chore: use github for docker build layer caches (#10346)

# Which Problems Are Solved

Building the login container in the pipeline without build layer caches
takes about 20 minutes.

# How the Problems Are Solved

We use cache-from and cache-to arguments to use the GitHub cache API.
Compare 1st and 2nd run [of this PRs
pipeline](https://github.com/zitadel/zitadel/actions/runs/16590808510/job/46927893304)

# Additional Context

- Follows up on #10343
This commit is contained in:
Elio Bischof
2025-07-29 12:45:01 +02:00
committed by GitHub
parent 5f5f198b22
commit b206a8ed87
2 changed files with 38 additions and 21 deletions

View File

@@ -1,9 +1,16 @@
x-build-cache: &build-cache
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
services: services:
devcontainer: devcontainer:
container_name: devcontainer container_name: devcontainer
build: build:
context: . context: .
<<: *build-cache
volumes: volumes:
- ../../:/workspaces:cached - ../../:/workspaces:cached
- /tmp/.X11-unix:/tmp/.X11-unix:cached - /tmp/.X11-unix:/tmp/.X11-unix:cached
@@ -36,6 +43,7 @@ services:
container_name: mock-zitadel container_name: mock-zitadel
build: build:
context: ../../apps/login/integration/core-mock context: ../../apps/login/integration/core-mock
<<: *build-cache
ports: ports:
- 22220:22220 - 22220:22220
- 22222:22222 - 22222:22222
@@ -45,6 +53,7 @@ services:
build: build:
context: ../.. context: ../..
dockerfile: build/login/Dockerfile dockerfile: build/login/Dockerfile
<<: *build-cache
image: "${LOGIN_TAG:-zitadel-login:local}" image: "${LOGIN_TAG:-zitadel-login:local}"
env_file: ../../apps/login/.env.test env_file: ../../apps/login/.env.test
network_mode: service:devcontainer network_mode: service:devcontainer
@@ -80,6 +89,7 @@ services:
build: build:
context: ../../apps/login/acceptance/setup context: ../../apps/login/acceptance/setup
dockerfile: ../go-command.Dockerfile dockerfile: ../go-command.Dockerfile
<<: *build-cache
entrypoint: "./setup.sh" entrypoint: "./setup.sh"
network_mode: service:devcontainer network_mode: service:devcontainer
environment: environment:
@@ -116,6 +126,7 @@ services:
dockerfile: ../go-command.Dockerfile dockerfile: ../go-command.Dockerfile
args: args:
- LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine} - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
<<: *build-cache
environment: environment:
PORT: '3333' PORT: '3333'
command: command:
@@ -140,6 +151,7 @@ services:
dockerfile: ../go-command.Dockerfile dockerfile: ../go-command.Dockerfile
args: args:
- LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine} - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
<<: *build-cache
network_mode: service:devcontainer network_mode: service:devcontainer
environment: environment:
API_URL: 'http://localhost:8080' API_URL: 'http://localhost:8080'
@@ -163,6 +175,7 @@ services:
# dockerfile: ../../go-command.Dockerfile # dockerfile: ../../go-command.Dockerfile
# args: # args:
# - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine} # - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
# <<: *build-cache
# network_mode: service:devcontainer # network_mode: service:devcontainer
# environment: # environment:
# API_URL: 'http://localhost:8080' # API_URL: 'http://localhost:8080'
@@ -184,6 +197,7 @@ services:
dockerfile: ../go-command.Dockerfile dockerfile: ../go-command.Dockerfile
args: args:
- LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine} - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
<<: *build-cache
network_mode: service:devcontainer network_mode: service:devcontainer
environment: environment:
API_URL: 'http://localhost:8080' API_URL: 'http://localhost:8080'
@@ -198,27 +212,27 @@ services:
depends_on: depends_on:
configure-login: configure-login:
condition: "service_completed_successfully" condition: "service_completed_successfully"
# mock-samlidp:
# mock-samlidp: # container_name: mock-samlidp
# container_name: mock-samlidp # build:
# build: # context: ../../apps/login/acceptance/idp/saml
# context: ../../apps/login/acceptance/idp/saml # dockerfile: ../../go-command.Dockerfile
# dockerfile: ../../go-command.Dockerfile # args:
# args: # - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
# - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine} # <<: *build-cache
# network_mode: service:devcontainer # network_mode: service:devcontainer
# environment: # environment:
# API_URL: 'http://localhost:8080' # API_URL: 'http://localhost:8080'
# API_DOMAIN: 'localhost' # API_DOMAIN: 'localhost'
# PAT_FILE: '/pat/zitadel-admin-sa.pat' # PAT_FILE: '/pat/zitadel-admin-sa.pat'
# SCHEMA: 'http' # SCHEMA: 'http'
# HOST: 'localhost' # HOST: 'localhost'
# PORT: "8003" # PORT: "8003"
# volumes: # volumes:
# - "../apps/login/packages/acceptance/pat:/pat" # - "../apps/login/packages/acceptance/pat:/pat"
# depends_on: # depends_on:
# configure-login: # configure-login:
# condition: "service_completed_successfully" # condition: "service_completed_successfully"
volumes: volumes:
postgres-data: postgres-data:

View File

@@ -59,6 +59,9 @@ jobs:
provenance: true provenance: true
sbom: true sbom: true
targets: login-standalone targets: login-standalone
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
files: | files: |
./apps/login/docker-bake.hcl ./apps/login/docker-bake.hcl
./apps/login/docker-bake-release.hcl ./apps/login/docker-bake-release.hcl