Skip to content

Commit

Permalink
docs: docker compose bake
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleTryon committed Oct 24, 2024
1 parent 50e0272 commit bf6ece1
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions content/guides/docker-compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,46 @@ When using `docker compose build` with Depot, there are a few things to be aware
3. It's not possible to use multiple different Depot projects for different Compose services with `docker compose build`.

However, `depot configure-docker` does directly integrate with any tools that use Docker Buildx, so if you are unable to use `depot bake --load` or otherwise need full Buildx compatibility with other tools, this is a good option.

## Building and testing `docker compose` on GitHub Actions

As we described above, the `depot bake` command can accept a `docker-compose.yml` file and build all services in parallel. However, by default this command will not load the images back into the local Docker daemon, which is necessary for running `docker compose` commands.
In this example, we demonstrate how to use `depot bake` to build all services defined in a `docker-compose.yml` file, followed by `depot pull` to load the built images into the local Docker daemon. This makes it possible to run `docker compose` commands, such as `docker compose run tests`, as usual. Once the tests pass, you can use depot push to push the images to a registry.

```yaml
name: Depot example compose
on: push
permissions:
contents: read
id-token: write
packages: write
jobs:
compose-example:
runs-on: depot-ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: depot/setup-action@v1
- name: Build, cache, and save all compose images to the depot ephemeral registry.
uses: depot/bake-action@v1
id: bake
with:
files: docker-compose.yml
save: true
- name: Pull all compose service images locally from the ephemeral registry.
uses: depot/pull-action@v1
with:
build-id: ${{ steps.bake.outputs.build-id }}
- name: Run compose up (images should not rebuild)
run: |
docker compose up
- name: If successful push the srv1 compose service target image to ghcr.io from ephemeral registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $ --password-stdin
depot push --target srv1 -t ghcr.io/depot/srv1:latest ${{ steps.build.outputs.build-id }}
```

0 comments on commit bf6ece1

Please sign in to comment.