Raj
Raj

Reputation: 2920

How to create multiple containers with dependencies using Google Cloud Builder

I am looking for help creating a cloudbuild.yaml file for my application. My application has a base image derived from phython:2-onbuild and then two additional images that derive from that base image. I have three separate Dockerfiles in my project for each. Is there an example of doing this that someone could point me towards?

For example, my base image Dockerfile looks like this:

FROM python:2-onbuild
# This will execute pip install requirements.txt and get all required python packages installed
# It will also ensure the current directly, minus anything in .dockerignore is copied over to the image
# The web server image and the worker image can then simply inherit from this.

Then subsequently, I create a web server image and a worker image. The worker is intended to be run as a CronJob.

My web server Dockerfile is like so:

FROM myapp-base

RUN chmod +x ./main_runner.sh
RUN chmod +w static/login.html
RUN chmod +w static/index.html
CMD ./main_runner.sh

and my worker Dockerfile is:

FROM myapp-base

RUN chmod +x worker_runner.sh
CMD python ./run_worker.py

Currently, my local docker-compose.yaml ties it all together by creating the myapp-base image and making it available by that name so the other images can derive from it. What is the equivalent in cloud build?

Upvotes: 4

Views: 3383

Answers (1)

David Bendory
David Bendory

Reputation: 1268

This example, from our open-sourced "docker" build-step, creates 3 different images from 3 different Dockerfiles. Is that what you're looking for?

Upvotes: 5

Related Questions