devops/bdj/deploy.sh

24 lines
926 B
Bash
Executable file

#!/usr/bin/env bash
# Build sites and sync docroots IN PLACE (no dir swap: hostPath mounts bind to
# the directory inode, so replacing the dir would leave pods serving a stale
# path). Routing/TLS are handled by Traefik + cert-manager; no reloads needed.
set -euo pipefail
cd "$(dirname "$0")"
BASE=/home/opc/zai-home-base
echo "==> building site"
python3 build.py
mkdir -p "$BASE/sites/bestdadjokes"
if command -v getenforce >/dev/null 2>&1 && [ "$(getenforce)" = "Enforcing" ]; then
chcon -Rt container_file_t "$BASE/sites/bestdadjokes" 2>/dev/null || true
fi
rsync -a --delete site/ "$BASE/sites/bestdadjokes/"
echo "==> verifying through Traefik (origin)"
sleep 1
for host in bestdadjokes.lol www.bestdadjokes.lol myadhd.dev; do
code=$(curl -sk -o /dev/null -w '%{http_code}' --resolve "$host:443:127.0.0.1" "https://$host/" --max-time 10)
echo " https://$host -> $code (origin)"
done
echo "==> deploy complete"