-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
186 lines (178 loc) · 6.92 KB
/
Copy pathdocker-compose.yml
File metadata and controls
186 lines (178 loc) · 6.92 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
services:
openwrt-controller:
build:
context: .
dockerfile: Dockerfile
container_name: openwrt_controller
# SECURITY: never run as root in production; require TLS; read-only fs.
# The Dockerfile ships a non-root user (app, uid 10001) so the
# read-only rootfs is actually usable — files in /app are owned by
# app:app at build time.
read_only: true
security_opt:
- no-new-privileges:true
# Drop all Linux capabilities except what we strictly need. The
# server only opens TCP/UDP sockets, so NET_BIND_SERVICE is the
# only one we keep.
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE
healthcheck:
# /healthz is anonymous and cheap; see internal/api/handlers/probes.go.
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/healthz", "||", "exit", "1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 20s
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/openwrthub
- INFLUX_URL=http://influxdb:8086
- INFLUX_ORG=openwrthub
- INFLUX_BUCKET=telemetry
- INFLUX_TOKEN=${INFLUX_TOKEN:?INFLUX_TOKEN required}
- JWT_SECRET=${JWT_SECRET:?JWT_SECRET required, min 32 chars}
- REQUIRE_TLS=${REQUIRE_TLS:-false}
- WS_ALLOWED_ORIGINS=${WS_ALLOWED_ORIGINS:-}
- ALLOW_LEGACY_PROVISION=${ALLOW_LEGACY_PROVISION:-false}
depends_on:
postgres:
condition: service_started
influxdb:
condition: service_started
restart: unless-stopped
postgres:
image: postgres:15.13-alpine
container_name: openwrt_postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d openwrthub"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD required}
POSTGRES_DB: openwrthub
# Bind to loopback only by default. Production deployments that need
# remote access should set PG_BIND_ADDR to a private network interface
# (e.g. 10.0.0.1) and adjust firewall rules accordingly.
ports:
- "${PG_BIND_ADDR:-127.0.0.1}:5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped
influxdb:
image: influxdb:2.7.10-alpine
container_name: openwrt_influx
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8086/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# Same loopback-by-default policy as Postgres.
ports:
- "${INFLUX_BIND_ADDR:-127.0.0.1}:8086:8086"
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD:?INFLUXDB_PASSWORD required}
DOCKER_INFLUXDB_INIT_ORG: openwrthub
DOCKER_INFLUXDB_INIT_BUCKET: telemetry
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${INFLUX_TOKEN:?INFLUX_TOKEN required}
volumes:
- influxdata:/var/lib/influxdb2
restart: unless-stopped
freeradius:
# Pinned to a specific version. The :latest tag is unacceptable in
# production — supply-chain risk and untested upgrades.
image: freeradius/freeradius-server:3.2.5-alpine
container_name: openwrt_radius
healthcheck:
test: ["CMD", "radtest", "dummy", "dummy", "127.0.0.1", "0", "testing123"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
ports:
- "1812:1812/udp"
- "1813:1813/udp"
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
command: >
sh -c '
apk add --no-cache freeradius-postgresql &&
ln -sf /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/sql &&
sed -i "s/driver = \"rlm_sql_null\"/driver = \"rlm_sql_postgresql\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/dialect = \"sqlite\"/dialect = \"postgresql\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/server = \"localhost\"/server = \"postgres\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/port = 3306/port = 5432/g" /etc/raddb/mods-available/sql &&
sed -i "s/login = \"radius\"/login = \"postgres\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/password = \"radpass\"/password = \"${POSTGRES_PASSWORD}\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/radius_db = \"radius\"/radius_db = \"openwrthub\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/read_clients = no/read_clients = yes/g" /etc/raddb/mods-available/sql &&
radiusd -f'
volumes:
pgdata:
influxdata:
postgres:
image: postgres:15-alpine
container_name: openwrt_postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD required}
POSTGRES_DB: openwrthub
# Bind to loopback only by default. Production deployments that need
# remote access should set PG_BIND_ADDR to a private network interface
# (e.g. 10.0.0.1) and adjust firewall rules accordingly.
ports:
- "${PG_BIND_ADDR:-127.0.0.1}:5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
restart: unless-stopped
influxdb:
image: influxdb:2.7-alpine
container_name: openwrt_influx
# Same loopback-by-default policy as Postgres.
ports:
- "${INFLUX_BIND_ADDR:-127.0.0.1}:8086:8086"
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD:?INFLUXDB_PASSWORD required}
DOCKER_INFLUXDB_INIT_ORG: openwrthub
DOCKER_INFLUXDB_INIT_BUCKET: telemetry
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${INFLUX_TOKEN:?INFLUX_TOKEN required}
volumes:
- influxdata:/var/lib/influxdb2
restart: unless-stopped
freeradius:
image: freeradius/freeradius-server:latest-alpine
container_name: openwrt_radius
ports:
- "1812:1812/udp"
- "1813:1813/udp"
depends_on:
- postgres
restart: unless-stopped
command: >
sh -c '
apk add --no-cache freeradius-postgresql &&
ln -sf /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/sql &&
sed -i "s/driver = \"rlm_sql_null\"/driver = \"rlm_sql_postgresql\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/dialect = \"sqlite\"/dialect = \"postgresql\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/server = \"localhost\"/server = \"postgres\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/port = 3306/port = 5432/g" /etc/raddb/mods-available/sql &&
sed -i "s/login = \"radius\"/login = \"postgres\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/password = \"radpass\"/password = \"${POSTGRES_PASSWORD}\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/radius_db = \"radius\"/radius_db = \"openwrthub\"/g" /etc/raddb/mods-available/sql &&
sed -i "s/read_clients = no/read_clients = yes/g" /etc/raddb/mods-available/sql &&
radiusd -f'
volumes:
pgdata:
influxdata: