Website deploy: run the image tagged current, so plain compose commands work on the server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
02fc61b88c
commit
c8e33e4ecd
2 changed files with 8 additions and 5 deletions
|
|
@ -39,7 +39,8 @@ rollback)
|
|||
remote "${dir}" <<'SH'
|
||||
set -e; cd "$1"
|
||||
prev="$(cat .previous)"; cur="$(cat .deployed)"
|
||||
SITE_TAG="${prev}" docker compose up -d
|
||||
docker tag "chesspenguin-site:${prev}" chesspenguin-site:current
|
||||
docker compose up -d
|
||||
echo "${prev}" > .deployed; echo "${cur}" > .previous
|
||||
SH
|
||||
wait_healthy
|
||||
|
|
@ -61,11 +62,12 @@ deploy)
|
|||
set -e; cd "$1"
|
||||
[ -f .env ] || { echo ".env is missing in $1 (see .env.example)"; exit 1; }
|
||||
cur="$(cat .deployed 2>/dev/null || true)"
|
||||
SITE_TAG="$2" docker compose up -d
|
||||
docker tag "chesspenguin-site:$2" chesspenguin-site:current
|
||||
docker compose up -d
|
||||
if [ -n "${cur}" ] && [ "${cur}" != "$2" ]; then echo "${cur}" > .previous; fi
|
||||
echo "$2" > .deployed
|
||||
# Keep the three newest images for rollbacks.
|
||||
docker image ls chesspenguin-site --format '{{.Tag}}' | tail -n +4 | grep -vx -e "$2" -e "${cur}" \
|
||||
docker image ls chesspenguin-site --format '{{.Tag}}' | tail -n +4 | grep -vx -e current -e "$2" -e "${cur}" \
|
||||
| xargs -r -I{} docker image rm -f "chesspenguin-site:{}" >/dev/null || true
|
||||
SH
|
||||
wait_healthy
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
# Production: docker-prodVM:~/services/ChessPenguinSite (copied there by deploy.sh).
|
||||
# nginx runs on another host and proxies to this VM on port 8140.
|
||||
# nginx runs on another host and proxies to this VM on port 8140. deploy.sh tags the
|
||||
# running version as chesspenguin-site:current, so a plain `docker compose up -d` works.
|
||||
services:
|
||||
site:
|
||||
image: chesspenguin-site:${SITE_TAG:-latest}
|
||||
image: chesspenguin-site:current
|
||||
container_name: chesspenguin-site
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue