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 all commits
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
47 changes: 47 additions & 0 deletions content/guides/docker-compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,50 @@ 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

With the `depot/bake-action` action and the `--save` flag, we can build all of the services in a Compose file in parallel and save them to the Depot ephemeral registry. Then, with the `depot/pull-action`, we can pull all of the images back into the local Docker daemon for testing in subsequent jobs.

```yaml
name: Depot example compose
on: push

permissions:
contents: read
id-token: write
packages: write

jobs:
build-services:
runs-on: ubuntu-22.04
outputs:
build-id: ${{ steps.bake.outputs.build-id }}
steps:
- uses: actions/checkout@v4
- 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

test:
runs-on: depot-ubuntu-22.04
needs: [build-services]
steps:
- uses: actions/checkout@v4
- uses: depot/setup-action@v1
- name: Pull all compose service images locally from the ephemeral registry.
uses: depot/pull-action@v1
with:
build-id: ${{ needs.build-services.outputs.build-id }}
- name: Run compose up (images should not rebuild)
run: |
docker compose up -d
- 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 }}
```