-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
76 lines (72 loc) · 2.42 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
76 lines (72 loc) · 2.42 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
services:
# ── PostgreSQL 数据库 ──
postgres:
image: postgres:17-alpine
container_name: interview-pg
environment:
POSTGRES_USER: interview
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?生产环境必须设置 POSTGRES_PASSWORD}
POSTGRES_DB: interview_platform
volumes:
- pgdata:/var/lib/postgresql/data
- ./docker/init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
networks:
- interview-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U interview -d interview_platform"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
# ── Go 后端 ──
backend:
build:
context: ./server
dockerfile: Dockerfile.prod
container_name: interview-backend
environment:
PORT: "8080"
DATABASE_URL: postgres://interview:${POSTGRES_PASSWORD:?生产环境必须设置 POSTGRES_PASSWORD}@postgres:5432/interview_platform?sslmode=disable
# JWT 签名密钥(生产环境务必设置为强随机字符串!)
JWT_SECRET: ${JWT_SECRET:?生产环境必须设置 JWT_SECRET}
# CORS 生产环境设置具体域名
CORS_ORIGIN: ${CORS_ORIGIN:-}
# 管理员邮箱(启动时自动提升为管理员)
ADMIN_EMAIL: ${ADMIN_EMAIL:-}
# SMTP 邮件配置(可选,不配则验证码打印日志)
SMTP_HOST: ${SMTP_HOST:-}
SMTP_PORT: ${SMTP_PORT:-}
SMTP_USER: ${SMTP_USER:-}
SMTP_PASS: ${SMTP_PASS:-}
SMTP_TLS_SERVERNAME: ${SMTP_TLS_SERVERNAME:-}
depends_on:
postgres:
condition: service_healthy
networks:
- interview-net
restart: unless-stopped
# ── Nginx 前端 ──
frontend:
build:
context: ./web
dockerfile: Dockerfile.prod
container_name: interview-frontend
ports:
- "80:80"
- "443:443"
volumes:
# 挂载 Let's Encrypt 证书(由 certbot 管理)
- /etc/letsencrypt/live/ggggs.icu/fullchain.pem:/etc/letsencrypt/live/ggggs.icu/fullchain.pem:ro
- /etc/letsencrypt/live/ggggs.icu/privkey.pem:/etc/letsencrypt/live/ggggs.icu/privkey.pem:ro
- /etc/letsencrypt/options-ssl-nginx.conf:/etc/letsencrypt/options-ssl-nginx.conf:ro
- /etc/letsencrypt/ssl-dhparams.pem:/etc/letsencrypt/ssl-dhparams.pem:ro
depends_on:
- backend
networks:
- interview-net
restart: unless-stopped
volumes:
pgdata:
networks:
interview-net:
driver: bridge