Skip to content

Commit 89f362f

Browse files
fix: registry-first deploy — service uses localhost:5000 image ref
Deploy script now updates services with localhost:5000/cubeos-app/api:latest instead of ghcr.io ref. GHCR image is pulled, tagged, and pushed to local registry before service update. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6378b52 commit 89f362f

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

scripts/ci-deploy.sh

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ fi
4646
docker pull ${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA}
4747
docker tag ${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA} ${GHCR_IMAGE}:latest
4848

49-
# --- Push to local registry (keeps registry in sync) ---
49+
# --- Push to local registry (registry-first: services always run from localhost:5000) ---
5050
LOCAL_REG_IMAGE="localhost:5000/cubeos-app/api:latest"
51-
docker tag "${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA}" "${LOCAL_REG_IMAGE}" 2>/dev/null && \
52-
docker push "${LOCAL_REG_IMAGE}" 2>/dev/null && \
53-
echo " Pushed to local registry: ${LOCAL_REG_IMAGE}" || \
54-
echo " WARN: Local registry push failed (non-fatal)"
51+
docker tag "${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA}" "${LOCAL_REG_IMAGE}"
52+
docker push "${LOCAL_REG_IMAGE}"
53+
echo " Pushed to local registry: ${LOCAL_REG_IMAGE}"
5554

5655
# =========================================================================
5756
# Pre-flight: kill zombie containers holding the port
@@ -67,7 +66,7 @@ if [ -n "${PORT_PID}" ]; then
6766
echo " ${ZOMBIE}"
6867
# Check if the running container is already on the target image
6968
RUNNING_IMAGE=$(docker ps --filter "name=cubeos-api" --format '{{.Image}}' | head -1 || true)
70-
if [ "${RUNNING_IMAGE}" = "${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA}" ]; then
69+
if [ "${RUNNING_IMAGE}" = "${LOCAL_REG_IMAGE}" ]; then
7170
echo " Already running target image — skipping update"
7271
SKIP_UPDATE=true
7372
fi
@@ -89,7 +88,7 @@ elif docker service inspect ${SERVICE_NAME} > /dev/null 2>&1; then
8988
echo "Service exists — updating image (detached)..."
9089

9190
docker service update \
92-
--image ${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA} \
91+
--image ${LOCAL_REG_IMAGE} \
9392
--update-order stop-first \
9493
--force \
9594
--detach \
@@ -138,16 +137,9 @@ if [ "${SKIP_UPDATE}" != "true" ] && ! docker service inspect ${SERVICE_NAME} >
138137
echo " Stack deployed — waiting for service registration..."
139138
sleep 8
140139

141-
# Pin to exact commit image (detached)
142-
if docker service inspect ${SERVICE_NAME} > /dev/null 2>&1; then
143-
echo " Pinning to commit image..."
144-
docker service update \
145-
--image ${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA} \
146-
--update-order stop-first \
147-
--detach \
148-
${SERVICE_NAME}
149-
sleep 5
150-
fi
140+
# Service deployed from compose which already uses localhost:5000/cubeos-app/api
141+
# No need to pin — compose image reference is correct
142+
sleep 5
151143
fi
152144

153145
# =========================================================================
@@ -166,7 +158,7 @@ while [ ${SECONDS_WAITED} -lt ${HEALTH_TIMEOUT} ]; do
166158
echo " Response: ${RESPONSE}"
167159
echo ""
168160
echo "=== Deployment Summary ==="
169-
echo "Image: ${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA}"
161+
echo "Image: ${LOCAL_REG_IMAGE} (from ${GHCR_IMAGE}:${CI_COMMIT_SHORT_SHA})"
170162
echo "Service: ${SERVICE_NAME}"
171163
echo ""
172164
docker service ls | grep ${STACK_NAME}

0 commit comments

Comments
 (0)