From 6bff6b2b0112865810f555ae56aedc2ed15b3260 Mon Sep 17 00:00:00 2001 From: rosslh Date: Mon, 16 Feb 2026 20:35:23 -0800 Subject: [PATCH] feat: add update pipeline with MapleDeploy CDN and versioning Route all Coolify update artifacts (versions.json, upgrade.sh, compose files) through updates.mapledeploy.ca instead of upstream cdn.coollabs.io. Extend CI to publish artifacts to Bunny CDN storage zone and purge cache on each build. - Point CDN_URL, versions_url, upgrade_script_url to updates.mapledeploy.ca - Hardcode helper/realtime images to ghcr.io (not mirrored to Forgejo) - Pass registry_url as 3rd arg to upgrade.sh for main image pulls - Adopt versioning scheme 4.0.0-beta.X.N (bump to 4.0.0-beta.463.1) - Add CI steps: generate versions.json, upload to Bunny, purge cache --- .env.production | 3 +- .forgejo/workflows/build.yml | 58 +++++++++++++++++++++++++++- app/Actions/Server/UpdateCoolify.php | 4 +- config/constants.php | 8 ++-- docker-compose.prod.yml | 4 +- scripts/upgrade.sh | 8 ++-- 6 files changed, 72 insertions(+), 13 deletions(-) diff --git a/.env.production b/.env.production index fe3c8370e..f1d95827f 100644 --- a/.env.production +++ b/.env.production @@ -15,4 +15,5 @@ ROOT_USERNAME= ROOT_USER_EMAIL= ROOT_USER_PASSWORD= -REGISTRY_URL=ghcr.io +REGISTRY_URL=forgejo.mapledeploy.ca +CDN_URL=https://updates.mapledeploy.ca diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 3d52419ed..f95a2ee75 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -10,6 +10,9 @@ on: env: REGISTRY: forgejo.mapledeploy.ca + CDN_STORAGE_ZONE: coolify-updates + CDN_PULL_ZONE_ID: "5338784" + CDN_BASE_URL: https://updates.mapledeploy.ca jobs: build: @@ -21,8 +24,12 @@ jobs: id: version run: | VERSION=$(sed -n "s/.*'version' => '\([^']*\)'.*/\1/p" config/constants.php) + HELPER_VERSION=$(sed -n "s/.*'helper_version' => '\([^']*\)'.*/\1/p" config/constants.php) + REALTIME_VERSION=$(sed -n "s/.*'realtime_version' => '\([^']*\)'.*/\1/p" config/constants.php) echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT" - echo "Building version: ${VERSION}" + echo "HELPER_VERSION=${HELPER_VERSION}" >> "$GITHUB_OUTPUT" + echo "REALTIME_VERSION=${REALTIME_VERSION}" >> "$GITHUB_OUTPUT" + echo "Building version: ${VERSION} (helper: ${HELPER_VERSION}, realtime: ${REALTIME_VERSION})" - name: Login to Forgejo registry run: | @@ -39,3 +46,52 @@ jobs: run: | docker push ${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.version.outputs.VERSION }} docker push ${{ env.REGISTRY }}/${{ github.repository }}:latest + + - name: Generate versions.json + run: | + cat > versions.json < ${dest}" + curl -fsSL -X PUT "${STORAGE_URL}/${dest}" \ + -H "AccessKey: ${{ secrets.BUNNY_CDN_STORAGE_KEY }}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"${file}" + } + + upload versions.json versions.json + upload scripts/upgrade.sh upgrade.sh + upload docker-compose.yml docker-compose.yml + upload docker-compose.prod.yml docker-compose.prod.yml + upload .env.production .env.production + + echo "All artifacts uploaded." + + - name: Purge CDN cache + run: | + curl -fsSL -X POST "https://api.bunny.net/pullzone/${{ env.CDN_PULL_ZONE_ID }}/purgeCache" \ + -H "AccessKey: ${{ secrets.BUNNY_API_KEY }}" \ + -H "Content-Type: application/json" + echo "CDN cache purged." diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index b5ebd92b2..0d5d5ac9d 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -119,9 +119,11 @@ private function update() $latestHelperImageVersion = getHelperVersion(); $upgradeScriptUrl = config('constants.coolify.upgrade_script_url'); + $registryUrl = config('constants.coolify.registry_url'); + remote_process([ "curl -fsSL {$upgradeScriptUrl} -o /data/coolify/source/upgrade.sh", - "bash /data/coolify/source/upgrade.sh $this->latestVersion $latestHelperImageVersion", + "bash /data/coolify/source/upgrade.sh $this->latestVersion $latestHelperImageVersion $registryUrl", ], $this->server); } } diff --git a/config/constants.php b/config/constants.php index bde7cec9a..3f46462ff 100644 --- a/config/constants.php +++ b/config/constants.php @@ -3,7 +3,7 @@ return [ // MapleDeploy branding: registry pointed to Forgejo, auto-update disabled by default 'coolify' => [ - 'version' => '4.0.0-beta.463', + 'version' => '4.0.0-beta.463.1', 'helper_version' => '1.0.12', 'realtime_version' => '1.0.10', 'self_hosted' => env('SELF_HOSTED', true), @@ -13,9 +13,9 @@ 'helper_image' => env('HELPER_IMAGE', 'ghcr.io/coollabsio/coolify-helper'), 'realtime_image' => env('REALTIME_IMAGE', 'ghcr.io/coollabsio/coolify-realtime'), 'is_windows_docker_desktop' => env('IS_WINDOWS_DOCKER_DESKTOP', false), - 'cdn_url' => env('CDN_URL', 'https://cdn.coollabs.io'), - 'versions_url' => env('VERSIONS_URL', env('CDN_URL', 'https://cdn.coollabs.io').'/coolify/versions.json'), - 'upgrade_script_url' => env('UPGRADE_SCRIPT_URL', env('CDN_URL', 'https://cdn.coollabs.io').'/coolify/upgrade.sh'), + 'cdn_url' => env('CDN_URL', 'https://updates.mapledeploy.ca'), + 'versions_url' => env('VERSIONS_URL', env('CDN_URL', 'https://updates.mapledeploy.ca').'/coolify/versions.json'), + 'upgrade_script_url' => env('UPGRADE_SCRIPT_URL', env('CDN_URL', 'https://updates.mapledeploy.ca').'/coolify/upgrade.sh'), 'releases_url' => 'https://cdn.coolify.io/releases.json', ], diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 46e0e88e5..13e01a445 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,6 +1,6 @@ services: coolify: - image: "${REGISTRY_URL:-ghcr.io}/coollabsio/coolify:${LATEST_IMAGE:-latest}" + image: "${REGISTRY_URL:-forgejo.mapledeploy.ca}/rosslh/coolify:${LATEST_IMAGE:-latest}" volumes: - type: bind source: /data/coolify/source/.env @@ -60,7 +60,7 @@ services: retries: 10 timeout: 2s soketi: - image: '${REGISTRY_URL:-ghcr.io}/coollabsio/coolify-realtime:1.0.10' + image: 'ghcr.io/coollabsio/coolify-realtime:1.0.10' ports: - "${SOKETI_PORT:-6001}:6001" - "6002:6002" diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index 648849d5c..4e4baf35f 100644 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh @@ -1,7 +1,7 @@ #!/bin/bash ## Do not modify this file. You will lose the ability to autoupdate! -CDN="https://cdn.coollabs.io/coolify" +CDN="https://updates.mapledeploy.ca/coolify" LATEST_IMAGE=${1:-latest} LATEST_HELPER_VERSION=${2:-latest} REGISTRY_URL=${3:-ghcr.io} @@ -155,7 +155,7 @@ echo "3/6 Pulling Docker images..." echo " This may take a few minutes depending on your connection." # Also pull the helper image (not in compose files but needed for upgrade) -HELPER_IMAGE="${REGISTRY_URL:-ghcr.io}/coollabsio/coolify-helper:${LATEST_HELPER_VERSION}" +HELPER_IMAGE="ghcr.io/coollabsio/coolify-helper:${LATEST_HELPER_VERSION}" echo " - Pulling $HELPER_IMAGE..." log "Pulling image: $HELPER_IMAGE" if docker pull "$HELPER_IMAGE" >>"$LOGFILE" 2>&1; then @@ -239,11 +239,11 @@ nohup bash -c " if [ -f /data/coolify/source/docker-compose.custom.yml ]; then log 'Using custom docker-compose.yml' log 'Running docker compose up with custom configuration...' - docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock \${DOCKER_CONFIG_MOUNT} --rm \${REGISTRY_URL:-ghcr.io}/coollabsio/coolify-helper:\${LATEST_HELPER_VERSION} bash -c \"LATEST_IMAGE=\${LATEST_IMAGE} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml -f /data/coolify/source/docker-compose.custom.yml up -d --remove-orphans --wait --wait-timeout 60\" >>\"\$LOGFILE\" 2>&1 + docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock \${DOCKER_CONFIG_MOUNT} --rm ghcr.io/coollabsio/coolify-helper:\${LATEST_HELPER_VERSION} bash -c \"LATEST_IMAGE=\${LATEST_IMAGE} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml -f /data/coolify/source/docker-compose.custom.yml up -d --remove-orphans --wait --wait-timeout 60\" >>\"\$LOGFILE\" 2>&1 else log 'Using standard docker-compose configuration' log 'Running docker compose up...' - docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock \${DOCKER_CONFIG_MOUNT} --rm \${REGISTRY_URL:-ghcr.io}/coollabsio/coolify-helper:\${LATEST_HELPER_VERSION} bash -c \"LATEST_IMAGE=\${LATEST_IMAGE} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d --remove-orphans --wait --wait-timeout 60\" >>\"\$LOGFILE\" 2>&1 + docker run -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock \${DOCKER_CONFIG_MOUNT} --rm ghcr.io/coollabsio/coolify-helper:\${LATEST_HELPER_VERSION} bash -c \"LATEST_IMAGE=\${LATEST_IMAGE} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d --remove-orphans --wait --wait-timeout 60\" >>\"\$LOGFILE\" 2>&1 fi log 'Docker compose up completed'