diff --git a/client/index.html b/client/index.html index f52e07c..8af551f 100644 --- a/client/index.html +++ b/client/index.html @@ -4,6 +4,7 @@ Golf Card Game + diff --git a/scripts/deploy-prod.sh b/scripts/deploy-prod.sh new file mode 100755 index 0000000..f076989 --- /dev/null +++ b/scripts/deploy-prod.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -e + +TAG="${1:?Usage: deploy-prod.sh (e.g. v3.3.2)}" +DROPLET="root@165.245.152.51" +IMAGE="git.adlee.work/alee/golfgame" + +echo "Deploying $TAG to production ($DROPLET)..." + +ssh $DROPLET bash -s "$TAG" "$IMAGE" <<'REMOTE' +set -e +TAG="$1" +IMAGE="$2" + +cd /opt/golfgame + +# Pull the image that passed staging +docker pull "$IMAGE:$TAG" +docker tag "$IMAGE:$TAG" golfgame-app:latest + +# Update code for compose/env changes +git fetch origin +git checkout "$TAG" + +# Restart app +docker compose -f docker-compose.prod.yml up -d app + +# Wait for healthy +echo "Waiting for health check..." +for i in $(seq 1 30); do + if docker compose -f docker-compose.prod.yml ps app | grep -q "healthy"; then + echo "Production deploy successful — $TAG" + exit 0 + fi + sleep 2 +done +echo "CRITICAL: app not healthy after 60s" +docker compose -f docker-compose.prod.yml logs --tail=30 app +exit 1 +REMOTE + +echo "Done."