2.3 KiB
2.3 KiB
FastAPI Project - Deployment
You can deploy this project with Docker Compose and put it behind an external reverse proxy (for example OpenResty/Nginx).
This repository uses an external reverse proxy setup and keeps Compose deployment focused on app services.
Preparation
- Have a remote server ready.
- Configure DNS records to point your domain to that server.
- Install Docker Engine on the server.
- Configure OpenResty (or your reverse proxy) to forward traffic:
- frontend domain/path -> frontend container port
- API domain/path -> backend container port
Environment Variables
Create .env.production based on .env.production.example and fill in real values.
Minimum required values:
DOMAINFRONTEND_HOSTENVIRONMENT=productionSECRET_KEYFIRST_SUPERUSERFIRST_SUPERUSER_PASSWORDPOSTGRES_SERVERPOSTGRES_PORTPOSTGRES_DBPOSTGRES_USERPOSTGRES_PASSWORD
Optional values:
SMTP_*andEMAILS_FROM_EMAILSENTRY_DSNMQTT_*pipeline settingsDOCKER_IMAGE_BACKENDDOCKER_IMAGE_FRONTEND
Deploy with Docker Compose
cd /path/to/project
docker compose --env-file .env.production -f compose.prod.yml build
docker compose --env-file .env.production -f compose.prod.yml up -d
To update after code changes:
docker compose --env-file .env.production -f compose.prod.yml down --remove-orphans
docker compose --env-file .env.production -f compose.prod.yml up -d --build
Verify
docker compose --env-file .env.production -f compose.prod.yml ps
docker compose --env-file .env.production -f compose.prod.yml logs backend --tail 100
docker compose --env-file .env.production -f compose.prod.yml logs frontend --tail 100
Backend health check endpoint:
http://<backend-host>:18000/api/v1/utils/health-check/(or your internal mapped port)
CI/CD
The Gitea workflow at .gitea/workflows/deploy.yml deploys using:
docker compose --env-file .env.production -f compose.prod.yml ...
So production deploys are isolated from local development overrides.
URLs
Replace with your real domains configured in OpenResty:
- Frontend:
https://<your-frontend-domain> - Backend API docs:
https://<your-api-domain>/docs - Backend API base URL:
https://<your-api-domain>