-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
177 lines (172 loc) · 7.14 KB
/
docker-compose.yml
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
name: simbiat-dev
# Looks like subnet may change in some cases for no apparent reason, so trying to force it
networks:
webserver:
driver: bridge
enable_ipv6: true
ipam:
config:
- subnet: 172.21.0.0/16
- subnet: 2001:db8:1::/64
services:
geoip:
container_name: geoip
build:
context: ./config/geoip
dockerfile: Dockerfile
restart: unless-stopped
environment:
GEOIPUPDATE_PRESERVE_FILE_TIMES: 1
GEOIPUPDATE_FREQUENCY: 24
GEOIPUPDATE_ACCOUNT_ID: ${GEOIP_ACCOUNT}
GEOIPUPDATE_LICENSE_KEY: ${GEOIP_LICENSE}
GEOIPUPDATE_EDITION_IDS: GeoLite2-ASN GeoLite2-City
volumes:
- ./data/geoip/:/usr/share/GeoIP/:rw
frankenphp:
container_name: frankenphp
build:
context: ./config/frankenphp
dockerfile: Dockerfile
args:
WEB_SERVER_TEST: ${WEB_SERVER_TEST}
restart: unless-stopped
environment:
WEB_SERVER_TEST: ${WEB_SERVER_TEST}
CROWDSEC_API_KEY: ${CROWDSEC_CADDY_KEY}
PHP_INI_DIR: /usr/local/php/config
PHP_INI_SCAN_DIR: /usr/local/php/config
networks:
- webserver
ports:
- "80:80" # HTTP
- "443:443" # HTTPS
- "443:443/udp" # HTTP/3
volumes:
- ./:/app:rw
- ./config/frankenphp:/usr/local/php/config:rw
- ${CADDY_DATA_DIR}:/data:rw
- ./data/caddy_config:/config:rw
security_opt:
- no-new-privileges=true
depends_on:
geoip:
condition: service_started
crowdsec:
condition: service_healthy
local.simbiat.dev:
condition: service_healthy
links:
- local.simbiat.dev:mysql
- local.simbiat.dev:database
#We need to register cron task and start cron service before the endpoint
command: >
/bin/sh -c "printenv | grep -v "no_proxy" > /etc/environment &&
cp /usr/local/php/config/cron/php.cron /etc/cron.d/php.cron &&
chmod 0644 /etc/cron.d/php.cron &&
crontab /etc/cron.d/php.cron &&
cron &&
docker-php-entrypoint --config /usr/local/php/config/caddy.json5 --adapter json5"
crowdsec:
#Based on https://github.com/crowdsecurity/example-docker-compose/tree/main/caddy
container_name: crowdsec
build:
context: ./config/crowdsec
dockerfile: Dockerfile
restart: unless-stopped
environment:
GID: 1000
COLLECTIONS: crowdsecurity/caddy crowdsecurity/whitelist-good-actors crowdsecurity/http-cve crowdsecurity/http-dos crowdsecurity/base-http-scenarios crowdsecurity/appsec-crs crowdsecurity/appsec-generic-rules crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-wordpress crowdsecurity/wordpress crowdsecurity/discord-crawler-whitelist openappsec/openappsec
BOUNCER_KEY_CADDY: ${CROWDSEC_CADDY_KEY}
BOUNCER_KEY_IPTABLES: ${CROWDSEC_IPTABLES_KEY}
networks:
- webserver
ports:
- "8080:8080"
- "6060:6060"
- "7422:7422"
volumes:
- ./data/crowdsec/:/var/lib/crowdsec/data/:rw
- ./data/geoip/GeoLite2-ASN.mmdb:/var/lib/crowdsec/data/GeoLite2-ASN.mmdb:ro
- ./data/geoip/GeoLite2-City.mmdb:/var/lib/crowdsec/data/GeoLite2-City.mmdb:ro
- ./config/crowdsec/yaml/acquis.yaml:/etc/crowdsec/acquis.yaml:ro
- ./config/crowdsec/yaml/acquis/:/etc/crowdsec/acquis.d/:rw
- ./config/crowdsec/yaml/config.yaml.local:/etc/crowdsec/config.yaml.local:ro
- ./config/crowdsec/yaml/online_api_credentials.yaml:/etc/crowdsec/online_api_credentials.yaml:ro
- ./config/crowdsec/yaml/appsec/simbiat-appsec.yaml:/etc/crowdsec/appsec-configs/simbiat-appsec.yaml:ro
- ./config/crowdsec/yaml/appsec/simbiat-seclang.yaml:/etc/crowdsec/appsec-rules/simbiat-seclang.yaml:ro
- ./config/crowdsec/01-coraza-recommended.conf:/var/lib/crowdsec/data/01-coraza-recommended.conf:ro
- ./config/crowdsec/02-crs-setup.conf:/var/lib/crowdsec/data/02-crs-setup.conf:ro
- ./config/crowdsec/03-exclusions-before-crs.conf:/var/lib/crowdsec/data/03-exclusions-before-crs.conf:ro
- ./config/crowdsec/04-exclusions-after-crs.conf:/var/lib/crowdsec/data/04-exclusions-after-crs.conf:ro
#Required to read syslog. This will be valid only on UNIX
- /var/log/:/var/log/:ro
#Caddy logs folder is RW, because we're also writing Crowdsec logs here
- ./logs:/usr/local/logs/:rw
security_opt:
- no-new-privileges=true
depends_on:
geoip:
condition: service_started
healthcheck:
test: [ "CMD", "cscli", "lapi", "status" ]
start_period: 120s
interval: 10s
timeout: 5s
retries: 3
#Override image's entrypoint to execute custom command
entrypoint: ''
command: >
/bin/sh -c "mkdir -p /etc/periodic/daily/ &&
printf \"#!/bin/sh\\ncscli hub update&&cscli hub upgrade\">/etc/periodic/daily/crowdsec_update.sh &&
chmod +x /etc/periodic/daily/crowdsec_update.sh &&
/bin/bash /docker_start.sh"
local.simbiat.dev:
container_name: mariadb
build:
context: ./config/mysql
dockerfile: Dockerfile
restart: unless-stopped
environment:
WEB_SERVER_TEST: ${WEB_SERVER_TEST}
MARIADB_AUTO_UPGRADE: true
#Settings for SSL certificates generated by CRON job
MARIADB_TLS_SETTING_CA_NAME: ${MARIADB_TLS_SETTING_CA_NAME}
MARIADB_TLS_SETTING_CLIENT_NAME: ${MARIADB_TLS_SETTING_CLIENT_NAME}
MARIADB_TLS_SETTING_SERVER_NAME: ${MARIADB_TLS_SETTING_SERVER_NAME}
#Alias in format of "DNS:domain_name[,DNS:domain_name2]". If you do not need an alias use the servername for "domain_name"
MARIADB_TLS_SETTING_SERVER_ALIAS: ${MARIADB_TLS_SETTING_SERVER_ALIAS}
#Password for backups created by CRON job
MARIADB_BACKUP_PASSWORD: ${MARIADB_BACKUP_PASSWORD}
networks:
- webserver
ports:
- ${MARIADB_PORT}:${MARIADB_PORT}
volumes:
- ${MARIADB_DATA_DIR}:/var/lib/mysql:rw
- ./config/mysql:/etc/mysql/conf.d:ro
- ${MARIADB_KEYS_DIR}:/usr/local/keys:rw
- ./logs:/usr/local/logs:rw
- ${MARIADB_BACKUP_DIR}:/usr/local/backups:rw
- ./build/DDL:/usr/local/DDL:ro
security_opt:
- no-new-privileges=true
healthcheck:
test: [ "CMD", "healthcheck.sh", "--defaults-file=/etc/mysql/conf.d/my.cnf", "--connect", "--innodb_initialized", "--innodb_buffer_pool_loaded", "--mariadbupgrade" ]
start_period: 120s
interval: 10s
timeout: 5s
retries: 3
#We want to generate keys automatically, and it is also a good idea to regenerate them on each restart
#We need to ensure that buffer pool file exists, too
#We need to register cron tasks and start cron service before the endpoint
command: >
/bin/sh -c "printenv | grep -v "no_proxy" > /etc/environment &&
/etc/mysql/conf.d/cron/ssl.sh &&
touch /var/lib/mysql/ib_buffer_pool &&
chown mysql:mysql /var/lib/mysql/ib_buffer_pool &&
cp /etc/mysql/conf.d/cron/mariadb.cron /etc/cron.d/mariadb.cron &&
chmod 0644 /etc/cron.d/mariadb.cron &&
crontab /etc/cron.d/mariadb.cron &&
cron &&
docker-entrypoint.sh mariadbd"