Skip to content

Commit 71b2f55

Browse files
committed
fix: add S3 storage env vars to rest-api, hocuspocus, and worker services
1 parent 0af6bce commit 71b2f55

File tree

6 files changed

+625
-16
lines changed

6 files changed

+625
-16
lines changed

DEPLOYMENT.md

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# Deployment Guide - Traefik Architecture
2+
3+
## Architecture
4+
5+
```
6+
Internet → Traefik (SSL/LB, ports 80/443) → Docker Services
7+
```
8+
9+
**Services:**
10+
11+
- `webapp` (Next.js) - docs.plus
12+
- `rest-api` - prodback.docs.plus/api/\*
13+
- `hocuspocus-server` - prodback.docs.plus/hocuspocus/\*
14+
- `hocuspocus-worker` - background jobs
15+
- `redis` - cache & pub/sub
16+
- `traefik` - reverse proxy + auto SSL
17+
18+
## Quick Start
19+
20+
### Prerequisites
21+
22+
```bash
23+
# Server requirements
24+
- Docker 24+
25+
- Docker Compose 2.20+
26+
- Open ports: 80, 443
27+
```
28+
29+
### 1. First-time Server Setup
30+
31+
```bash
32+
# Create directories
33+
sudo mkdir -p /opt/projects/prod.docs.plus
34+
cd /opt/projects/prod.docs.plus
35+
36+
# Create .env file
37+
cat > .env << 'EOF'
38+
# Database (DigitalOcean managed)
39+
DATABASE_URL=postgresql://user:pass@host:25060/db?sslmode=require
40+
41+
# Supabase
42+
SUPABASE_URL=https://xxx.supabase.co
43+
SUPABASE_ANON_KEY=eyJ...
44+
SUPABASE_SERVICE_ROLE_KEY=eyJ...
45+
46+
# Next.js public vars
47+
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
48+
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
49+
NEXT_PUBLIC_PROVIDER_URL=wss://prodback.docs.plus/hocuspocus
50+
NEXT_PUBLIC_RESTAPI_URL=https://prodback.docs.plus/api
51+
52+
# Auth
53+
JWT_SECRET=your-jwt-secret-min-32-chars
54+
55+
# Traefik
56+
57+
TRAEFIK_DASHBOARD_AUTH=admin:$apr1$xyz$hash # htpasswd -nb admin password
58+
59+
# Misc
60+
ALLOWED_ORIGINS=https://docs.plus
61+
EOF
62+
63+
# Setup GitHub Actions runner
64+
mkdir -p app/docs.plus
65+
cd app/docs.plus
66+
# Configure self-hosted runner: Settings → Actions → Runners → New
67+
```
68+
69+
### 2. DNS Setup
70+
71+
Point these domains to your server IP:
72+
73+
- `docs.plus` → Server IP
74+
- `prodback.docs.plus` → Server IP
75+
- `traefik.docs.plus` → Server IP (optional, for dashboard)
76+
- `status.docs.plus` → Server IP (optional, for uptime kuma)
77+
78+
### 3. Deploy
79+
80+
Push to main with commit message containing `build front` or `build back`:
81+
82+
```bash
83+
git commit --allow-empty -m "build front back"
84+
git push
85+
```
86+
87+
## Manual Deployment
88+
89+
```bash
90+
# From server
91+
cd /opt/projects/prod.docs.plus/app/docs.plus/docs.plus
92+
93+
# Deploy
94+
docker-compose -f docker-compose.prod.yml \
95+
--env-file /opt/projects/prod.docs.plus/.env \
96+
up -d --build \
97+
--scale webapp=2 \
98+
--scale rest-api=2 \
99+
--scale hocuspocus-server=2
100+
101+
# View logs
102+
docker-compose -f docker-compose.prod.yml logs -f
103+
104+
# Check status
105+
docker ps
106+
```
107+
108+
## Scaling
109+
110+
```bash
111+
# Scale services
112+
docker-compose -f docker-compose.prod.yml up -d \
113+
--scale webapp=4 \
114+
--scale rest-api=4 \
115+
--scale hocuspocus-server=4
116+
117+
# Traefik auto-balances traffic
118+
```
119+
120+
## Monitoring
121+
122+
### View logs
123+
124+
```bash
125+
# All services
126+
docker-compose -f docker-compose.prod.yml logs -f
127+
128+
# Specific service
129+
docker logs -f <container-name>
130+
```
131+
132+
### Health endpoints
133+
134+
```bash
135+
curl https://docs.plus/api/health
136+
curl https://prodback.docs.plus/api/health
137+
curl https://prodback.docs.plus/hocuspocus/health
138+
```
139+
140+
### Traefik Dashboard
141+
142+
Access at `https://traefik.docs.plus` (requires auth)
143+
144+
## Rollback
145+
146+
```bash
147+
# Find previous image
148+
docker images docsy-webapp --format "{{.Tag}}"
149+
150+
# Rollback to previous tag
151+
export DEPLOY_TAG=<previous-tag>
152+
docker-compose -f docker-compose.prod.yml \
153+
--env-file /opt/projects/prod.docs.plus/.env \
154+
up -d
155+
```
156+
157+
## Troubleshooting
158+
159+
### SSL not working
160+
161+
```bash
162+
# Check Traefik logs
163+
docker logs traefik
164+
165+
# SSL certs stored in volume
166+
docker volume inspect docsplus_traefik-certs
167+
168+
# Force cert renewal
169+
docker exec traefik traefik healthcheck
170+
```
171+
172+
### Service not accessible
173+
174+
```bash
175+
# Check if Traefik sees the service
176+
docker exec traefik traefik healthcheck
177+
178+
# Check container labels
179+
docker inspect <container> | jq '.[0].Config.Labels'
180+
181+
# Verify network
182+
docker network inspect docsplus-network
183+
```
184+
185+
### Container keeps restarting
186+
187+
```bash
188+
# Check logs
189+
docker logs <container> --tail 100
190+
191+
# Common issues:
192+
# - DATABASE_URL wrong → check .env
193+
# - Redis not ready → check redis container
194+
# - Build args missing → rebuild with --no-cache
195+
```
196+
197+
## Environment Variables
198+
199+
| Variable | Description |
200+
| --------------------------- | --------------------------------------- |
201+
| `DATABASE_URL` | PostgreSQL connection string (with SSL) |
202+
| `SUPABASE_URL` | Supabase project URL |
203+
| `SUPABASE_ANON_KEY` | Supabase anon key |
204+
| `SUPABASE_SERVICE_ROLE_KEY` | Supabase service role key |
205+
| `JWT_SECRET` | JWT signing secret (32+ chars) |
206+
| `ACME_EMAIL` | Email for Let's Encrypt certs |
207+
| `TRAEFIK_DASHBOARD_AUTH` | htpasswd auth for Traefik dashboard |
208+
| `ALLOWED_ORIGINS` | CORS allowed origins |
209+
| `NEXT_PUBLIC_*` | Public vars baked into frontend |
210+
211+
## Useful Commands
212+
213+
```bash
214+
# Restart all
215+
docker-compose -f docker-compose.prod.yml restart
216+
217+
# Rebuild specific service
218+
docker-compose -f docker-compose.prod.yml up -d --build webapp
219+
220+
# Force recreate
221+
docker-compose -f docker-compose.prod.yml up -d --force-recreate
222+
223+
# Clean everything (WARNING: deletes data)
224+
docker-compose -f docker-compose.prod.yml down -v
225+
docker system prune -af
226+
```

0 commit comments

Comments
 (0)