Description
Versioning tools for Dockerfile source repos. Previously, these tools were in runtimes-common, but have been moved to click-to-deploy for further development.
dockerfiles
generates versionsed Dockerfiles from a common template.
cloudbuild
generates a configuration file to build these Dockerfiles using
Google Container Builder.
Installation
git clone https://github.com/GoogleCloudPlatform/click-to-deploy.git
cd click-to-deploy/tools
bazel run //:gazelle
bazel build dockerversioning/scripts/dockerfiles:dockerfiles
bazel build dockerversioning/scripts/cloudbuild:cloudbuild
- Set the path to the built scripts:
BAZEL_ARCH=linux_amd64_stripped
export PATH=$PATH:$PWD/bazel-bin/dockerversioning/scripts/dockerfiles/${BAZEL_ARCH}/
export PATH=$PATH:$PWD/bazel-bin/dockerversioning/scripts/cloudbuild/${BAZEL_ARCH}/
Create versions.yaml
At root of the Dockerfile source repo, add a file called versions.yaml
.
Follow the format defined in versions.go
. See an example on
github.
Primary folders in the Dockerfile source repo:
templates
contains Dockerfile.template
, which is a Go template for
generating Dockerfile
s.
tests
contains any tests that should be included in the generated cloud
build configuration.
- Version folders as defined in
versions.yaml
. The Dockerfile
s are
generated into these folders. The folders should also contain all
supporting files for each version, for example docker-entrypoint.sh
files.
Usage of dockerfiles
command
cd path/to/dockerfile/repo
dockerfiles
Usage of cloudbuild
command
cd path/to/dockerfile/repo
cloudbuild > cloudbuild.yaml
You can use the generated cloudbuild.yaml
file as followed:
gcloud container builds submit --config=cloudbuild.yaml .