It builds container images locally using Google Cloud Container Builder config file.
Why not just do docker build? It will be useful to provide an easy way to manage multiple steps builds.
- We love small docker images:
- Don't want to contain golang environment. We love a single go binary docker image.
- Don't Want to contain frontend js build environment for a web app.
steps:
- name: gcr.io/cloud-builders/docker
args: ["build", "-t", "cb-build", "-f", "Dockerfile.build", "."]
- name: cb-build
args: ["cp", "/go/src/cb/cb", "/workspace"]
- name: gcr.io/cloud-builders/docker
args: ["build", "-t", "cb", "."]
This is an example config file. It will build a golang single binary image of cb command itself (not useful though).
- 1st step - Build a temporary image. It builds a go binary using
golangbase image as usual. - 2nd step - Run the resulted image of 1st step. It copies the golang binary in the image to workspace volume.
- 3rd step - Build a final image from scratch. Just add the
cbcommand from workplace volume.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cb latest 05994f135ea4 2 days ago 3.208 MB
cb-build latest 61f9b946f604 2 days ago 680.9 MB
...
go get -u github.com/hiroshi/cb
Make sure you have $GOPATH/bin in your $PATH.
cb SOURCE.tar.gz --config CONFIG.(json|yml)
- The
sourcefield in config will be ignored as well asgcloud alpha container builds createdo. Specify SOURCE as 1st argument. - The
imagesfield in config will be ignored. Thecbcommand is intended for local builds so always pushing images are not supposed to be welcome.
-
- Create a volume for
workspacewithdocker volume create.
- Create a volume for
-
- Expand
SOURCEinto theworkspacevolume withdocker copy.
- Expand
-
docker runan image with volumes/var/run/docker.sock//var/run/docker.sock/,WORKSPACE_VOLUME:/workspace.
- If the image have docker command like this, you can do
docker buildor anything in container with SOURCE at hand.
-
- Repeat 3) with different image and args as you specifed in
stepsfield of CONFIG.
- Repeat 3) with different image and args as you specifed in
Do you get it? No? See and run examples, I hope it may help you understand.
make run-example
- Support
wait_forandidfields ofsteps