FROM python:3.11-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PYTHONIOENCODING=utf-8 # Install system dependencies including PostgreSQL client libraries RUN apt-get update && apt-get install -y \ curl \ libpq-dev \ gcc \ && rm -rf /var/lib/apt/lists/* # Create app user and directory RUN useradd --create-home --shell /bin/bash app WORKDIR /app # Copy requirements and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Set ownership RUN chown -R app:app /app # Switch to app user USER app # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8080/health || exit 1 # Expose port EXPOSE 8080 # Run the application CMD ["python", "nfoguard.py"]