# Use a base Ubuntu image FROM ubuntu:22.04 # Install system dependencies and Python RUN apt-get update && \ apt-get install -y --no-install-recommends \ python3 \ python3-pip \ python3-dev \ && rm -rf /var/lib/apt/lists/* # Create a non-root user and set permissions RUN useradd -m appuser && mkdir /app && chown appuser:appuser /app USER appuser WORKDIR /app # Copy requirements.txt and install dependencies COPY --chown=appuser:appuser requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY --chown=appuser:appuser . . # Run the script CMD ["python3", "app.py"]