FROM grafana/grafana:11.6.0

# Modal functions need Python to invoke the function wrapper. Build as root so
# Python and the Grafana plugin can be installed, then run Grafana unprivileged.
USER root
RUN if [ -f /etc/alpine-release ]; then \
      apk add --no-cache python3 socat; \
    else \
      apt-get update && apt-get install --no-install-recommends -y python3 socat && rm -rf /var/lib/apt/lists/*; \
    fi \
    && ln -sf "$(command -v python3)" /usr/local/bin/python \
    && grafana cli plugins install grafana-clickhouse-datasource \
    && chown -R 472:0 /var/lib/grafana/plugins

# The upstream Alpine image runs Grafana as its unprivileged numeric UID.
USER 472
