Build Grafana image from Dockerfile
9a2f9a8 parent: de739e7 added
grafana/Dockerfile +16 -0 | new file mode 100644 | ||
| @@ -0,0 +1,16 @@ | ||
| 1 | +FROM grafana/grafana:11.6.0 | |
| 2 | + | |
| 3 | +# Modal functions need Python to invoke the function wrapper. Build as root so | |
| 4 | +# Python and the Grafana plugin can be installed, then run Grafana unprivileged. | |
| 5 | +USER root | |
| 6 | +RUN if [ -f /etc/alpine-release ]; then \ | |
| 7 | + apk add --no-cache python3; \ | |
| 8 | + else \ | |
| 9 | + apt-get update && apt-get install --no-install-recommends -y python3 && rm -rf /var/lib/apt/lists/*; \ | |
| 10 | + fi \ | |
| 11 | + && ln -sf "$(command -v python3)" /usr/local/bin/python \ | |
| 12 | + && grafana cli plugins install grafana-clickhouse-datasource \ | |
| 13 | + && chown -R 472:0 /var/lib/grafana/plugins | |
| 14 | + | |
| 15 | +# The upstream Alpine image runs Grafana as its unprivileged numeric UID. | |
| 16 | +USER 472 | |
| new file mode 100644 | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | +FROM grafana/grafana:11.6.0 | ||
| 2 | + | ||
| 3 | +# Modal functions need Python to invoke the function wrapper. Build as root so | ||
| 4 | +# Python and the Grafana plugin can be installed, then run Grafana unprivileged. | ||
| 5 | +USER root | ||
| 6 | +RUN if [ -f /etc/alpine-release ]; then \ | ||
| 7 | + apk add --no-cache python3; \ | ||
| 8 | + else \ | ||
| 9 | + apt-get update && apt-get install --no-install-recommends -y python3 && rm -rf /var/lib/apt/lists/*; \ | ||
| 10 | + fi \ | ||
| 11 | + && ln -sf "$(command -v python3)" /usr/local/bin/python \ | ||
| 12 | + && grafana cli plugins install grafana-clickhouse-datasource \ | ||
| 13 | + && chown -R 472:0 /var/lib/grafana/plugins | ||
| 14 | + | ||
| 15 | +# The upstream Alpine image runs Grafana as its unprivileged numeric UID. | ||
| 16 | +USER 472 | ||
modified
modal_grafana.py +1 -2 | @@ -25,8 +25,7 @@ grafana_secret = modal.Secret.from_name( | ||
| 25 | 25 | ], |
| 26 | 26 | ) |
| 27 | 27 | image = ( |
| 28 | - modal.Image.from_registry("grafana/grafana:11.6.0", add_python="3.12") | |
| 29 | - .run_commands("grafana cli plugins install grafana-clickhouse-datasource") | |
| 28 | + modal.Image.from_dockerfile("grafana/Dockerfile") | |
| 30 | 29 | .add_local_dir("grafana/provisioning", "/etc/grafana/provisioning") |
| 31 | 30 | ) |
| 32 | 31 | |
| @@ -25,8 +25,7 @@ grafana_secret = modal.Secret.from_name( | |||
| 25 | ], | 25 | ], |
| 26 | ) | 26 | ) |
| 27 | image = ( | 27 | image = ( |
| 28 | - modal.Image.from_registry("grafana/grafana:11.6.0", add_python="3.12") | 28 | + modal.Image.from_dockerfile("grafana/Dockerfile") |
| 29 | - .run_commands("grafana cli plugins install grafana-clickhouse-datasource") | ||
| 30 | .add_local_dir("grafana/provisioning", "/etc/grafana/provisioning") | 29 | .add_local_dir("grafana/provisioning", "/etc/grafana/provisioning") |
| 31 | ) | 30 | ) |
| 32 | 31 | ||