# Production deployment The production site is https://edu.mstaut.ir. Gitea runs on the same VPS. **Normal releases are fully automatic:** a push to `master` (or *workflow_dispatch* in Gitea) runs `.gitea/workflows/deploy.yml` on the `local-host` runner — checkout, `npm ci` + `next build` on the runner host (with npm cache), then `scripts/deploy-production.sh` with a prebuilt tree (`Dockerfile.prebuilt`: no second `npm ci` / compile inside Docker). Backup, migrations, smoke checks, and container swap need no manual steps. `scripts/deploy-production.sh` builds the Docker image from `PREBUILT_DIR` in CI (or from the full root `Dockerfile` only for emergency/local use without CI), backs up the database to `/opt/backups/edu`, applies versioned migrations (`node db/migrate.mjs` — idempotent via `schema_migrations`), checks a candidate container, and replaces `aut-management-faculty`. It retains the previous container and automatically restores it if the new container fails its initial HTTPS check. Database migrations are forward-only (not automatically reversed); the dump before migrate is the recovery path. Uploaded admin images persist in the Docker volume `edu-uploads`. Production settings are stored in `/etc/edu-production.env`, owned by root with mode `600`. It contains `DATABASE_URL`, `NEXT_PUBLIC_SITE_URL`, `NODE_ENV`, `PORT`, and `HOSTNAME`. Database credentials must never be committed. The database host is `insaight-postgres` on `shared_web_network`. Database dumps are in `/opt/backups/edu`. Nginx proxies HTTPS to `127.0.0.1:3000`; the application port is bound only to loopback. Nginx configuration is `/etc/nginx/sites-available/edu.mstaut.ir.conf`. Certbot manages the certificate under `/etc/letsencrypt/live/edu.mstaut.ir`, with automatic renewal via `certbot.timer`. When enabling ArvanCloud, use HTTPS for the connection to the origin on port 443, with `edu.mstaut.ir` as the origin host name. Leave the ACME challenge path accessible for certificate renewal and bypass caching for admin pages, API requests, and authenticated traffic. To inspect a deployment: ```sh docker logs --tail 100 aut-management-faculty curl --resolve edu.mstaut.ir:443:127.0.0.1 https://edu.mstaut.ir/ certbot renew --cert-name edu.mstaut.ir --dry-run ```