# Deployment Guide — Staging ## Quick start (on the staging server) 1. SSH to the staging server and clone the repo (or copy the project folder). 2. Go into the `deployment/` directory. 3. Copy the staging environment file: ```bash cp .env.staging .env # edit .env to fill in any API keys you need ``` 4. Run the deploy script: ```bash ./deploy.sh ``` 5. The app is available on: - **Nginx (HTTP):** http://localhost - **Next.js (direct):** http://localhost:3000 ## What the script does - Builds the Docker image from the project root using the `Dockerfile`. - Starts two containers: - `andris-app` — the Next.js app (port 3000, exposed only on localhost). - `andris-nginx` — reverse proxy on ports 80 / 443. - SQLite database is stored in a Docker volume (`app-db`) so data survives restarts. - On first boot the entrypoint auto-initialises the database (`prisma db push`) and seeds the admin user. ## Updating the app ```bash cd deployment ./deploy.sh ``` This rebuilds the image with your latest source code and recreates the containers. ## Files overview | File | Purpose | |------|---------| | `Dockerfile` | Multi-stage build (Next.js standalone) | | `docker-compose.yml` | Production services: app + nginx | | `docker-compose.override.yml` | Optional override for local dev | | `nginx/nginx.conf` | Nginx main config | | `nginx/default.conf` | Nginx site / reverse proxy config | | `.env.staging` | Staging environment template | | `deploy.sh` | One-command build & deploy script | | `entrypoint.sh` | Container entrypoint (DB init + app start) | ## Health check A `GET /api/health` endpoint returns `{"status":"ok"}`. The Docker `healthcheck` uses it every 30 s. ## Notes - The `.dockerignore` at the project root prevents the dev database, `node_modules`, and `.env` from being baked into the image. - For a real domain, update `server_name` in `nginx/default.conf` and mount your TLS certificates.