# Docker Deployment This deployment runs the Condo frontend and backend in Docker while connecting to an existing PostgreSQL database. PostgreSQL is not included in `docker-compose.yml`. ## Runtime Shape - `frontend`: nginx serves the static files and proxies `/api/*` to the backend. - `backend`: Node 24 runs the Fastify API on `0.0.0.0:3000`. - Existing PostgreSQL: must expose the `booking_test` database to the backend container. The browser only needs the frontend URL. API requests go to the same origin under `/api`, so the backend port does not need to be published. ## Environment Use the variables shown in `deploy/.env.production.example`. The important settings are: - `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, `DB_NAME=booking_test` - `AUTH_USERNAME`, `AUTH_PASSWORD` - `AUTH_COOKIE_SECURE=false` for HTTP test machines - `AUTH_COOKIE_SECURE=true` when the public frontend URL uses HTTPS - `FRONTEND_PORT`, default `8080` `DB_HOST` must be resolvable from inside the backend container. If PostgreSQL runs directly on the Docker host, use the host address that works for that server environment. ## Build And Run ```bash docker compose build docker compose up -d ``` Open the frontend at: ```text http://:8080 ``` ## Database Migration And Checks The database scripts intentionally read one JSON connection line from standard input. Example shape: ```json {"host":"DB_HOST","port":5432,"user":"DB_USER","password":"DB_PASSWORD","database":"booking_test","ssl":false} ``` Run migration safety checks without database access: ```bash docker compose run --rm backend npm run db:check-migrations ``` Run inventory and migrations against the existing PostgreSQL connection: ```bash printf '%s\n' "$CONDON_DB_CONNECTION_JSON" | docker compose run --rm -T backend npm run db:inventory printf '%s\n' "$CONDON_DB_CONNECTION_JSON" | docker compose run --rm -T backend npm run db:migrate:up ``` For an already imported database that matches the retained production baseline, run: ```bash printf '%s\n' "$CONDON_DB_CONNECTION_JSON" | docker compose run --rm -T backend npm run db:verify ``` `/api/auth/session` is public and works as a basic process check. `/api/health` requires a valid login cookie.