Files
menu/deploy.sh
T
tanshu 1f06e32854 Add the playbook that deploys one Site
The playbook pulls the tag from the registry, creates the data root owned by the
app user, runs the container with its config baked into the image, waits for
health, then verifies the data directory as the app user so a permissions
mistake surfaces at deploy time. Caddy is pointed at the app with a stable
marker, so a temporary hostname can be checked beside the live site and the
cutover is one invocation with the retire flags set.
2026-09-22 21:25:52 +05:30

46 lines
1016 B
Bash
Executable File

#!/usr/bin/env bash
#
# Builds the image, runs the tests and pushes it to the private registry.
#
# ./deploy.sh 2026-09-22
#
# Then deploy with the printed ansible-playbook command, or with the cutover
# flags from deploy/ansible/readme.md.
set -euo pipefail
TAG="${1:-}"
if [[ -z "$TAG" ]]; then
echo "usage: deploy.sh <tag> (e.g. $(date +%Y-%m-%d) or a git short sha)" >&2
exit 1
fi
IMAGE="registry.tanshu.com/menu-admin:${TAG}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
if [[ -z "${SKIP_TESTS:-}" ]]; then
echo "==> tests"
npm test
npm run typecheck
fi
echo "==> building ${IMAGE}"
docker build -t "$IMAGE" .
echo "==> pushing ${IMAGE}"
docker push "$IMAGE"
cat <<EOF
pushed ${IMAGE}
parallel run:
ansible-playbook -l monoco -e site=hopsngrains -e tag=${TAG} playbook.yml
cutover:
ansible-playbook -l monoco -e site=hopsngrains -e tag=${TAG} \\
-e vhost=menu.hopsngrains.com -e retire_nginx_snippet=true \\
-e retire_nginx_container=true playbook.yml
EOF