-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
268 lines (259 loc) · 8.71 KB
/
Copy pathdocker-compose.yml
File metadata and controls
268 lines (259 loc) · 8.71 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# OpenCodeHub — self-hosted quickstart stack (production-safe)
# ============================================================
# 1. cp .env.example .env
# 2. Fill in ALL required secrets in .env
# 3. docker compose up -d
#
# REQUIRED .env values (compose refuses to start without them):
# JWT_SECRET SESSION_SECRET INTERNAL_HOOK_SECRET CRON_SECRET
# RUNNER_SECRET AI_CONFIG_ENCRYPTION_KEY WORKFLOW_SECRET_ENCRYPTION_KEY
# POSTGRES_PASSWORD REDIS_PASSWORD
# → generate each with: openssl rand -hex 32
#
# Storage — two backends only:
# - local (default): filesystem; point STORAGE_PATH/GIT_REPOS_PATH at a
# dedicated disk or NAS mount for best performance
# - s3: any S3-compatible store (AWS S3, MinIO, R2, Garage, ...) via
# STORAGE_ENDPOINT/STORAGE_BUCKET/STORAGE_ACCESS_KEY_ID/STORAGE_SECRET_ACCESS_KEY
#
# Optional profiles:
# docker compose --profile with-runner up -d # CI/CD runner (needs Docker-in-Docker)
# docker compose --profile with-minio up -d # local S3-compatible storage
# ============================================================
services:
# ── Main OpenCodeHub application (web + API + Git HTTP) ────
app:
build:
context: .
dockerfile: Dockerfile
container_name: opencodehub-app
restart: unless-stopped
env_file: .env
environment:
NODE_ENV: production
PORT: 4321
PROCESS_TYPE: app
DATABASE_DRIVER: postgres
DATABASE_URL: postgresql://${POSTGRES_USER:-opencodehub}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@postgres:5432/${POSTGRES_DB:-opencodehub}
REDIS_URL: redis://:${REDIS_PASSWORD:?Set REDIS_PASSWORD in .env}@redis:6379
JWT_SECRET: ${JWT_SECRET:?Set JWT_SECRET in .env}
SESSION_SECRET: ${SESSION_SECRET:?Set SESSION_SECRET in .env}
INTERNAL_HOOK_SECRET: ${INTERNAL_HOOK_SECRET:?Set INTERNAL_HOOK_SECRET in .env}
CRON_SECRET: ${CRON_SECRET:?Set CRON_SECRET in .env}
RUNNER_SECRET: ${RUNNER_SECRET:?Set RUNNER_SECRET in .env}
AI_CONFIG_ENCRYPTION_KEY: ${AI_CONFIG_ENCRYPTION_KEY:?Set AI_CONFIG_ENCRYPTION_KEY in .env}
WORKFLOW_SECRET_ENCRYPTION_KEY: ${WORKFLOW_SECRET_ENCRYPTION_KEY:?Set WORKFLOW_SECRET_ENCRYPTION_KEY in .env}
SITE_URL: ${SITE_URL:-http://localhost:4321}
ALLOWED_ORIGINS: ${SITE_URL:-http://localhost:4321}
GIT_REPOS_PATH: /data/repos
REPOS_PATH: /data/repos
GIT_SSH_PORT: 2222
GIT_SSH_HOST_KEY: /data/ssh/host_key
STORAGE_TYPE: ${STORAGE_TYPE:-local}
STORAGE_PATH: /data/storage
RATE_LIMIT_ENABLED: "true"
RATE_LIMIT_SKIP_DEV: "false"
CSRF_SKIP_DEV: "false"
ports:
- "${WEB_PORT:-4321}:4321" # Web UI + API + Git HTTP
volumes:
- repos-data:/data/repos
- storage-data:/data/storage
- ssh-data:/data/ssh
- cache-data:/data/cache
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- och
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:4321/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
# ── SSH Git server ─────────────────────────────────────────
ssh-git:
build:
context: .
dockerfile: Dockerfile
container_name: opencodehub-ssh
restart: unless-stopped
environment:
NODE_ENV: production
PROCESS_TYPE: ssh
DATABASE_DRIVER: postgres
DATABASE_URL: postgresql://${POSTGRES_USER:-opencodehub}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@postgres:5432/${POSTGRES_DB:-opencodehub}
REDIS_URL: redis://:${REDIS_PASSWORD:?Set REDIS_PASSWORD in .env}@redis:6379
JWT_SECRET: ${JWT_SECRET:?Set JWT_SECRET in .env}
INTERNAL_HOOK_SECRET: ${INTERNAL_HOOK_SECRET:?Set INTERNAL_HOOK_SECRET in .env}
GIT_REPOS_PATH: /data/repos
REPOS_PATH: /data/repos
GIT_SSH_PORT: 2222
GIT_SSH_HOST_KEY: /data/ssh/host_key
ports:
- "${SSH_PORT:-2222}:2222" # SSH Git
volumes:
- repos-data:/data/repos
- storage-data:/data/storage
- ssh-data:/data/ssh
- cache-data:/data/cache
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- och
# ── Background worker (merge queue, webhooks, mirrors, digests) ──
worker:
build:
context: .
dockerfile: Dockerfile
container_name: opencodehub-worker
restart: unless-stopped
environment:
NODE_ENV: production
PROCESS_TYPE: worker
DATABASE_DRIVER: postgres
DATABASE_URL: postgresql://${POSTGRES_USER:-opencodehub}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@postgres:5432/${POSTGRES_DB:-opencodehub}
REDIS_URL: redis://:${REDIS_PASSWORD:?Set REDIS_PASSWORD in .env}@redis:6379
JWT_SECRET: ${JWT_SECRET:?Set JWT_SECRET in .env}
INTERNAL_HOOK_SECRET: ${INTERNAL_HOOK_SECRET:?Set INTERNAL_HOOK_SECRET in .env}
GIT_REPOS_PATH: /data/repos
REPOS_PATH: /data/repos
STORAGE_TYPE: ${STORAGE_TYPE:-local}
STORAGE_PATH: /data/storage
WORKER_HEALTH_PORT: 9090
expose:
- "9090" # Worker healthz/ready
volumes:
- repos-data:/data/repos
- storage-data:/data/storage
- ssh-data:/data/ssh
- cache-data:/data/cache
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- och
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/healthz"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
# ── PostgreSQL ─────────────────────────────────────────────
postgres:
image: docker.io/library/postgres:16-alpine
container_name: opencodehub-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-opencodehub}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
POSTGRES_DB: ${POSTGRES_DB:-opencodehub}
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- och
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-opencodehub} -d ${POSTGRES_DB:-opencodehub}"]
interval: 10s
timeout: 5s
retries: 5
# ── Redis (sessions, caching, distributed locking, queues) ──
redis:
image: docker.io/library/redis:7-alpine
container_name: opencodehub-redis
restart: unless-stopped
command:
- redis-server
- --requirepass
- ${REDIS_PASSWORD:?Set REDIS_PASSWORD in .env}
- --appendonly
- "yes"
- --maxmemory
- 256mb
- --maxmemory-policy
- allkeys-lru
volumes:
- redis-data:/data
networks:
- och
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 5
# ── CI/CD Runner (Docker-in-Docker, optional) ──────────────
runner:
build:
context: .
dockerfile: Dockerfile.runner
container_name: opencodehub-runner
restart: unless-stopped
privileged: true # Required for Docker-in-Docker
environment:
RUNNER_TOKEN: ${RUNNER_TOKEN:-}
SERVER_URL: http://app:4321
DOCKER_HOST: unix:///var/run/docker.sock
RUNNER_WORK_DIR: /work
RUNNER_CACHE_DIR: /cache
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- runner-work:/work
- runner-cache:/cache
depends_on:
- app
networks:
- och
profiles:
- with-runner
# ── MinIO (S3-compatible storage, optional) ────────────────
minio:
image: minio/minio:latest
container_name: opencodehub-minio
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin}
ports:
- "${MINIO_CONSOLE_PORT:-9001}:9001" # Web console (set 0 to disable)
volumes:
- minio-data:/data
networks:
- och
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 30s
timeout: 10s
retries: 3
profiles:
- with-minio
volumes:
repos-data:
driver: local
storage-data:
driver: local
ssh-data:
driver: local
cache-data:
driver: local
postgres-data:
driver: local
redis-data:
driver: local
runner-work:
driver: local
runner-cache:
driver: local
minio-data:
driver: local
networks:
och:
driver: bridge