From 1d9e3698cd44044f24132b7f657f848bf2379006 Mon Sep 17 00:00:00 2001 From: Romain Gautier Date: Fri, 3 Jul 2026 01:36:14 +0200 Subject: [PATCH] try to optimize dagger with cache --- .tangled/workflows/build.yml | 15 ++++++++++++++- application/Dockerfile | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.tangled/workflows/build.yml b/.tangled/workflows/build.yml index 8c3d0f4..13f7191 100644 --- a/.tangled/workflows/build.yml +++ b/.tangled/workflows/build.yml @@ -22,7 +22,20 @@ steps: command: devenv shell true - name: "Build docker image" - command: DAGGER_NO_NAG=1 devenv shell dagger call application build-prod export-image --name app-php-prod:latest + command: | + devenv shell -- bash -c ' + set -euo pipefail + export DOCKER_BUILDKIT=1 + CACHE_REF="${CACHE_REF:-ttl.sh/rssbase-application-build-cache:24h}" + docker buildx create --use --name rssbase-ci-builder >/dev/null 2>&1 || docker buildx use rssbase-ci-builder + docker buildx inspect --bootstrap + docker buildx build application \ + --target frankenphp_prod \ + --tag app-php-prod:latest \ + --cache-from "type=registry,ref=${CACHE_REF}" \ + --cache-to "type=registry,ref=${CACHE_REF},mode=max" \ + --load + ' - name: "Start docker container and smoke test" command: | diff --git a/application/Dockerfile b/application/Dockerfile index 239beaf..879c111 100644 --- a/application/Dockerfile +++ b/application/Dockerfile @@ -78,7 +78,9 @@ COPY --link frankenphp/conf.d/20-app.prod.ini $PHP_INI_DIR/app.conf.d/ # prevent the reinstallation of vendors at every changes in the source code COPY --link composer.* symfony.* ./ -RUN composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress +ENV COMPOSER_CACHE_DIR=/tmp/composer-cache +RUN --mount=type=cache,target=/tmp/composer-cache,sharing=locked \ + composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress # copy sources COPY --link --exclude=frankenphp/ . ./ -- 2.51.2