prometheus: Dockerfile + docker-compose for the sidecar deploy

The VPS runs Caddy inside Docker as part of the Hephaestus stack (not
system-wide angie as the earlier deploy/README assumed), so the shape
of the deploy is: Prometheus runs as its own small docker-compose that
attaches to Hephaestus's existing network, and Hephaestus's Caddy
reverse-proxies prometheus.x → prometheus:3700.

Dockerfile: node:22-alpine base (keeps the image ~55 MB and gives us
node:sqlite stable), tini for signal handling, non-root `node` user,
one /data volume holding the DB + ed25519 service key + uploads +
snapshot build output.

docker-compose: one service, attaches hephaestus_default as external
network, env sourced from an .env file alongside the compose. The .env
is NOT committed (contains ADMIN_PUBLISHER, optional VirusTotal key,
optional payment config). Healthcheck polls /healthz.

The deploy/prometheus-service.service systemd unit from the earlier
commit is now unused on this host (kept for anyone deploying natively
on a non-dockered box).
This commit is contained in:
Local Dev 2026-10-09 00:47:40 +02:00
parent 40bf5fc641
commit 7950430aa0
2 changed files with 87 additions and 0 deletions

38
deploy/Dockerfile Normal file
View file

@ -0,0 +1,38 @@
# Prometheus service image.
#
# Built for the standalone docker-compose at deploy/docker-compose.yml, which
# attaches to the hephaestus_default network so Hephaestus's Caddy can route
# prometheus.x → prometheus:3700 without either side knowing about the other.
#
# node:22-alpine keeps the image small (~55 MB with deps) and gives us
# node:sqlite (stable in 22+). We copy package files first so a code change
# that leaves deps alone reuses the npm layer.
FROM node:22-alpine
RUN apk add --no-cache tini
WORKDIR /opt/prometheus
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY service/ ./service/
COPY public/ ./public/
COPY scripts/ ./scripts/
# /data holds everything that must survive a container rebuild: the SQLite
# DB, the service's own ed25519 key, uploaded binaries and (for the snapshot
# timer) the rendered static mirror.
ENV PROMETHEUS_DB=/data/db.sqlite \
PROMETHEUS_KEY_DIR=/data/keys \
PROMETHEUS_UPLOAD_DIR=/data/uploads \
BIND=0.0.0.0 \
PORT=3700
RUN mkdir -p /data/keys /data/uploads && chown -R node:node /data /opt/prometheus
USER node
EXPOSE 3700
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "service/server.js"]

49
deploy/docker-compose.yml Normal file
View file

@ -0,0 +1,49 @@
# Standalone compose for prometheus.x on the Hephaestus VPS.
#
# The service attaches to Hephaestus's existing docker network
# (hephaestus_default), so Hephaestus's Caddy can route prometheus.x to
# `prometheus:3700` with no changes to Hephaestus itself other than one new
# block in its Caddyfile.
#
# One volume (`data`) holds the SQLite DB, the service's ed25519 signing
# key, uploads that passed scan, and the snapshot build output. Env lives
# in an .env file alongside this one; the ones below are the defaults and
# can be overridden.
name: prometheus
services:
prometheus:
build:
context: ..
dockerfile: deploy/Dockerfile
image: prometheus:latest
restart: unless-stopped
environment:
BNS_NETWORK: chipnet
ADMIN_PUBLISHER: ${ADMIN_PUBLISHER:-}
VIRUSTOTAL_API_KEY: ${VIRUSTOTAL_API_KEY:-}
PAYMENT_REQUIRED: ${PAYMENT_REQUIRED:-}
PROMETHEUS_PAYMENT_ADDRESS: ${PROMETHEUS_PAYMENT_ADDRESS:-}
PROMETHEUS_LISTING_FEE_USD: ${PROMETHEUS_LISTING_FEE_USD:-1}
BNS_GATEWAY: ${BNS_GATEWAY:-}
volumes:
- data:/data
networks:
- hephaestus
expose:
- "3700"
healthcheck:
test: ["CMD", "wget", "--quiet", "--spider", "http://127.0.0.1:3700/healthz"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
volumes:
data:
networks:
hephaestus:
external: true
name: hephaestus_default