-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
109 lines (104 loc) · 3.6 KB
/
Copy pathdocker-compose.yml
File metadata and controls
109 lines (104 loc) · 3.6 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
# ProtoForge Docker Compose Configuration(生产环境 / 开发者)
# 新手请用 docker-compose.simple.yml,无需编译直接用预构建镜像
#
# Quick start: docker compose up -d
# Simple mode: docker compose -f docker-compose.simple.yml up -d
# With custom settings: Set PROTOFORGE_DB_PASSWORD, PROTOFORGE_JWT_SECRET, PROTOFORGE_ADMIN_PASSWORD in .env
# Run tests: docker compose --profile test up -d
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: protoforge
POSTGRES_USER: protoforge
POSTGRES_PASSWORD: ${PROTOFORGE_DB_PASSWORD:?必须在.env中设置PROTOFORGE_DB_PASSWORD}
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U protoforge"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
init-test-db:
profiles: [test]
image: postgres:16-alpine
depends_on:
postgres:
condition: service_healthy
entrypoint: >
sh -c "psql -U protoforge -h postgres -d protoforge -c 'SELECT 1 FROM pg_database WHERE datname = $$protoforge_test$$' | grep -q 1 || psql -U protoforge -h postgres -d postgres -c 'CREATE DATABASE protoforge_test'"
protoforge:
build: .
command: ["sh", "-c", "alembic upgrade head && python -m protoforge.cli run"]
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 256M
cpus: '0.25'
ports:
- "8000:8000"
- "5020:5020"
- "4840:4840"
- "1883:1883"
- "5060:5060"
- "5060:5060/udp"
- "47808:47808/udp"
- "102:102"
- "8080:8080"
- "5000:5000"
- "9600:9600"
- "44818:44818"
- "51340:51340"
- "8193:8193"
- "7878:7878"
- "1701:1701"
- "34964:34964"
- "34980:34980"
# GB28181 RTP 媒体流端口范围 (如需从外部播放视频流则映射)
- "6000-6999:6000-6999/udp"
environment:
# 在 .env 中设置完整的数据库连接 URL,避免在 compose 文件中暴露凭据模式
# 示例: PROTOFORGE_DB_PATH=postgresql://protoforge:你的密码@postgres:5432/protoforge
PROTOFORGE_DB_PATH: ${PROTOFORGE_DB_PATH:?请在.env中设置PROTOFORGE_DB_PATH}
PROTOFORGE_JWT_SECRET: ${PROTOFORGE_JWT_SECRET:?必须在.env中设置PROTOFORGE_JWT_SECRET}
PROTOFORGE_ADMIN_PASSWORD: ${PROTOFORGE_ADMIN_PASSWORD:?必须在.env中设置PROTOFORGE_ADMIN_PASSWORD}
PROTOFORGE_LOG_LEVEL: info
PROTOFORGE_CORS_ORIGINS: ${PROTOFORGE_CORS_ORIGINS:-http://localhost:8000,http://127.0.0.1:8000} # FIXED: 默认仅允许本地访问,生产环境务必设置具体域名
PROTOFORGE_GRPC_PORT: "0"
depends_on:
postgres:
condition: service_healthy
volumes:
- protoforge-data:/app/data
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
# FIXED: 添加日志轮转配置,防止日志文件无限增长
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
protoforge-test:
profiles: [test]
build: .
command: ["sh", "-c", "pip install -e '.[dev,all]' && python -m pytest tests/ -v --tb=short"]
environment:
PROTOFORGE_DB_PATH: ${PROTOFORGE_DB_PATH_TEST:?请在.env中设置PROTOFORGE_DB_PATH_TEST}
PROTOFORGE_NO_AUTH: "1"
depends_on:
init-test-db:
condition: service_completed_successfully
volumes:
- ./:/app
volumes:
postgres-data:
protoforge-data: