#!/bin/bash set -e # ensure data dir exists (mounted volume expected) DATA_DIR=${DRIFT_BOTTLE_DATA_DIR:-/app/data} mkdir -p "$DATA_DIR" for json_file in bottles.json filter_words.json mottos.json config.json; do if [ -f "/app/mengyadriftbottle-backend/${json_file}" ] && [ ! -f "$DATA_DIR/${json_file}" ]; then cp "/app/mengyadriftbottle-backend/${json_file}" "$DATA_DIR/${json_file}" fi done # start backend on localhost:5002 (not exposed outside container) BACKEND_PORT=${BACKEND_PORT:-5002} echo "Starting backend API on localhost:${BACKEND_PORT}" cd /app/mengyadriftbottle-backend gunicorn -b 127.0.0.1:${BACKEND_PORT} app:app & BACKEND_PID=$! # start nginx to serve frontend + proxy /api to backend echo "Starting nginx on port 6767 (proxying /api to backend)" nginx -g 'daemon off;' & NGINX_PID=$! trap "kill $BACKEND_PID $NGINX_PID" TERM INT wait -n $BACKEND_PID $NGINX_PID