2025-06-18 20:22:36 +05:30
|
|
|
# Stage 1: Build stage with dependencies
|
2026-09-26 10:08:28 +05:30
|
|
|
FROM python:3.12-slim AS builder
|
2025-06-18 20:22:36 +05:30
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install Python dependencies
|
|
|
|
|
COPY requirements.txt .
|
2026-09-26 10:08:28 +05:30
|
|
|
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
2025-06-18 20:22:36 +05:30
|
|
|
|
|
|
|
|
# Stage 2: Final runtime stage
|
2026-09-26 10:08:28 +05:30
|
|
|
FROM python:3.12-slim
|
2025-06-18 20:22:36 +05:30
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-09-26 10:08:28 +05:30
|
|
|
# Install iperf3
|
2025-06-21 02:10:19 +05:30
|
|
|
RUN apt-get update && \
|
2026-09-26 10:08:28 +05:30
|
|
|
apt-get install -y --no-install-recommends iperf3 && \
|
2025-06-21 02:00:24 +05:30
|
|
|
rm -rf /var/lib/apt/lists/*
|
2025-06-18 20:22:36 +05:30
|
|
|
|
|
|
|
|
# Copy installed Python packages from the builder stage
|
2026-09-26 10:08:28 +05:30
|
|
|
COPY --from=builder /install /usr/local
|
2025-06-18 20:22:36 +05:30
|
|
|
|
|
|
|
|
# Copy the exporter application code
|
|
|
|
|
COPY exporter.py .
|
|
|
|
|
|
|
|
|
|
# Expose the metrics port
|
|
|
|
|
EXPOSE 9876
|
|
|
|
|
|
2026-09-26 10:08:28 +05:30
|
|
|
# Run as non-root user (nobody)
|
|
|
|
|
USER 65534:65534
|
|
|
|
|
|
2025-06-18 20:22:36 +05:30
|
|
|
# Set the entrypoint
|
2025-06-21 02:00:24 +05:30
|
|
|
CMD ["python", "exporter.py"]
|
2026-09-26 10:08:28 +05:30
|
|
|
|