# Use an official Python runtime as a parent image FROM python:3.10-slim-buster # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Set the working directory in the container WORKDIR /home/user/app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ && rm -rf /var/lib/apt/lists/* # Copy the requirements file first to leverage Docker cache COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Expose the port the app runs on EXPOSE 7860 # Create a non-root user RUN useradd -m -u 1000 user USER user # Command to run the application CMD ["python", "app.py"]