# Use the specific Python 3.10 image as base FROM docker.io/library/python:3.10@sha256:d12ca2c8482a44ccd00661f0bbc502abf2e96c3bf46e3bdc8f8aeba2d29267f6 # Set the working directory to /home/user/app WORKDIR /home/user/app # Install necessary system dependencies including wkhtmltopdf RUN apt-get update && apt-get install -y \ git \ git-lfs \ ffmpeg \ libsm6 \ libxext6 \ cmake \ rsync \ libgl1-mesa-glx \ wkhtmltopdf \ # Adding wkhtmltopdf for PDF generation && rm -rf /var/lib/apt/lists/* \ && git lfs install # Check that wkhtmltopdf is correctly installed and print its path RUN which wkhtmltopdf # Install the necessary Python packages specified in the requirements.txt file COPY --mount=target=/tmp/requirements.txt,source=requirements.txt /tmp/requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt # Install fakeroot for compatibility with certain builds RUN apt-get update && apt-get install -y fakeroot && \ mv /usr/bin/apt-get /usr/bin/.apt-get && \ echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \ chmod +x /usr/bin/apt-get && \ rm -rf /var/lib/apt/lists/* && \ useradd -m -u 1000 user # Freeze installed package versions and save to /tmp/freeze.txt RUN pip freeze > /tmp/freeze.txt # Install additional dependencies RUN pip install --no-cache-dir \ gradio[oauth]==4.42.0 \ "uvicorn>=0.14.0" \ spaces # Copy the rest of the application code into the working directory COPY --link --chown=1000 ./ /home/user/app # Copy the freeze.txt file for reference COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt # Set the user to 1000 (non-root user) USER 1000 # Command to run the application CMD ["python", "app.py"]