FROM prom/prometheus:v2.45.0 # Copy configuration files COPY prometheus.yml /etc/prometheus/prometheus.yml COPY alert_rules.yml /etc/prometheus/rules/alert_rules.yml # Create directories for rules USER root RUN mkdir -p /etc/prometheus/rules && \ chown -R nobody:nobody /etc/prometheus USER nobody # Expose Prometheus port EXPOSE 9090 # Start Prometheus with configuration CMD ["--config.file=/etc/prometheus/prometheus.yml", \ "--storage.tsdb.path=/prometheus", \ "--web.console.libraries=/usr/share/prometheus/console_libraries", \ "--web.console.templates=/usr/share/prometheus/consoles", \ "--web.enable-lifecycle", \ "--storage.tsdb.retention.time=30d"]