chore(docker): add .env.example and Docker Compose setup/build/run scripts
This commit is contained in:
parent
5701e77780
commit
a1f26bc61f
12 changed files with 943 additions and 7 deletions
111
scripts/up.sh
Executable file
111
scripts/up.sh
Executable file
|
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/_compose.sh
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)/_compose.sh"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: ./scripts/up.sh [options]
|
||||
|
||||
Start GCoordinator in the background with pre-flight secret/config checks.
|
||||
|
||||
Options:
|
||||
--lan Start with LAN port bindings (default unless cloudflare)
|
||||
--cloudflare Start with cloudflared ingress sidecar
|
||||
--mode <lan|cloudflare> Explicitly select deployment mode
|
||||
--build Rebuild the image before starting containers
|
||||
--logs Tail service logs after starting containers
|
||||
--dry-run Print compose commands without executing them
|
||||
-h, --help Show this help message
|
||||
EOF
|
||||
}
|
||||
|
||||
REQ_MODE=""
|
||||
DO_BUILD=0
|
||||
FOLLOW_LOGS=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--lan)
|
||||
REQ_MODE="lan"
|
||||
shift
|
||||
;;
|
||||
--cloudflare)
|
||||
REQ_MODE="cloudflare"
|
||||
shift
|
||||
;;
|
||||
--mode)
|
||||
[[ $# -ge 2 ]] || die "--mode requires an argument."
|
||||
REQ_MODE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--mode=*)
|
||||
REQ_MODE="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--build)
|
||||
DO_BUILD=1
|
||||
shift
|
||||
;;
|
||||
--logs)
|
||||
FOLLOW_LOGS=1
|
||||
shift
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "Unknown option: $1 (run with --help)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
MODE="$(resolve_mode "$REQ_MODE")"
|
||||
|
||||
if [[ ! -f "$SECRET_FILE" || -L "$SECRET_FILE" || ! -s "$SECRET_FILE" ]]; then
|
||||
die "Missing or invalid Vault master key at $SECRET_FILE. Run ./scripts/setup.sh first."
|
||||
fi
|
||||
|
||||
[[ ! -L "$DATA_DIR" ]] || die "Refusing symlinked data directory: $DATA_DIR"
|
||||
mkdir -p -m 0700 "$DATA_DIR"
|
||||
|
||||
if [[ "$MODE" == "cloudflare" ]]; then
|
||||
cf_token="$(env_effective CLOUDFLARED_TUNNEL_TOKEN "")"
|
||||
if [[ -z "$cf_token" ]]; then
|
||||
die "CLOUDFLARED_TUNNEL_TOKEN is required when mode=cloudflare. Set it in $ENV_FILE or switch to --lan."
|
||||
fi
|
||||
fi
|
||||
|
||||
UP_ARGS=(up -d --remove-orphans)
|
||||
if [[ "$DO_BUILD" -eq 1 ]]; then
|
||||
UP_ARGS+=(--build)
|
||||
fi
|
||||
|
||||
log_info "Starting GCoordinator stack (mode=$MODE)..."
|
||||
run_compose "$MODE" "${UP_ARGS[@]}"
|
||||
|
||||
if [[ "$DRY_RUN" != "1" ]]; then
|
||||
run_compose "$MODE" ps
|
||||
fi
|
||||
|
||||
if [[ "$MODE" == "lan" ]]; then
|
||||
lan_bind="$(env_effective GCOORD_LAN_BIND 127.0.0.1)"
|
||||
http_port="$(env_effective GCOORD_HTTP_PORT 3000)"
|
||||
proxy_port="$(env_effective GCOORD_PROXY_PORT "")"
|
||||
log_info "UI listening on http://${lan_bind}:${http_port}"
|
||||
if [[ -n "$proxy_port" ]]; then
|
||||
log_info "Isolated proxy origin port configured on ${lan_bind}:${proxy_port}"
|
||||
fi
|
||||
else
|
||||
log_info "Ingress routed privately via cloudflared tunnel (no host ports exposed)."
|
||||
fi
|
||||
|
||||
if [[ "$FOLLOW_LOGS" -eq 1 ]]; then
|
||||
exec "$SCRIPT_DIR/logs.sh" --mode "$MODE"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue