An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(dev): cache bust mutable coold nightly assets
Andras Bacsaia42785189ecb
diff --git a/.gitignore b/.gitignoreindex 792578dbcf..401adc775e 100644--- a/.gitignore+++ b/.gitignore@@ -43,6 +43,7 @@ tests/v4/Browser/Screenshots# Local generated Lima configs.dev/bin/+.dev/coold-assets/.dev/lima/ssh.config.dev/lima/ssh_key.dev/lima/hostsdiff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex 6cfa907236..9bd8286861 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -9,7 +9,9 @@ services:- USER_ID=${USERID:-1000}- GROUP_ID=${GROUPID:-1000}- COOLIFY_FLUX_VERSION=${COOLIFY_FLUX_VERSION:-nightly}+ - COOLIFY_FLUX_CHECKSUM=${COOLIFY_FLUX_CHECKSUM:-unknown}- COOLIFY_CLI_VERSION=${COOLIFY_CLI_VERSION:-nightly}+ - COOLIFY_CLI_CHECKSUM=${COOLIFY_CLI_CHECKSUM:-unknown}ports:- "${APP_PORT:-8000}:8080"- "${FORWARD_FLUX_PORT:-6443}:6443"diff --git a/docker/development/Dockerfile b/docker/development/Dockerfileindex 73fcbd4098..337e79b2b0 100644--- a/docker/development/Dockerfile+++ b/docker/development/Dockerfile@@ -31,7 +31,9 @@ ARG TARGETARCHARG POSTGRES_VERSIONARG CLOUDFLARED_VERSIONARG COOLIFY_FLUX_VERSION+ARG COOLIFY_FLUX_CHECKSUMARG COOLIFY_CLI_VERSION+ARG COOLIFY_CLI_CHECKSUMARG NGINX_VERSIONWORKDIR /var/www/html@@ -90,6 +92,7 @@ RUN mkdir -p /usr/local/bin && \# Install Flux from coold nightly release based on architectureRUN set -eux; \+ echo "Flux checksum: ${COOLIFY_FLUX_CHECKSUM}"; \mkdir -p /usr/local/bin /run/coolify /etc/coolify; \chown -R www-data:www-data /run/coolify /etc/coolify; \case "${TARGETARCH:-}" in \@@ -112,6 +115,7 @@ RUN set -eux; \# Install coolify from coold nightly release based on architectureRUN set -eux; \+ echo "Coolify CLI checksum: ${COOLIFY_CLI_CHECKSUM}"; \mkdir -p /usr/local/bin; \case "${TARGETARCH:-}" in \amd64|arm64) COOLIFY_CLI_ARCH="${TARGETARCH}" ;; \diff --git a/scripts/dev.sh b/scripts/dev.shindex cc0e9e1e2b..7fba66f385 100755--- a/scripts/dev.sh+++ b/scripts/dev.sh@@ -65,6 +65,80 @@ coold_vm_dns_name() {printf '%s.local\n' "$(coold_vm_instance "$index")"}+coold_asset_arch() {+ case "$(uname -m)" in+ arm64|aarch64)+ printf 'arm64\n'+ ;;+ x86_64|amd64)+ printf 'amd64\n'+ ;;+ *)+ echo "ERROR: Unsupported coold asset architecture: $(uname -m)" >&2+ return 1+ ;;+ esac+}++resolve_coold_asset_checksum() {+ local version="$1"+ local asset="$2"+ local arch+ local url++ arch="$(coold_asset_arch)"+ url="https://github.com/coollabsio/coold/releases/download/${version}/${asset}-linux-musl-${arch}.tar.gz.sha256"++ curl -fsSL --retry 3 --max-time 30 "$url" | awk '{ print $1; exit }'+}++prepare_coold_asset_cache_bust() {+ local flux_version+ local cli_version+ local cache_dir="$ROOT/.dev/coold-assets"+ local cache_file="$cache_dir/docker-cache-key"+ local previous_key=""+ local current_key+ local resolved_checksum++ flux_version="$(read_coolify_env COOLIFY_FLUX_VERSION nightly)"+ cli_version="$(read_coolify_env COOLIFY_CLI_VERSION nightly)"++ if [ -z "${COOLIFY_FLUX_CHECKSUM:-}" ]; then+ if resolved_checksum="$(resolve_coold_asset_checksum "$flux_version" flux 2>/dev/null)"; then+ export COOLIFY_FLUX_CHECKSUM="$resolved_checksum"+ else+ echo "WARN: Could not resolve Flux checksum for ${flux_version}; Docker may reuse a cached Flux layer." >&2+ export COOLIFY_FLUX_CHECKSUM=unknown+ fi+ fi++ if [ -z "${COOLIFY_CLI_CHECKSUM:-}" ]; then+ if resolved_checksum="$(resolve_coold_asset_checksum "$cli_version" coolify 2>/dev/null)"; then+ export COOLIFY_CLI_CHECKSUM="$resolved_checksum"+ else+ echo "WARN: Could not resolve Coolify CLI checksum for ${cli_version}; Docker may reuse a cached CLI layer." >&2+ export COOLIFY_CLI_CHECKSUM=unknown+ fi+ fi++ current_key="flux=${flux_version}:${COOLIFY_FLUX_CHECKSUM};cli=${cli_version}:${COOLIFY_CLI_CHECKSUM}"++ if [ -f "$cache_file" ]; then+ previous_key="$(cat "$cache_file")"+ fi++ mkdir -p "$cache_dir"+ printf '%s\n' "$current_key" > "$cache_file"++ if [ "$previous_key" != "$current_key" ]; then+ COOLD_ASSETS_CHANGED=changed+ return+ fi++ COOLD_ASSETS_CHANGED=unchanged+}+resolve_lima_dns_name() {local name="$1"local ip=""@@ -551,6 +625,12 @@ up() {fiecho "==> Starting Coolify Docker stack with Spin..."+ prepare_coold_asset_cache_bust+ if [ "$COOLD_ASSETS_CHANGED" = "changed" ]; then+ echo "==> Coold nightly assets changed; rebuilding the Coolify dev image..."+ COOLIFY_CLI_SSH_USER="$(coolify_ssh_user)" spin build coolify+ fi+if [ "${#spin_args[@]}" -gt 0 ]; thenCOOLIFY_CLI_SSH_USER="$(coolify_ssh_user)" spin up -d "${spin_args[@]}"elsediff --git a/tests/Feature/DevEnvironmentExampleTest.php b/tests/Feature/DevEnvironmentExampleTest.phpindex 3860605481..fb2ef713d6 100644--- a/tests/Feature/DevEnvironmentExampleTest.php+++ b/tests/Feature/DevEnvironmentExampleTest.php@@ -34,3 +34,19 @@ it('runs the v5 dev Lima seeder with the normal development database seeder', fuexpect($developmentSeederBlock)->toContain('DevelopmentRailpackExamplesSeeder::class')->and($developmentSeederBlock)->toContain('V5DevLimaSeeder::class');});++it('cache busts mutable nightly coold assets with resolved checksums', function () {+ $compose = file_get_contents(base_path('docker-compose.dev.yml'));+ $dockerfile = file_get_contents(base_path('docker/development/Dockerfile'));+ $devScript = file_get_contents(base_path('scripts/dev.sh'));++ expect($compose)->toContain('COOLIFY_FLUX_CHECKSUM=${COOLIFY_FLUX_CHECKSUM:-unknown}')+ ->and($compose)->toContain('COOLIFY_CLI_CHECKSUM=${COOLIFY_CLI_CHECKSUM:-unknown}')+ ->and($dockerfile)->toContain('ARG COOLIFY_FLUX_CHECKSUM')+ ->and($dockerfile)->toContain('ARG COOLIFY_CLI_CHECKSUM')+ ->and($dockerfile)->toContain('Flux checksum: ${COOLIFY_FLUX_CHECKSUM}')+ ->and($dockerfile)->toContain('Coolify CLI checksum: ${COOLIFY_CLI_CHECKSUM}')+ ->and($devScript)->toContain('resolve_coold_asset_checksum')+ ->and($devScript)->toContain('export COOLIFY_FLUX_CHECKSUM=')+ ->and($devScript)->toContain('export COOLIFY_CLI_CHECKSUM=');+});