mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-08 03:07:14 +02:00
Build: use Yarn 4 via Corepack; immutable install with inline builds. Runtime: enable Corepack as user 'node', use project-local cache (/app/.yarn/cache), add curl; fix ownership. Entrypoint: generate keys in correct dir; run 'yarn install --immutable --inline-builds' before migrations; wait for Postgres. Config: enable matomo/css/desktop; notify 'docker compose build' on entrypoint changes. Docs: rename README title to 'Chess'. Ref: ChatGPT conversation (2025-09-03) — https://chatgpt.com/share/68b88126-7a6c-800f-acae-ae61ed577f46
35 lines
1.0 KiB
Bash
35 lines
1.0 KiB
Bash
#!/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}"
|
|
key_dir="$(dirname "${APP_KEY_FILE}")"
|
|
key_base="$(basename "${APP_KEY_FILE}")"
|
|
( cd "${key_dir}" && bash /app/tools/gen-signing-key.sh "${key_base}" )
|
|
fi
|
|
|
|
# 1.5) Ensure Yarn is ready and deps are installed (PnP, immutable)
|
|
echo "[chess] preparing yarn & installing deps (immutable)"
|
|
corepack enable || true
|
|
yarn install --immutable --inline-builds
|
|
|
|
# 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
|