Add HarborForge stack to docker-compose
- Add hf_db_init sidecar that ensures the HarborForge database exists on every `compose up` (idempotent CREATE DATABASE IF NOT EXISTS), so the shared MySQL instance can host both hangmanlab and harborforge schemas without touching existing data. - Wire hf_backend's DATABASE_URL directly from compose env vars and gate it on hf_db_init completing successfully. - Add a mysqladmin-ping healthcheck on mysql so dependents can wait on service_healthy. - Drop dead Vite runtime envs from hf_frontend (build-time only) and make wizard CORS_ORIGINS configurable via HF_FRONTEND_HOST. - Seed .env.example with all variables the stack reads. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
22
mysql-init/10-harborforge.sh
Executable file
22
mysql-init/10-harborforge.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# Idempotent HarborForge DB bootstrap. Runs on every `compose up` via the
|
||||
# hf_db_init sidecar service: waits for mysql to accept connections, then
|
||||
# ensures the HarborForge database exists and the shared app user can use it.
|
||||
set -e
|
||||
|
||||
HF_DB_NAME="${HF_DB_NAME:-harborforge}"
|
||||
MYSQL_HOST="${MYSQL_HOST:-mysql}"
|
||||
|
||||
echo "hf_db_init: waiting for mysql at ${MYSQL_HOST}..."
|
||||
until mysql -h"${MYSQL_HOST}" -uroot -p"${MYSQL_ROOT_PASSWORD}" -e "SELECT 1" >/dev/null 2>&1; do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "hf_db_init: ensuring database '${HF_DB_NAME}' exists and granting access to '${DB_USER}'"
|
||||
mysql -h"${MYSQL_HOST}" -uroot -p"${MYSQL_ROOT_PASSWORD}" <<EOSQL
|
||||
CREATE DATABASE IF NOT EXISTS \`${HF_DB_NAME}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL PRIVILEGES ON \`${HF_DB_NAME}\`.* TO '${DB_USER}'@'%';
|
||||
FLUSH PRIVILEGES;
|
||||
EOSQL
|
||||
|
||||
echo "hf_db_init: done"
|
||||
Reference in New Issue
Block a user