diff --git a/.tangled/workflows/check.yml b/.tangled/workflows/check.yml index 19281b4..09ad689 100644 --- a/.tangled/workflows/check.yml +++ b/.tangled/workflows/check.yml @@ -21,28 +21,5 @@ steps: - name: "Initialize devenv" command: devenv shell true - - name: "Publish Dagger base image cache" - command: | - devenv shell -- bash -c ' - set -euo pipefail - export DAGGER_NO_NAG=1 - BASE_HASH="$(sha256sum \ - application/Dockerfile \ - application/frankenphp/conf.d/10-app.ini \ - application/frankenphp/docker-entrypoint.sh \ - application/frankenphp/Caddyfile \ - | sha256sum | cut -c1-16)" - BASE_REF="${DAGGER_PHP_BASE_REF:-ttl.sh/rssbase-application-dagger-frankenphp-base-${BASE_HASH}:24h}" - - if docker buildx imagetools inspect "${BASE_REF}" >/dev/null 2>&1; then - echo "Using cached Dagger base image: ${BASE_REF}" - else - echo "Publishing Dagger-built base image: ${BASE_REF}" - dagger call application build-base publish --address "${BASE_REF}" - fi - - dagger settings application phpBaseImageRef "${BASE_REF}" - ' - - name: "Run checks" - command: DAGGER_NO_NAG=1 devenv shell dagger check + command: DAGGER_NO_NAG=1 devenv shell dagger check --env ci diff --git a/application/.dagger/main.dang b/application/.dagger/main.dang index fcf7b10..83c965c 100644 --- a/application/.dagger/main.dang +++ b/application/.dagger/main.dang @@ -4,6 +4,7 @@ Dagger workflows for rssbase.io/application. type Application { pub source: Directory! pub phpBaseImageRef: String! + pub composerValidateBaseImageRef: String! new( ws: Workspace!, @@ -12,6 +13,10 @@ type Application { Useful in ephemeral CI where the Dagger engine cache starts empty. """ phpBaseImageRef: String! = "", + """ + Optional lightweight image for composer validate checks. + """ + composerValidateBaseImageRef: String! = "", ) { self.source = ws.directory("/application", exclude: [ ".dagger", @@ -19,23 +24,34 @@ type Application { "vendor", ]) self.phpBaseImageRef = phpBaseImageRef + self.composerValidateBaseImageRef = composerValidateBaseImageRef self } - let phpBase: Container! { - let base = if (phpBaseImageRef != "") { + let phpBaseImage: Container! { + if (phpBaseImageRef != "") { container.from(phpBaseImageRef) } else { buildBase } + } - base + let phpBase: Container! { + phpBaseImage .withDirectory("/app", source) .withWorkdir("/app") .withMountedCache("/tmp/composer-cache", cacheVolume("composer-cache")) .withEnvVariable("COMPOSER_CACHE_DIR", "/tmp/composer-cache") } + let composerValidateBase: Container! { + if (composerValidateBaseImageRef != "") { + container.from(composerValidateBaseImageRef) + } else { + phpBaseImage + } + } + """ Build the reusable FrankenPHP base image from application/Dockerfile. """ @@ -54,8 +70,10 @@ type Application { Validate Composer metadata. """ @check - pub composerValidate: String! { - phpBase + pub composerValidate(base: Container! = composerValidateBase): String! { + base + .withDirectory("/app", source) + .withWorkdir("/app") .withExec(["composer", "validate", "--strict"]) .stdout } diff --git a/dagger.toml b/dagger.toml index 50adc71..9759c01 100644 --- a/dagger.toml +++ b/dagger.toml @@ -2,3 +2,6 @@ source = "application" legacy-default-path = true # settings.source = "./path" + +[env.ci.modules.application.settings] +composerValidateBaseImageRef = "composer:2"