forked from 18F/couch-rules-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
108 lines (104 loc) · 2.57 KB
/
docker-compose.yml
File metadata and controls
108 lines (104 loc) · 2.57 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
services:
couchdb:
# Pin to specific version for reproducibility and security
image: couchdb:3.5.1
container_name: couchdb-rules-engine
environment:
- COUCHDB_USER=admin
- COUCHDB_PASSWORD=password
- COUCHDB_SECRET=mysecret
ports:
- "5984:5984"
volumes:
- couchdb_data:/opt/couchdb/data
- couchdb_config:/opt/couchdb/etc/local.d
# Security hardening for CouchDB container
# Note: CouchDB entrypoint requires privilege escalation to switch users
# so we cannot use no-new-privileges or cap_drop without breaking startup
# Resource limits to prevent resource exhaustion attacks
deploy:
resources:
limits:
memory: 512M
cpus: '1.0'
reservations:
memory: 256M
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5984/_up"]
interval: 30s
timeout: 10s
retries: 5
networks:
- rules-engine-network
web-interface:
build:
context: ./web
dockerfile: Dockerfile
container_name: rules-engine-web
ports:
# DHI nginx listens on 8080 internally (non-root)
- "8080:8080"
depends_on:
couchdb:
condition: service_healthy
environment:
- COUCHDB_URL=http://couchdb:5984
- COUCHDB_DATABASE=rules_db
# Security hardening for web interface
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
read_only: true
tmpfs:
- /tmp:noexec,nosuid,size=32m
- /var/cache/nginx:size=32m
- /var/run:noexec,nosuid,size=16m
deploy:
resources:
limits:
memory: 128M
cpus: '0.5'
networks:
- rules-engine-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
interval: 30s
timeout: 10s
retries: 3
initializer:
build:
context: .
dockerfile: Dockerfile.initializer
container_name: rules-engine-initializer
depends_on:
couchdb:
condition: service_healthy
environment:
- COUCHDB_URL=http://couchdb:5984
- COUCHDB_USER=admin
- COUCHDB_PASSWORD=password
- DB_NAME=rules_db
# Security hardening for initializer (runs once and exits)
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
deploy:
resources:
limits:
memory: 128M
cpus: '0.5'
networks:
- rules-engine-network
restart: "no"
volumes:
couchdb_data:
couchdb_config:
networks:
rules-engine-network:
driver: bridge