Skip to content

BuildCompose

Boris Feld edited this page Jun 7, 2019 · 6 revisions

The build-compose command allows you to build multiple images described in a docker-compose.yml file in your target.

⚠️ Only docker compose versions 3 are supported

All images with the build section set will be built. That means your docker-compose.yml file can use external images (like postgresql:latest) that will be skipped, alongside your own images to build.

Arguments

Argument Type Description Sample values
--compose-file, -c Optional path, defaults to docker-compose.yml Path to the docker-compose.yml file in your target path/to/docker-compose.yml
--registry Optional string, defaults to env variable REGISTRY or registry.hub.docker.com if not set Sets the registry used to tag the images produced. Useful when combining with push-artifact registry.hub.docker.com
--write Optional path Directory where the produced images will be stored as TAR archives. Used for artifacts uploading /builds/images/
--build-retries, -r Optional positive integer, defaults to 3 Number of times each image build will be retried after a failure (network, ...) 5
--build-arg Optional multiple KEY=VALUE strings Build arguments provided to each Docker image built. They need to be namespaced to be efficient across images. BACKEND_VERSION=1.2.3
--tag Optional multiple strings, defaults to latest Docker tags applied on the built image --tag=latest --tag=1.2.3
--service Optional multiple strings Limit the docker-compose file processing to those servcies. my-project

Taskcluster integration

As this command builds a Docker image, you will need the following:

  • scope docker-worker:capability:privileged on your task
  • a worker type that can use the privileged capability (ask a #taskcluster admin)
  • request the priviliged state in your task payload:
payload:
  capabilities:
    privileged: true

Example

Here is a dummy docker-compose.yml file that would build a single image, tagged mozilla/my-project:latest

version: '3.2'
services:
  my-project:
    build:
      context: .
      dockerfile: infra/dockerfile.base
    image: mozilla/my-project

  database:
    image: postgresql:latest
Clone this wiki locally