Files
menu/deploy.sh
T
tanshu 01ce0bd609 Create each Site's network with its own subnet
The deploy failed on hngmohali with 'all predefined address pools have been
fully subnetted': every 172.17-172.30/16 is in use, 172.31/16 is the host's own
VPC so Docker will not allocate from it, and all sixteen 192.168.0-240/20 blocks
are taken. Docker therefore refuses a network created without a subnet.

Each Site now names a free network_subnet (10.210.0.0/16, one /24 each), the role
looks the network up first and only creates it when it is absent and with that
subnet, and it fails with an explanation when a Site declares none. Existing
networks are left alone, because Docker cannot change a subnet in place and the
Sites already running have theirs. The test checks every Site declares one, and
the deployment readme says a new Site needs a free subnet.

deploy.sh now deploys every Site by default, with SITE=<name> to narrow it, which
is what the local edit was reaching for.
2026-09-23 00:18:04 +05:30

51 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Builds the image with podman, pushes it to the private registry, then deploys
# the Site with the playbook that lives in ansible/.
#
# ./deploy.sh 2026-09-22 deploy the default Site
# SITE=greatbear ./deploy.sh 2026-09-22 deploy another Site
# SKIP_DEPLOY=1 ./deploy.sh 2026-09-22 build and push only
# SKIP_CHECKS=1 ./deploy.sh 2026-09-22 skip format, typecheck and tests
#
set -euo pipefail
TAG="${1:-}"
if [[ -z "$TAG" ]]; then
echo "usage: $0 <tag> (e.g. $(date +%Y-%m-%d) or a git short sha)" >&2
exit 1
fi
parent_path=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
cd "$parent_path"
if ! command -v podman >/dev/null 2>&1; then
echo "podman is required to build and push the image" >&2
exit 1
fi
if [[ -z "${SKIP_CHECKS:-}" ]]; then
echo "==> lint, format, types and tests"
npm run lint
npm run format:check
npm run typecheck
npm test
fi
echo "==> building and pushing registry.tanshu.com/menu-admin:$TAG"
make build-production TAG="$TAG"
if [[ -n "${SKIP_DEPLOY:-}" ]]; then
echo "SKIP_DEPLOY is set, so the playbook was not run."
exit 0
fi
cd ansible
if [[ -n "${SITE:-}" ]]; then
echo "==> deploying $SITE"
ansible-playbook --inventory=hosts playbook.yml --limit "$SITE" -e "tag=$TAG"
else
echo "==> deploying every Site"
ansible-playbook --inventory=hosts playbook.yml -e "tag=$TAG"
fi