# Base image with Python 3.9 FROM python:3.9 # For fixing ImportError: libGL.so.1: cannot open shared object file: No such file or directory RUN apt-get update RUN apt install -y libgl1-mesa-glx # Create a non-root user RUN useradd -m -u 1000 user # Set the working directory WORKDIR /app # Copy requirements.txt and install Python dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application code COPY --chown=user . /app # Switch to the non-root user USER user # Command to run the FastAPI application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]