prometheus: add ClamAV sidecar — real uploads can scan now
Before this: service's /healthz always 503'd and the upload endpoint
rejected every submission with scan verdict=error, because clamd was not
installed anywhere reachable. Service worked for the seeded browse view
but no publisher could POST a listing.
Now: a `clamav` sibling container runs the official clamav/clamav:stable
image on an internal docker network only Prometheus can reach. The
Prometheus service connects via CLAMD_HOST=clamav. Signatures live in a
dedicated volume so restarts reuse the ~250 MB freshclam downloaded on
first start.
Two networks on the Prometheus container now:
prometheus-internal bridge, service + clamav only; clamd never exposed
hephaestus external hephaestus_default, so Hephaestus's Caddy
continues to route prometheus.x → prometheus:3700
depends_on with condition=service_healthy means Prometheus waits for
clamd's healthcheck to pass before starting. clamav's start_period is
5 min to accommodate the signature download; the healthcheck itself
is clamdcheck.sh / clamdscan --ping with a 10s timeout per probe.
Deploy on the VPS:
cd ~/prometheus && git pull && cd deploy
docker compose pull clamav # first time, 500+ MB
docker compose up -d # Prometheus will wait for clamav healthy
This commit is contained in:
parent
a9ca956c2e
commit
998d0b0fca
1 changed files with 34 additions and 1 deletions
|
|
@ -19,8 +19,13 @@ services:
|
|||
dockerfile: deploy/Dockerfile
|
||||
image: prometheus:latest
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
clamav:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
BNS_NETWORK: chipnet
|
||||
CLAMD_HOST: clamav
|
||||
CLAMD_PORT: "3310"
|
||||
ADMIN_PUBLISHER: ${ADMIN_PUBLISHER:-}
|
||||
VIRUSTOTAL_API_KEY: ${VIRUSTOTAL_API_KEY:-}
|
||||
PAYMENT_REQUIRED: ${PAYMENT_REQUIRED:-}
|
||||
|
|
@ -30,6 +35,7 @@ services:
|
|||
volumes:
|
||||
- data:/data
|
||||
networks:
|
||||
- prometheus-internal
|
||||
- hephaestus
|
||||
expose:
|
||||
- "3700"
|
||||
|
|
@ -38,12 +44,39 @@ services:
|
|||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
start_period: 60s
|
||||
|
||||
# ClamAV runs as a sibling container on an internal network — only
|
||||
# Prometheus can reach it. First start downloads ~250 MB of signatures via
|
||||
# freshclam into a volume; subsequent starts reuse it.
|
||||
clamav:
|
||||
image: clamav/clamav:stable
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
CLAMAV_NO_MILTERD: "true"
|
||||
volumes:
|
||||
- clamav-sigs:/var/lib/clamav
|
||||
networks:
|
||||
- prometheus-internal
|
||||
expose:
|
||||
- "3310"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "clamdcheck.sh || clamdscan --ping 2>/dev/null || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
# Signature download on first start can take a few minutes.
|
||||
start_period: 5m
|
||||
|
||||
volumes:
|
||||
data:
|
||||
clamav-sigs:
|
||||
|
||||
networks:
|
||||
# Internal: only Prometheus + clamav. Clamd never exposed off this network.
|
||||
prometheus-internal:
|
||||
driver: bridge
|
||||
# External: shared with Hephaestus so its Caddy can route prometheus.x.
|
||||
hephaestus:
|
||||
external: true
|
||||
name: hephaestus_default
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue