[subaction/matrix] Generate multiple matrices when targets reference other targets as build contexts
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- docker, github-actions, typescript
Línea de trabajo
Comienza en la matrix subaction y sigue cómo se genera la lista de destinos actual a partir del ejemplo docker-bake.hcl. Define la finalización produciendo matrices agrupadas por dependencias, además de salidas jobs_amount y matrices que el flujo de trabajo de GitHub Actions por etapas pueda consumir sin duplicar builds dependientes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
We'd like to use the matrix subaction to generate multiple matrices, since we have a couple of targets that depend on other targets and would like to avoid building the same target multiple times.
As an example, consider the following docker-bake.hcl (containing targets with Dockerfiles that can't be easily merged into a multi-stage Dockerfile):
group "default" {
targets = ["apps", "special-app"]
}
target "base" {
context = "basedir"
tags = ["base:latest"]
}
target "apps" {
name = "app_${version}"
context = "appdir/${version}"
matrix = {
version = ["1-0-0", "2-0-0", "2-1-5"]
}
tags = ["app:${version}"]
contexts = {
base = "target:base"
}
}
target "special-app" {
context = "appdir/special"
tags = ["special-app:latest"]
contexts = {
app = "target:app_2-0-0"
}
}
Now we commit and push a change to basedir/Dockerfile, which triggers a GitHub workflow that builds these targets on multiple runners using the matrix subaction and pushes them to our registry.
Currently the subaction generates the following matrix:
[{"target": "base"}, {"target": "app_1-0-0"}, {"target": "app_2-0-0"}, {"target": "app_2-1-5"}, {"target": "special-app"}]
This generates 5 workflow jobs running in parallel, but most of them spend time building dependent targets first, which other jobs are already building. This results in a lot of duplicate work which could be avoided.
Ideally the subaction would generate multiple matrices like this:
[
[{"target": "base"}],
[{"target": "app_1-0-0"}, {"target": "app_2-0-0"}, {"target": "app_2-1-5"}],
[{"target": "special-app"}]
]
This way we could define multiple jobs that depend on the previous ones and supply them with one matrix each.
Snippet of an example workflow using multiple matrices
jobs:
generate:
runs-on: ubuntu-latest
outputs:
jobs_amount: ${{ steps.generate.outputs.jobs_amount }}
matrices: ${{ steps.generate.outputs.matrices }}
steps:
- uses: actions/checkout@v6
- id: generate
uses: docker/bake-action/subaction/matrix@multiple-matrices
stage_1:
needs:
- generate
if: ${{ fromJson(needs.generate.outputs.jobs_amount) >= 1 }}
strategy:
matrix:
include: ${{ toJson(fromJson(needs.generate.outputs.matrices)[0]) }}
steps:
# ...
stage_2:
needs:
- generate
- stage_1
if: ${{ fromJson(needs.generate.outputs.jobs_amount) >= 2 }}
strategy:
matrix:
include: ${{ toJson(fromJson(needs.generate.outputs.matrices)[1]) }}
steps:
# ...
stage_3:
needs:
- generate
- stage_2
if: ${{ fromJson(needs.generate.outputs.jobs_amount) >= 3 }}
strategy:
matrix:
include: ${{ toJson(fromJson(needs.generate.outputs.matrices)[2]) }}
steps:
# ...
We imagine that this usecase is common enough to be supported here and would like to contribute that feature, since we already made it for our own workflows.
Would you be interested in this feature?
- Lenguaje dominante
- TypeScript
- Estrellas
- 302
- Forks
- 42
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de docker/bake-action
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
docker/bake-action#488 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Add support for dockerignoreAbiertokind/enhancement status/triage
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
docker/bake-action#458 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
status/triage
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
docker/bake-action#322 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
status/needs-more-info
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
docker/bake-action#312 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
unknown cache exporterAbiertostatus/needs-investigation
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
docker/bake-action#306 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de docker/bake-action
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
marmelab/react-admin#11431 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
db-ux-design-system/core-web#8655 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
stripe/react-stripe-js#728 ·
-
[Upload Grade C dataset] the pop-up changes it's size while uploading the document => Jumping effectAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
epam/statgpt-admin-frontend#305 ·
Los mantenedores suelen responder en 1 día