mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-20 02:27:57 +00:00
fix(dev): cache bust mutable coold nightly assets
This commit is contained in:
@@ -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/hosts
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -31,7 +31,9 @@ ARG TARGETARCH
|
||||
ARG POSTGRES_VERSION
|
||||
ARG CLOUDFLARED_VERSION
|
||||
ARG COOLIFY_FLUX_VERSION
|
||||
ARG COOLIFY_FLUX_CHECKSUM
|
||||
ARG COOLIFY_CLI_VERSION
|
||||
ARG COOLIFY_CLI_CHECKSUM
|
||||
ARG NGINX_VERSION
|
||||
|
||||
WORKDIR /var/www/html
|
||||
@@ -90,6 +92,7 @@ RUN mkdir -p /usr/local/bin && \
|
||||
|
||||
# Install Flux from coold nightly release based on architecture
|
||||
RUN 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 architecture
|
||||
RUN set -eux; \
|
||||
echo "Coolify CLI checksum: ${COOLIFY_CLI_CHECKSUM}"; \
|
||||
mkdir -p /usr/local/bin; \
|
||||
case "${TARGETARCH:-}" in \
|
||||
amd64|arm64) COOLIFY_CLI_ARCH="${TARGETARCH}" ;; \
|
||||
|
||||
@@ -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() {
|
||||
fi
|
||||
|
||||
echo "==> 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 ]; then
|
||||
COOLIFY_CLI_SSH_USER="$(coolify_ssh_user)" spin up -d "${spin_args[@]}"
|
||||
else
|
||||
|
||||
@@ -34,3 +34,19 @@ it('runs the v5 dev Lima seeder with the normal development database seeder', fu
|
||||
expect($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=');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user