Repository navigation
Expand file tree
/
Copy pathdocker-compose-web.yml
More file actions
172 lines (165 loc) · 5.66 KB
/
Copy pathdocker-compose-web.yml
File metadata and controls
172 lines (165 loc) · 5.66 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
# DeepVuln Web Service Docker Compose 配置
#
# 启动 Web 服务所需的全部组件:
# - Web API (FastAPI + Uvicorn)
# - Celery Worker (后台扫描任务)
# - Redis (Celery broker)
# - PostgreSQL (数据库)
#
# 使用方法:
# 1. 配置环境变量(参考 .env.example)
# 2. docker-compose -f docker-compose-web.yml up -d
# 3. 访问 http://localhost:8000/health
version: "3.8"
services:
# PostgreSQL 数据库
postgres:
image: postgres:16-alpine
container_name: deepvuln-postgres
environment:
POSTGRES_USER: deepvuln
POSTGRES_PASSWORD: deepvuln_password
POSTGRES_DB: deepvuln
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U deepvuln"]
interval: 5s
timeout: 5s
retries: 5
networks:
- deepvuln-network
# Redis - Celery broker
redis:
image: redis:7-alpine
container_name: deepvuln-redis
command: redis-server --appendonly yes --appendfilename "appendonly.aof"
ports:
- "6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
networks:
- deepvuln-network
# Celery Worker - 处理后台扫描任务
celery-worker:
build:
context: .
dockerfile: Dockerfile
args:
APT_MIRROR: ${APT_MIRROR:-https://mirrors.tuna.tsinghua.edu.cn/debian}
image: deepvuln:latest
container_name: deepvuln-celery-worker
command: ["python", "-m", "celery", "-A", "src.web.tasks.scan_tasks", "worker", "-l", "info", "-Q", "scan", "--concurrency=2"]
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPENAI_BASE_URL=${OPENAI_BASE_URL:-https://api.lkeap.cloud.tencent.com/coding/v3}
- PYTHONUNBUFFERED=1
# 数据库连接
# 代码只读 DEEPVULN_DB_* 前缀(audit B3:DATABASE_URL 从未生效)
- DEEPVULN_DB_URL=postgresql+asyncpg://deepvuln:deepvuln_password@postgres:5432/deepvuln
# Redis 连接(broker + WS pub/sub)
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- CELERY_REDIS_URL=redis://redis:6379/0
# 安全:JWT secret 必须显式提供(web service 在默认 secret 下拒绝启动)
# 用法:openssl rand -hex 32,然后 export DEEPVULN_SECURITY_JWT_SECRET=...
- DEEPVULN_SECURITY_JWT_SECRET=${DEEPVULN_SECURITY_JWT_SECRET:?请在 .env 中设置 DEEPVULN_SECURITY_JWT_SECRET(openssl rand -hex 32 生成)}
- DEEPVULN_SECURITY_DEV_MODE=${DEEPVULN_SECURITY_DEV_MODE:-false}
# ZIP 上传扫描:worker 读取 web-api 解压后的源码(共享 uploads 卷)
- DEEPVULN_WEB_UPLOAD_DIR=/app/uploads
volumes:
- ./src:/app/src:ro
- deepvuln-cache:/home/deepvuln/.cache
- codeql-databases:/tmp/codeql_cache
- codeql-packs:/home/deepvuln/.codeql
- uploads-data:/app/uploads
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- deepvuln-network
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
# Web API 服务器
web-api:
build:
context: .
dockerfile: Dockerfile
args:
APT_MIRROR: ${APT_MIRROR:-https://mirrors.tuna.tsinghua.edu.cn/debian}
image: deepvuln:latest
container_name: deepvuln-web-api
command: ["python", "-m", "uvicorn", "src.web.main:app", "--host", "0.0.0.0", "--port", "8000"]
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPENAI_BASE_URL=${OPENAI_BASE_URL:-https://api.lkeap.cloud.tencent.com/coding/v3}
- PYTHONUNBUFFERED=1
# 数据库连接
# 代码只读 DEEPVULN_DB_* 前缀(audit B3:DATABASE_URL 从未生效)
- DEEPVULN_DB_URL=postgresql+asyncpg://deepvuln:deepvuln_password@postgres:5432/deepvuln
# Redis 连接(broker + WS pub/sub)
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- CELERY_REDIS_URL=redis://redis:6379/0
# 安全:JWT secret 必须显式提供(web service 在默认 secret 下拒绝启动)
# 用法:openssl rand -hex 32,然后 export DEEPVULN_SECURITY_JWT_SECRET=...
- DEEPVULN_SECURITY_JWT_SECRET=${DEEPVULN_SECURITY_JWT_SECRET:?请在 .env 中设置 DEEPVULN_SECURITY_JWT_SECRET(openssl rand -hex 32 生成)}
- DEEPVULN_SECURITY_DEV_MODE=${DEEPVULN_SECURITY_DEV_MODE:-false}
# ZIP 上传扫描:web-api 与 celery-worker 共享 uploads 卷(Dockerfile WORKDIR=/app)
- DEEPVULN_WEB_UPLOAD_DIR=/app/uploads
ports:
- "8000:8000"
volumes:
- ./src:/app/src:ro
- deepvuln-cache:/home/deepvuln/.cache
- codeql-databases:/tmp/codeql_cache
- codeql-packs:/home/deepvuln/.codeql
- uploads-data:/app/uploads
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
celery-worker:
condition: service_started
networks:
- deepvuln-network
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
volumes:
postgres-data:
name: deepvuln-postgres-data
redis-data:
name: deepvuln-redis-data
deepvuln-cache:
name: deepvuln-cache
codeql-databases:
name: codeql-databases
codeql-packs:
name: codeql-packs
uploads-data:
name: deepvuln-uploads-data
networks:
deepvuln-network:
name: deepvuln-network