Skip to content

Commit c386280

Browse files
committed
feat: enforce env vars with run.sh to start prometheus
1 parent 04d2113 commit c386280

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docker-compose.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ services:
152152
image: prom/prometheus:${PROMETHEUS_VERSION:-v2.46.0}
153153
user: ":"
154154
networks: [dvnode]
155+
environment:
156+
PROM_REMOTE_WRITE_TOKEN: ${PROM_REMOTE_WRITE_TOKEN:-"obol-monitoring-token-needed"}
155157
volumes:
156-
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
158+
- ./prometheus:/etc/prometheus
157159
- ./data/prometheus:/prometheus
160+
entrypoint: /etc/prometheus/run.sh
158161
restart: unless-stopped
159162

160163
grafana:
File renamed without changes.

prometheus/run.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
if [ -z "$PROM_REMOTE_WRITE_TOKEN" ]
4+
then
5+
echo "\$PROM_REMOTE_WRITE_TOKEN variable is empty"
6+
fi
7+
8+
# eval is used instead of envsubst, as prometheus user doesn't have permissions to install envsubst
9+
eval "echo \"$(cat /etc/prometheus/prometheus.yml.example)\"" > /etc/prometheus/prometheus.yml
10+
11+
/bin/prometheus \
12+
--config.file=/etc/prometheus/prometheus.yml

0 commit comments

Comments
 (0)