mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-09 19:57:16 +02:00
web-app-chess: refactor runtime & entrypoint
- Move entrypoint to files/ and deploy via copy - Parameterize APP_KEY_FILE, data dir, and entrypoint paths - Require explicit PORT/PG envs (remove fallbacks) - Drop stray header from config/main.yml - Dockerfile: use templated data dir & entrypoint; keep node user - Compose: set custom image, adjust volume mapping - env: derive APP_SCHEME from WEB_PROTOCOL; NODE_ENV from ENVIRONMENT - tasks: add 01_core and simplify main to include it Ref: https://chatgpt.com/share/68b851c5-4dd8-800f-8e9e-22b985597b8f
This commit is contained in:
27
roles/web-app-chess/files/docker-entrypoint.sh
Normal file
27
roles/web-app-chess/files/docker-entrypoint.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_KEY_FILE="${APP_KEY_FILE}"
|
||||
APP_KEY_PUB="${APP_KEY_FILE}.pub"
|
||||
|
||||
# 1) Generate signing key pair if missing
|
||||
if [[ ! -f "${APP_KEY_FILE}" || ! -f "${APP_KEY_PUB}" ]]; then
|
||||
echo "[chess] generating RSA signing key pair at ${APP_KEY_FILE}"
|
||||
/app/tools/gen-signing-key.sh "${APP_KEY_FILE}"
|
||||
fi
|
||||
|
||||
# 2) Wait for PostgreSQL if env is provided
|
||||
if [[ -n "${PGHOST:-}" ]]; then
|
||||
echo "[chess] waiting for PostgreSQL at ${PGHOST}:${PGPORT}..."
|
||||
until pg_isready -h "${PGHOST}" -p "${PGPORT}" -U "${PGUSER}" >/dev/null 2>&1; do
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
# 3) Run migrations (idempotent)
|
||||
echo "[chess] running migrations"
|
||||
yarn migrate up
|
||||
|
||||
# 4) Start app
|
||||
echo "[chess] starting server on port ${PORT}"
|
||||
exec yarn start
|
Reference in New Issue
Block a user