Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: docker compose bake #90

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
KyleTryon marked this conversation as resolved.
Show resolved Hide resolved
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
KyleTryon marked this conversation as resolved.
Show resolved Hide resolved

- 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 }}
```