Repository navigation
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
244 lines (234 loc) · 8.45 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
244 lines (234 loc) · 8.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Production Docker Compose
# Usage: create an env file (variable table in docs/operate/deployment.md),
# then: docker compose -f docker-compose.prod.yml --env-file <your-env> up -d --build
#
# Task 37: services reference the versioned ghcr images published by
# release.yml (set FULLA_VERSION to pin; `--build` still works and tags
# the local build with the same name). Schema migrations run through the
# one-shot `migrate` service (profile "migrate"), not at app startup:
# docker compose -f docker-compose.prod.yml --env-file <your-env> \
# --profile migrate run --rm --build migrate
# The app itself keeps FULLA_AUTO_MIGRATE=false and only self-checks.
# NOTE: the migrate service also carries a build: section so a fresh
# deployment can migrate from LOCAL sources with --build even when the
# released ghcr image is unavailable (mirrored/offline hosts) or stale
# relative to unreleased migrations — the WSL 2026-09-12 rehearsal hit
# exactly that: `run --rm migrate` pulled the released image and silently
# applied one migration fewer than the local sources ship.
services:
nginx:
image: nginx:stable-alpine
container_name: oauth2-nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ../../deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ../../deploy/nginx/ssl:/etc/nginx/ssl:ro
depends_on:
fulla-backend:
condition: service_healthy
fulla-frontend:
condition: service_started
fulla-admin:
condition: service_started
networks:
- oauth2-net
fulla-frontend:
image: ghcr.io/voidvec/fulla-frontend:${FULLA_VERSION:-latest}
build:
context: ../..
dockerfile: deploy/docker/Dockerfile
target: frontend-runtime
args:
# Vite build-time vars (inlined into the SPA bundle)
VITE_API_BASE_URL: ${VITE_API_BASE_URL:-}
VITE_CLIENT_ID: ${VITE_CLIENT_ID:-fulla-portal}
VITE_REDIRECT_URI: ${VITE_REDIRECT_URI:-}
container_name: fulla-frontend
restart: always
expose:
- "80"
deploy:
resources:
limits:
cpus: "0.5"
memory: 128M
networks:
- oauth2-net
fulla-admin:
image: ghcr.io/voidvec/fulla-admin:${FULLA_VERSION:-latest}
build:
context: ../../frontends/admin
dockerfile: Dockerfile
container_name: fulla-admin
restart: always
expose:
- "80"
deploy:
resources:
limits:
cpus: "0.5"
memory: 128M
networks:
- oauth2-net
fulla-backend:
image: ghcr.io/voidvec/fulla-backend:${FULLA_VERSION:-latest}
build:
context: ../..
dockerfile: deploy/docker/Dockerfile
target: backend-runtime
container_name: fulla-backend
restart: always
expose:
- "5555"
deploy:
resources:
limits:
cpus: "2"
memory: 512M
depends_on:
fulla-postgres:
condition: service_healthy
fulla-redis:
condition: service_started
environment:
- FULLA_ENV=${FULLA_ENV:-production}
- FULLA_ISSUER=${FULLA_ISSUER}
- FULLA_JWT_KEY_PATH=${FULLA_JWT_KEY_PATH:-/app/keys/signing.pem}
- FULLA_DB_HOST=${FULLA_DB_HOST}
- FULLA_DB_PORT=${FULLA_DB_PORT:-5432}
- FULLA_DB_NAME=${FULLA_DB_NAME}
- FULLA_DB_USER=${FULLA_DB_USER}
- FULLA_DB_PASSWORD=${FULLA_DB_PASSWORD}
- FULLA_REDIS_HOST=${FULLA_REDIS_HOST}
- FULLA_REDIS_PORT=${FULLA_REDIS_PORT:-6379}
- FULLA_REDIS_PASSWORD=${FULLA_REDIS_PASSWORD}
- FULLA_LISTEN_PORT=${FULLA_LISTEN_PORT:-5555}
- FULLA_FRONTEND_URL=${FULLA_FRONTEND_URL}
- FULLA_CORS_ALLOW_ORIGINS=${FULLA_CORS_ALLOW_ORIGINS}
- FULLA_PORTAL_REDIRECT_URI=${FULLA_PORTAL_REDIRECT_URI}
- FULLA_PORTAL_CLIENT_SECRET=${FULLA_PORTAL_CLIENT_SECRET}
- FULLA_ADMIN_CONSOLE_REDIRECT_URI=${FULLA_ADMIN_CONSOLE_REDIRECT_URI}
# WebAuthn / passkeys (#142): fail-closed while RP_ORIGINS is empty
- FULLA_WEBAUTHN_RP_ID=${FULLA_WEBAUTHN_RP_ID:-}
- FULLA_WEBAUTHN_RP_NAME=${FULLA_WEBAUTHN_RP_NAME:-Fulla}
- FULLA_WEBAUTHN_RP_ORIGINS=${FULLA_WEBAUTHN_RP_ORIGINS:-}
- FULLA_GOOGLE_REDIRECT_URI=${FULLA_GOOGLE_REDIRECT_URI:-}
# Migrations run via the `migrate` one-shot service (see header);
# the app only self-checks the schema at startup.
- FULLA_AUTO_MIGRATE=${FULLA_AUTO_MIGRATE:-false}
- DETAILED_VALIDATION_ERRORS=${DETAILED_VALIDATION_ERRORS:-false}
# Optional: set the bootstrap admin's initial password explicitly;
# when empty AdminBootstrapper generates a random one and prints it
# ONCE to the container log (read it via `docker compose logs backend`).
- FULLA_BOOTSTRAP_ADMIN_PASSWORD=${FULLA_BOOTSTRAP_ADMIN_PASSWORD:-}
# External auth (optional)
- FULLA_GITHUB_CLIENT_ID=${FULLA_GITHUB_CLIENT_ID:-}
- FULLA_GITHUB_CLIENT_SECRET=${FULLA_GITHUB_CLIENT_SECRET:-}
- FULLA_GOOGLE_CLIENT_ID=${FULLA_GOOGLE_CLIENT_ID:-}
- FULLA_GOOGLE_CLIENT_SECRET=${FULLA_GOOGLE_CLIENT_SECRET:-}
# WeChat OAuth (optional)
- FULLA_WECHAT_APPID=${FULLA_WECHAT_APPID:-}
- FULLA_WECHAT_SECRET=${FULLA_WECHAT_SECRET:-}
# Email / SMTP (生产环境必须配置,否则验证邮件/密码重置只输出到日志)
- FULLA_SMTP_HOST=${FULLA_SMTP_HOST:-}
- FULLA_SMTP_PORT=${FULLA_SMTP_PORT:-465}
- FULLA_SMTP_USER=${FULLA_SMTP_USER:-}
- FULLA_SMTP_PASSWORD=${FULLA_SMTP_PASSWORD:-}
- FULLA_SMTP_FROM_NAME=${FULLA_SMTP_FROM_NAME:-OAuth2 Platform}
- FULLA_SMTP_SSL=${FULLA_SMTP_SSL:-true}
volumes:
- ../../deploy/keys:/app/keys:ro
# migrations/seed are baked into the image (/app/sql/*) -- no volume
# mounts, so the running container matches the released artifact.
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5555/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
networks:
- oauth2-net
# One-shot schema migration executor (Task 37). Not started by default:
# docker compose -f docker-compose.prod.yml --env-file .env.docker \
# --profile migrate run --rm --build migrate
# (--build migrates from LOCAL sources; without it compose pulls the
# released image, which may predate unreleased migrations.)
# Exit code 0 = schema up to date, 1 = failure (compose surfaces it).
migrate:
image: ghcr.io/voidvec/fulla-backend:${FULLA_VERSION:-latest}
build:
context: ../..
dockerfile: deploy/docker/Dockerfile
target: backend-runtime
profiles: ["migrate"]
command: ["./fulla-server", "--migrate-only"]
restart: "no"
depends_on:
fulla-postgres:
condition: service_healthy
environment:
- FULLA_ENV=${FULLA_ENV:-production}
- FULLA_ISSUER=${FULLA_ISSUER}
- FULLA_JWT_KEY_PATH=${FULLA_JWT_KEY_PATH:-/app/keys/signing.pem}
- FULLA_DB_HOST=${FULLA_DB_HOST}
- FULLA_DB_PORT=${FULLA_DB_PORT:-5432}
- FULLA_DB_NAME=${FULLA_DB_NAME}
- FULLA_DB_USER=${FULLA_DB_USER}
- FULLA_DB_PASSWORD=${FULLA_DB_PASSWORD}
- FULLA_REDIS_HOST=${FULLA_REDIS_HOST}
- FULLA_REDIS_PORT=${FULLA_REDIS_PORT:-6379}
- FULLA_REDIS_PASSWORD=${FULLA_REDIS_PASSWORD}
- FULLA_PORTAL_CLIENT_SECRET=${FULLA_PORTAL_CLIENT_SECRET}
volumes:
- ../../deploy/keys:/app/keys:ro
networks:
- oauth2-net
fulla-postgres:
image: postgres:17-alpine
container_name: fulla-postgres
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- oauth2-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
fulla-redis:
image: redis:7-alpine
container_name: fulla-redis
restart: always
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
- redisdata:/data
networks:
- oauth2-net
fulla-prometheus:
image: prom/prometheus:latest
container_name: fulla-prometheus
restart: always
ports:
# Loopback only: reach it via SSH tunnel / reverse proxy, never the
# public interface.
- "127.0.0.1:9090:9090"
volumes:
- ../observability/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- promdata:/prometheus
networks:
- oauth2-net
networks:
oauth2-net:
driver: bridge
volumes:
pgdata:
redisdata:
promdata: