Spaces:
Sleeping
Sleeping
| FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime | |
| # Ensure timezone is non-interactive | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ffmpeg \ | |
| git \ | |
| build-essential \ | |
| curl \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a new user named "user" with user ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # --- OPTIMIZED CACHING --- | |
| # 1. Copy the requirements and install them first | |
| COPY --chown=user requirements.txt requirements3d.txt $HOME/app/ | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt && \ | |
| pip install --no-cache-dir -r requirements3d.txt | |
| # 2. Copy the model download script and run it | |
| RUN mkdir -p $HOME/app/scripts | |
| COPY --chown=user scripts/download_models.sh $HOME/app/scripts/download_models.sh | |
| RUN bash scripts/download_models.sh | |
| # 3. Copy the rest of the app (this layer will change frequently, but the above layers will be cached) | |
| COPY --chown=user . $HOME/app | |
| # Expose the port that Gradio runs on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["python", "app.py"] | |