Files
Aut.ManagementFaculty/docs/deployment.md
T
smhk1376andCursor 8eee3242bf
Deploy edu.mstaut.ir / deploy (push) Failing after 12s
Trigger deploy workflow with a no-op docs probe.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-16 16:32:11 +03:30

51 lines
2.1 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 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 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
```
<!-- workflow probe: no runtime impact -->