Repository navigation
Expand file tree
/
Copy pathcompose.yaml
More file actions
117 lines (114 loc) · 3.75 KB
/
Copy pathcompose.yaml
File metadata and controls
117 lines (114 loc) · 3.75 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
name: uni-stem-course-simulators
x-api: &api
build:
context: .
dockerfile: backend/Dockerfile
environment: &api-env
DATABASE_PASSWORD_FILE: /run/courselab/db-runtime-password
DB_HOST: db
DB_NAME: courselab
DB_USER: courselab_app
CONTENT_ROOT: /content
PRIVATE_ASSESSMENTS_ROOT: /run/private-assessments
COOKIE_SECURE: "false"
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost:8080,http://127.0.0.1:8080}
RATE_LIMIT: ${COURSELAB_RATE_LIMIT:-120}
AUTH_RATE_LIMIT: ${COURSELAB_AUTH_RATE_LIMIT:-30}
VARIANT_TOKEN_SECRET: ${VARIANT_TOKEN_SECRET:-}
volumes:
- credentials:/run/courselab:ro
- type: bind
source: ${COURSELAB_PRIVATE_ASSESSMENTS_PATH:-./.local/private-assessments}
target: /run/private-assessments
read_only: true
bind:
create_host_path: true
networks: [database, application]
read_only: true
tmpfs:
- /tmp:size=64m,noexec,nosuid
security_opt: [no-new-privileges:true]
cap_drop: [ALL]
services:
credentials:
image: alpine:3.22
command: [sh, -ec, "umask 077; if [ ! -s /secrets/db-password ]; then head -c 32 /dev/urandom | base64 > /secrets/db-password; fi; if [ ! -s /secrets/db-runtime-password ]; then head -c 32 /dev/urandom | base64 > /secrets/db-runtime-password; fi; chown 10001:10001 /secrets/db-password /secrets/db-runtime-password; chmod 0440 /secrets/db-password /secrets/db-runtime-password"]
volumes: [credentials:/secrets]
network_mode: none
read_only: true
security_opt: [no-new-privileges:true]
cap_drop: [ALL]
cap_add: [CHOWN, FOWNER, DAC_OVERRIDE]
db:
image: postgres:17-alpine
environment:
POSTGRES_DB: courselab
POSTGRES_USER: courselab
POSTGRES_PASSWORD_FILE: /run/courselab/db-password
volumes:
- database:/var/lib/postgresql/data
- credentials:/run/courselab:ro
networks: [database]
depends_on:
credentials: {condition: service_completed_successfully}
healthcheck:
test: [CMD-SHELL, "pg_isready -U courselab -d courselab"]
interval: 3s
timeout: 3s
retries: 20
security_opt: [no-new-privileges:true]
db-roles:
image: postgres:17-alpine
entrypoint: ["/bin/sh", "/provision-runtime-role.sh"]
user: "10001:10001"
environment:
DB_HOST: db
DB_NAME: courselab
DB_ADMIN_USER: courselab
DB_RUNTIME_USER: courselab_app
DB_ADMIN_PASSWORD_FILE: /run/courselab/db-password
DB_RUNTIME_PASSWORD_FILE: /run/courselab/db-runtime-password
volumes:
- credentials:/run/courselab:ro
- ./deploy/provision-runtime-role.sh:/provision-runtime-role.sh:ro
- ./deploy/provision-runtime-role.sql:/provision-runtime-role.sql:ro
networks: [database]
depends_on:
db: {condition: service_healthy}
read_only: true
tmpfs:
- /tmp:size=16m,noexec,nosuid
security_opt: [no-new-privileges:true]
cap_drop: [ALL]
migrate:
<<: *api
command: [alembic, upgrade, head]
environment:
<<: *api-env
DATABASE_PASSWORD_FILE: /run/courselab/db-password
DB_USER: courselab
depends_on:
db-roles: {condition: service_completed_successfully}
api:
<<: *api
depends_on:
migrate: {condition: service_completed_successfully}
healthcheck:
test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/v1/health', timeout=2)"]
interval: 5s
timeout: 3s
retries: 20
start_period: 10s
web:
build: ./frontend
ports: ["127.0.0.1:${COURSELAB_PORT:-8080}:80"]
networks: [application]
depends_on:
api: {condition: service_healthy}
security_opt: [no-new-privileges:true]
networks:
database: {internal: true}
application: {}
volumes:
database: {}
credentials: {}