28 lines
704 B
Docker
28 lines
704 B
Docker
# Use a Python slim image as base
|
|
FROM python:3.9-slim as exporter_custom
|
|
|
|
# Set environment variables to avoid buffering
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Create and set working directory
|
|
WORKDIR /app
|
|
|
|
# Install required dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
libpq-dev && \
|
|
pip install psycopg2-binary prometheus-client && \
|
|
apt-get clean
|
|
|
|
# Create a directory for logs
|
|
RUN mkdir /app/logs
|
|
|
|
# Copy the Python script into the container
|
|
COPY pg_metrics_exporter.py /app/
|
|
|
|
# Set permissions for log directory (if required)
|
|
RUN chmod 755 /app/logs
|
|
|
|
# Run the script and redirect logs to a file
|
|
CMD ["python", "/app/pg_metrics_exporter.py", ">", "/app/logs/exporter.log", "2>&1"]
|