-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
80 lines (76 loc) · 2.25 KB
/
Copy pathdocker-compose.yml
File metadata and controls
80 lines (76 loc) · 2.25 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
# GridPilot 完整产品栈(postgres + redis + api + web)。
# 面向自部署客户:先确保根目录存在 .env,否则下方 env_file 会直接失败。
# cp .env.example .env # 并把 ENCRYPTION_KEY 改为 `openssl rand -base64 32` 的真实输出
# docker compose up --build -d
# 更省事可以直接跑 ./install.sh,会自动处理 .env 并调用上面这条命令。
#
# 只想在本机跑基础设施、自己用 pnpm 起 api/web 做开发?见 docker-compose.dev.yml。
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: gridpilot
POSTGRES_PASSWORD: gridpilot
POSTGRES_DB: gridpilot
ports:
- "${DB_PORT:-25432}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U gridpilot"]
interval: 5s
timeout: 3s
retries: 10
redis:
image: redis:7-alpine
command: redis-server --appendonly yes
ports:
- "${REDIS_PORT:-26379}:6379"
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
api:
build:
context: .
dockerfile: apps/api/Dockerfile
env_file: .env
environment:
NODE_ENV: production
DATABASE_URL: postgresql://gridpilot:gridpilot@postgres:5432/gridpilot
REDIS_URL: redis://redis:6379
API_HOST: 0.0.0.0
API_PORT: 3301
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "${API_PORT:-3301}:3301"
web:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
NEXT_PUBLIC_API_URL: http://localhost:${API_PORT:-3301}
NEXT_PUBLIC_API_PORT: ${API_PORT:-3301}
# rewrites() 的目标在 next build 时烘焙进 routes-manifest.json,必须以 build arg 传入;
# 与下方 environment.API_URL 保持一致(Docker 内网地址,和公网域名/端口无关)
API_URL: http://api:3301
env_file: .env
environment:
NODE_ENV: production
API_URL: http://api:3301
PORT: 3300
HOSTNAME: 0.0.0.0
depends_on:
- api
ports:
- "${WEB_PORT:-3300}:3300"
volumes:
pgdata:
redisdata: