Repository navigation
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
195 lines (185 loc) · 4.65 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
195 lines (185 loc) · 4.65 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
version: '3.9'
services:
redis:
image: redis:7-alpine
container_name: biokey-redis
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- data-network
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
postgres:
image: postgres:15-alpine
container_name: biokey-postgres
environment:
POSTGRES_DB: biokey_db
POSTGRES_USER: biokey
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
- ./database/seeds.sql:/docker-entrypoint-initdb.d/02-seeds.sql
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U biokey"]
interval: 10s
timeout: 5s
retries: 5
networks:
- data-network
deploy:
resources:
limits:
cpus: '1.00'
memory: 1G
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
backend:
build:
context: ./backend-server
dockerfile: Dockerfile
container_name: biokey-backend
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
DB_NAME: biokey_db
DB_USER: biokey
DB_HOST: postgres
DB_PORT: 5432
DB_POOL_SIZE: 10
REDIS_URL: redis://redis:6379/0
ENABLE_ASYNC_ADMIN_JOBS: "true"
API_PORT: 4567
API_BIND: 0.0.0.0
APP_ENV: ${APP_ENV:-production}
APP_REQUIRE_HTTPS: "true"
REQUIRE_ADMIN_TOKEN_HASH: "true"
TRUST_PROXY: "1"
LOG_LEVEL: ${LOG_LEVEL:-INFO}
LOG_FORMAT: json
command: >
sh -c 'export DB_PASSWORD="$(cat /run/secrets/db_password)";
export APP_SESSION_SECRET="$(cat /run/secrets/app_session_secret)";
export SESSION_TOKEN_PEPPER="$(cat /run/secrets/session_token_pepper)";
export APP_AUTH_PEPPER="$(cat /run/secrets/app_auth_pepper)";
export ADMIN_TOKEN_HASH="$(cat /run/secrets/admin_token_hash)";
exec bundle exec ruby app.rb'
secrets:
- db_password
- app_session_secret
- session_token_pepper
- app_auth_pepper
- admin_token_hash
ports:
- "4567:4567"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4567/ready"]
interval: 30s
timeout: 10s
retries: 3
networks:
- backend-network
- data-network
deploy:
resources:
limits:
cpus: '1.00'
memory: 1G
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
backend-worker:
build:
context: ./backend-server
dockerfile: Dockerfile
container_name: biokey-backend-worker
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
DB_NAME: biokey_db
DB_USER: biokey
DB_HOST: postgres
DB_PORT: 5432
REDIS_URL: redis://redis:6379/0
ENABLE_ASYNC_ADMIN_JOBS: "true"
APP_ENV: ${APP_ENV:-production}
command: >
sh -c 'export DB_PASSWORD="$(cat /run/secrets/db_password)";
exec bundle exec ruby worker.rb'
secrets:
- db_password
networks:
- data-network
deploy:
resources:
limits:
cpus: '1.00'
memory: 1G
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
# Optional: pgAdmin for database management
pgadmin:
image: dpage/pgadmin4:latest
container_name: biokey-pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin@biokey.local
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD?PGADMIN_PASSWORD is required for pgadmin profile}
ports:
- "5050:80"
depends_on:
- postgres
networks:
- backend-network
profiles: ["dev"] # Only run with: docker-compose --profile dev up
volumes:
postgres_data:
driver: local
redis_data:
driver: local
secrets:
db_password:
file: ./.secrets/db_password.txt
app_session_secret:
file: ./.secrets/app_session_secret.txt
session_token_pepper:
file: ./.secrets/session_token_pepper.txt
app_auth_pepper:
file: ./.secrets/app_auth_pepper.txt
admin_token_hash:
file: ./.secrets/admin_token_hash.txt
networks:
backend-network:
driver: bridge
data-network:
driver: bridge
internal: true