I'm proposing some updates on the Docker image:
- Usage of
php:7.1-cli
instead of the regularphp:7
. This change provides the official PHP image on Docker Hub, on it's currently latest tag. Also it only have the PHP CLI version, so the image is more clean (without the extra PHP settings required for the Web version). - Usage of arguments. This provides a powerful resource for Docker images as labels, provided by Microbadger, a service designed to inspect what's inside Docker images, along with extra data like image name, VCS reference by latest commit, build date and VCS URL.
- Put all commands into a single
RUN
declaration. This makes the image lightier than it was before, as for eachRUN
it creates a new layer (the more the more layers, the heavier the image gets).
Go to the terminal and run:
docker build -t marcelsud/diffcs:v0.2.1 \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg RELEASE_VERSION='v0.2.1' \
.
The build arguments, as described below:
- VCS_REF indicates the last commit, shortened. Useful for GitHub integrations.
- BUILD_DATE indicates the date when the image was built.
- RELEASE_VERSION indicates which DiffCS version should be installed. So you don't have to edit your Dockerfile for each time you want to generate a new tag of it ๐
Also, I strongly suggest to execute he build process twice, for each release:
- The first using the tag related to the project's current tag, as
marcelsud/diffcs:v0.2.1
; - Then finally the last one, using the
latest
tag, asmarcelsud/diffcs:latest
, in order to always provide the top-fresh version onlatest
.
Then at last, publish each tag as below:
docker push marcelsud/diffcs:v0.2.1
- Keep in mind that you can use the same arguments in the automated build process through Docker Hub! ๐
- Use the
org.label-schema.vcs-url
label if you want to keep your Dockerfile under GitHub.