Configurable trusted proxy (FORWARDED_ALLOW_IPS); named deploy targets
FORWARDED_ALLOW_IPS (default 127.0.0.1) lets the app sit behind a proxy that reaches it over a Docker network instead of loopback; README shows the compose.override.yml for that. deploy.sh <name> picks HOST_<NAME> from the gitignored .deploy.env and leaves a server's compose.override.yml alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
21202c2ca3
commit
080fb451a6
4 changed files with 38 additions and 9 deletions
16
deploy.sh
16
deploy.sh
|
|
@ -1,13 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
# Deploy this checkout (including uncommitted changes) over SSH:
|
||||
# HOST=root@<server> ./deploy.sh
|
||||
# or put HOST=root@<server> in .deploy.env (gitignored; keep server details out of the repo).
|
||||
# ./deploy.sh # HOST from .deploy.env
|
||||
# ./deploy.sh <name> # HOST_<NAME> from .deploy.env (several servers)
|
||||
# .deploy.env is gitignored: keep server details out of the repo.
|
||||
# A compose.override.yml on the server (e.g. different networking) is left alone.
|
||||
# Copies app/ and compose.yml to /opt/tools, rebuilds and restarts the container,
|
||||
# then waits for it to report healthy. Paste data in /opt/tools/data is kept.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
[ -z "${HOST:-}" ] && [ -f .deploy.env ] && . ./.deploy.env
|
||||
[ -n "${HOST:-}" ] || { echo "usage: HOST=root@<server> $0 (or set HOST in .deploy.env)" >&2; exit 1; }
|
||||
[ -f .deploy.env ] && { CLI_HOST=${HOST:-}; . ./.deploy.env; HOST=${CLI_HOST:-${HOST:-}}; }
|
||||
if [ -n "${1:-}" ]; then
|
||||
var="HOST_$(printf %s "$1" | tr '[:lower:]-' '[:upper:]_')"
|
||||
HOST=${!var:-}
|
||||
[ -n "$HOST" ] || { echo "no $var in .deploy.env" >&2; exit 1; }
|
||||
fi
|
||||
[ -n "${HOST:-}" ] || { echo "usage: HOST=root@<server> $0 (or set HOST / HOST_<NAME> in .deploy.env)" >&2; exit 1; }
|
||||
node --test tests/ >/dev/null || { echo "tests failed; not deploying" >&2; exit 1; }
|
||||
tar -czf - --exclude=__pycache__ --exclude=data app compose.yml |
|
||||
ssh "$HOST" 'set -e; mkdir -p /opt/tools && rm -rf /opt/tools/app && tar --no-same-owner -xzf - -C /opt/tools'
|
||||
|
|
@ -18,7 +26,7 @@ mkdir -p data && chown 10001:10001 data && chmod 700 data
|
|||
docker compose up -d --build --remove-orphans
|
||||
for i in $(seq 1 30); do
|
||||
s=$(docker inspect -f '{{.State.Health.Status}}' tools 2>/dev/null || echo none)
|
||||
[ "$s" = healthy ] && { echo "tools is healthy on 127.0.0.1:8090"; docker image prune -f >/dev/null; exit 0; }
|
||||
[ "$s" = healthy ] && { echo "tools is healthy"; docker image prune -f >/dev/null; exit 0; }
|
||||
sleep 2
|
||||
done
|
||||
echo "tools did not become healthy:" >&2; docker logs --tail 50 tools >&2; exit 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue