Files
Aut.ManagementFaculty/docs/deployment.md
T
bestmahdi2 8233dd8a24
Deploy edu.mstaut.ir / deploy (push) Successful in 4m3s
Deploy edu production through same-host Gitea runner
2026-10-06 11:45:44 +03:30

46 lines
1.8 KiB
Markdown

# Production deployment
The production site is https://edu.mstaut.ir. Gitea runs on the same VPS.
Pushes to `master` run `.gitea/workflows/deploy.yml` on the existing
`local-host` runner. The checkout lives at `/opt/prod/Aut.ManagementFaculty`.
`scripts/deploy-production.sh` builds a Next.js standalone Docker image,
backs up the database, applies versioned 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 not automatically reversed.
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 deploy manually on the VPS:
```sh
cd /opt/prod/Aut.ManagementFaculty
git fetch origin master
git checkout --detach origin/master
bash scripts/deploy-production.sh
```
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
```