- docker-compose.yml: restart always, env_file, named volume, start_period - frontend/nginx.conf: gzip compression, cache headers for assets, no-cache for SW - Makefile: add prod-down and prod-logs targets - docs/DEPLOY.md: Dokploy + Cloudflare Tunnel deploy instructions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
121 lines
2.1 KiB
Markdown
121 lines
2.1 KiB
Markdown
# ROA AUTO - Deploy Guide
|
|
|
|
## Prerequisites
|
|
|
|
- Docker & Docker Compose installed
|
|
- Domain configured (e.g., roaauto.romfast.ro)
|
|
- Cloudflare Tunnel configured (or reverse proxy)
|
|
|
|
## Production Deploy on Dokploy
|
|
|
|
### 1. Clone and configure
|
|
|
|
```bash
|
|
git clone <repo-url> roaauto
|
|
cd roaauto
|
|
cp .env.example .env
|
|
```
|
|
|
|
Edit `.env` with production values:
|
|
|
|
```
|
|
SECRET_KEY=<generate-a-strong-secret>
|
|
DATABASE_URL=sqlite+aiosqlite:///./data/roaauto.db
|
|
SMSAPI_TOKEN=<your-smsapi-token>
|
|
CORS_ORIGINS=https://roaauto.romfast.ro
|
|
```
|
|
|
|
Generate a secret key:
|
|
|
|
```bash
|
|
python3 -c "import secrets; print(secrets.token_urlsafe(64))"
|
|
```
|
|
|
|
### 2. Build and start
|
|
|
|
```bash
|
|
make prod-build
|
|
make prod-up
|
|
```
|
|
|
|
Verify:
|
|
|
|
```bash
|
|
curl http://localhost/api/health
|
|
# {"status":"ok"}
|
|
```
|
|
|
|
### 3. Run initial migration
|
|
|
|
```bash
|
|
docker compose exec backend alembic upgrade head
|
|
```
|
|
|
|
### 4. Seed catalog data (first deploy only)
|
|
|
|
```bash
|
|
docker compose exec backend python -m app.db.seed
|
|
```
|
|
|
|
## Cloudflare Tunnel Setup
|
|
|
|
1. Install `cloudflared` on the Proxmox host
|
|
2. Create a tunnel: `cloudflared tunnel create roaauto`
|
|
3. Configure the tunnel to route `roaauto.romfast.ro` to `http://localhost:80`
|
|
4. Run as a service: `cloudflared service install`
|
|
|
|
The tunnel provides HTTPS termination - nginx listens on port 80 internally.
|
|
|
|
## Dokploy Configuration
|
|
|
|
If using Dokploy instead of manual Docker:
|
|
|
|
1. Create a new project in Dokploy
|
|
2. Set source to your Git repository
|
|
3. Set compose file to `docker-compose.yml`
|
|
4. Add environment variables from `.env.example`
|
|
5. Set the domain to `roaauto.romfast.ro`
|
|
6. Deploy
|
|
|
|
## Maintenance
|
|
|
|
### Logs
|
|
|
|
```bash
|
|
make prod-logs
|
|
```
|
|
|
|
### Database backup
|
|
|
|
```bash
|
|
make backup
|
|
```
|
|
|
|
### Update deployment
|
|
|
|
```bash
|
|
git pull
|
|
make prod-build
|
|
make prod-up
|
|
```
|
|
|
|
### Rollback
|
|
|
|
```bash
|
|
git checkout <previous-commit>
|
|
make prod-build
|
|
make prod-up
|
|
```
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Internet → Cloudflare Tunnel → nginx (:80)
|
|
├── / → SPA (static files)
|
|
└── /api → backend (:8000)
|
|
|
|
backend: Python 3.12 + FastAPI + SQLite (file-based)
|
|
frontend: Vue 3 SPA served by nginx
|
|
data: ./backend/data/ (bind mount, persisted)
|
|
```
|