# Use a lightweight Python image FROM python:3.9 # Create a non-root user RUN useradd -u 1000 user ENV PATH="/home/user/.local/bin:$PATH" # Set the working directory inside the container WORKDIR /app # Copy the dependencies and install them as root COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Switch to the non-root user after installing dependencies USER user COPY . . # Run the FastAPI app with Uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]