-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
196 lines (184 loc) · 5.66 KB
/
docker-compose.yml
File metadata and controls
196 lines (184 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
x-judge0-env: &judge0-env
RAILS_ENV: production
RAILS_MAX_THREADS: 5
SECRET_KEY_BASE: ${JUDGE0_SECRET_KEY_BASE:-dev_only_change_me_in_prod}
POSTGRES_HOST: judge0-db
POSTGRES_PORT: 5432
POSTGRES_DB: ${JUDGE0_DB_NAME:-judge0}
POSTGRES_USER: ${JUDGE0_DB_USER:-judge0}
POSTGRES_PASSWORD: ${JUDGE0_DB_PASSWORD:-judge0password}
REDIS_HOST: judge0-redis
REDIS_PORT: 6379
AUTHN_TOKEN: ${JUDGE0_AUTHN_TOKEN:-}
AUTHZ_TOKEN: ${JUDGE0_AUTHZ_TOKEN:-}
# On cgroup-v2 hosts, isolate cannot use --cg mode (requires cgroup v1
# memory subsystem). Per-process VIRT limits (isolate -m) apply instead.
#
# Go 1.13 compiler needs ~4 GB of virtual address space for the runtime
# loader + cgo + parallel package compilation. The compile step uses
# MAX_MEMORY_LIMIT directly, so it must be >= 4096000.
# The per-submission memory_limit (set per language in LANGUAGE_CONFIG)
# governs the run step and can be much lower (768 MB for JS/Java/Go).
#
# Java 13 JVM also needs >512 MB VIRT for heap reservation at startup.
MAX_MEMORY_LIMIT: ${JUDGE0_MAX_MEMORY_LIMIT:-4096000}
# Go's linker and JVM spawn many threads during compilation.
# 512 gives Go's runtime enough headroom to avoid intermittent
# pthread_create failures under concurrent submissions.
MAX_MAX_PROCESSES_AND_OR_THREADS: ${JUDGE0_MAX_MAX_PROCESSES:-512}
services:
backend:
profiles: ["prod"]
image: ghcr.io/opensauce/dsa-flash-backend:latest
build:
context: ./backend
ports:
- "8000:8000"
depends_on:
- db
environment:
DATABASE_URL: "postgresql://${POSTGRES_USER:-user}:${POSTGRES_PASSWORD:-password}@db:5432/${POSTGRES_DB:-flashcards}"
SECRET_KEY: "${SECRET_KEY:-}"
JUDGE0_URL: "${JUDGE0_URL:-http://judge0-server:2358}"
JUDGE0_AUTHN_TOKEN: "${JUDGE0_AUTHN_TOKEN:-}"
volumes:
- ./dsa-flash-cards:/data/flashcards
backend-dev:
profiles: ["dev"]
build:
context: ./backend
command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
ports:
- "8000:8000"
depends_on:
- db
environment:
DATABASE_URL: "postgresql://${POSTGRES_USER:-user}:${POSTGRES_PASSWORD:-password}@db:5432/${POSTGRES_DB:-flashcards}"
DEV_MODE: "${DEV_MODE:-}"
SECRET_KEY: "${SECRET_KEY:-}"
RESET_DB: "${RESET_DB:-}"
JUDGE0_URL: "${JUDGE0_URL:-http://judge0-server:2358}"
JUDGE0_AUTHN_TOKEN: "${JUDGE0_AUTHN_TOKEN:-}"
volumes:
- ./backend/app:/usr/src/app/app
- ./backend/alembic:/usr/src/app/alembic
- ./backend/alembic.ini:/usr/src/app/alembic.ini
- ./dsa-flash-cards:/data/flashcards
frontend:
profiles: ["prod"]
image: ghcr.io/opensauce/dsa-flash-frontend:latest
build:
context: ./frontend
environment:
API_BASE: http://backend:8000
ports:
- "3000:3000"
frontend-dev:
profiles: ["dev"]
build:
context: ./frontend
dockerfile: Dockerfile.dev
depends_on:
- backend-dev
volumes:
- ./frontend:/usr/src/app
- /usr/src/app/node_modules
command: yarn dev
environment:
API_BASE: http://backend-dev:8000
ports:
- "3000:3000"
db:
profiles: ["prod", "dev"]
image: postgres:15
environment:
POSTGRES_USER: ${POSTGRES_USER:-user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
POSTGRES_DB: ${POSTGRES_DB:-flashcards}
volumes:
- db_data:/var/lib/postgresql/data
backup:
profiles: ["prod"]
build:
context: ./backup
depends_on:
- db
environment:
POSTGRES_USER: ${POSTGRES_USER:-}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-}
POSTGRES_DB: ${POSTGRES_DB:-}
POSTGRES_HOST: db
S3_BUCKET: ${S3_BACKUP_BUCKET:-}
S3_PREFIX: ${S3_BACKUP_PREFIX:-backups/}
RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-7}
BACKUP_INTERVAL_SECONDS: ${BACKUP_INTERVAL_SECONDS:-86400}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION:-eu-west-2}
restart: unless-stopped
pgadmin:
profiles: ["dev"]
image: dpage/pgadmin4:latest
depends_on:
- db
environment:
PGADMIN_DEFAULT_EMAIL: admin@123.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5050:80"
volumes:
- pgadmin_data:/var/lib/pgadmin
judge0-db:
profiles: ["prod", "dev"]
image: postgres:15
environment:
POSTGRES_USER: ${JUDGE0_DB_USER:-judge0}
POSTGRES_PASSWORD: ${JUDGE0_DB_PASSWORD:-judge0password}
POSTGRES_DB: ${JUDGE0_DB_NAME:-judge0}
volumes:
- judge0_db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${JUDGE0_DB_USER:-judge0}"]
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
judge0-redis:
profiles: ["prod", "dev"]
image: redis:7
restart: unless-stopped
judge0-server:
profiles: ["prod", "dev"]
image: judge0/judge0:1.13.1
ports:
- "127.0.0.1:2358:2358"
depends_on:
judge0-db:
condition: service_healthy
judge0-redis:
condition: service_started
environment:
<<: *judge0-env
restart: unless-stopped
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
judge0-workers:
profiles: ["prod", "dev"]
image: judge0/judge0:1.13.1
command: ["./scripts/workers"]
depends_on:
judge0-db:
condition: service_healthy
judge0-redis:
condition: service_started
environment:
<<: *judge0-env
restart: unless-stopped
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
volumes:
db_data:
pgadmin_data:
judge0_db_data: