Skip to content

Commit ea50e9f

Browse files
authored
Merge pull request #421 from ansforge/hotfix/converter-metrics
chore(converter): use writable directory for prometheus metrics
2 parents bf12d92 + 7afe357 commit ea50e9f

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

converter/Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ RUN --mount=type=cache,target=/root/.cache/uv \
1919
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
2020
uv sync --frozen --no-dev --no-install-project
2121

22-
# Create metrics directory during first stage because mkdir
23-
# is not available in non dev base image
24-
RUN mkdir -p /prometheus_metrics
25-
2622
# Runtime stage: minimal DHI image with no shell or package manager,
2723
# already runs as the nonroot user.
2824
FROM dhi.io/python:3.14-alpine3.23
@@ -46,8 +42,7 @@ EXPOSE 8080
4642
ENV FLASK_ENV=production
4743
ENV CONVERTER_VERSION=${CONVERTER_VERSION}
4844

49-
# Flask Prometheus Exporter setup
50-
COPY --from=builder --chown=nonroot:nonroot /prometheus_metrics /tmp/prometheus_metrics
45+
# Flask Prometheus Exporter setup.
5146
ENV PROMETHEUS_MULTIPROC_DIR=/tmp/prometheus_metrics
5247

5348
# Use Gunicorn for production deployment

converter/converter/converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
app = Flask(__name__)
2121
init_db(app)
2222

23-
is_prod = os.getenv("FLASK_ENV") == "production"
24-
25-
if is_prod:
23+
multiproc_dir = os.getenv("PROMETHEUS_MULTIPROC_DIR")
24+
if multiproc_dir:
25+
os.makedirs(multiproc_dir, exist_ok=True)
2626
metrics = GunicornInternalPrometheusMetrics(app)
2727
else:
2828
metrics = PrometheusMetrics(app)

0 commit comments

Comments
 (0)