How to modify tags for multiple images from docker-bake.hcl #551
-
|
How to set tags for multistage images for an Laravel application. The images are almost identical, apart of CMD and HEALTHCHECK dockerfile docker-bake.hcl I would like to generate tags, which have as an prefix the target At the moment I call docker/metadata-action three times with My project:
Similar
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I would suggest to put targets to build in a bake group like: group "builds" {
targets = ["app", "worker", "scheduler"]
}
target app {
...
}
target worker {
...
}
target scheduler {
...
}Then you can use a GitHub Actions matrix to distribute solved targets of this group using our matrix subaction: https://github.com/docker/bake-action/tree/master/subaction/matrix jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v5
-
name: Generate matrix
id: generate
uses: docker/bake-action/subaction/matrix@v6
with:
target: builds
build:
runs-on: ubuntu-latest
needs:
- prepare
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
-
name: Checkout
uses: actions/checkout@v5
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
name/app
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
flavor: |
suffix=-${{ matrix.target }}
-
name: Build
uses: docker/bake-action@v6
with:
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
targets: ${{ matrix.target }} |
Beta Was this translation helpful? Give feedback.
I would suggest to put targets to build in a bake group like:
Then you can use a GitHub Actions matrix to distribute solved targets of this group using our matrix subaction: https://github.com/docker/bake-action/tree/master/subaction/matrix