# syntax=docker/dockerfile:1
#
# Configuration image for the monitoring stack.
#
# Why this exists: docker-node-01 is a Portainer *agent* endpoint. Portainer
# ships compose content to the agent instead of running compose beside a git
# checkout, so relative bind mounts such as ./config/grafana:/etc/grafana do not
# resolve. Building configuration into an image and seeding it into a named
# volume makes configuration delivery a versioned, atomic operation (one image
# tag) with no shell access to the node and no host paths to keep in sync.
#
# gettext is installed for envsubst: files ending in .tmpl are rendered with the
# container environment at seed time, which is how the Tempo S3 credentials and
# the Alertmanager receiver URL reach their config files without ever being
# committed to this repository.

FROM alpine:3.22

RUN apk add --no-cache gettext \
 && adduser -D -u 10001 seeder

WORKDIR /src

# The contents of config/ land at the volume root, not inside a config/ directory.
# Consumers reference /etc/monitoring/tempo/tempo.yaml, so the volume has to
# contain tempo/ directly. synthetics/ keeps its directory name because the
# scheduler addresses it as /config/synthetics/k6/api-journey.js.
COPY config/ /src/
COPY synthetics/ /src/synthetics/
COPY docker/config-image/seed.sh /usr/local/bin/seed.sh

RUN chmod 0755 /usr/local/bin/seed.sh

ENTRYPOINT ["/usr/local/bin/seed.sh"]
