Spaces:
Sleeping
Sleeping
| # Use a standard Python base image | |
| FROM python:3.9-slim | |
| # Set environment variables to non-interactive | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install necessary packages | |
| RUN apt-get update && \ | |
| apt-get install -y \ | |
| python3 \ | |
| python3-pip \ | |
| python3-venv \ | |
| wget \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a user with ID 1000 as required by Hugging Face | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /home/user/app | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Create and activate a virtual environment | |
| RUN python3 -m venv /home/user/venv | |
| ENV PATH="/home/user/venv/bin:$PATH" | |
| # Install Python requirements | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Add a comment about installing CPU-only dependencies here if needed for the full application | |
| # e.g., RUN pip install torch==1.x.x+cpu torchvision==0.x.x+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html | |
| # Copy application files | |
| COPY --chown=user app.py . | |
| # Switch to the user | |
| USER user | |
| # Expose port for the web server | |
| EXPOSE 7860 | |
| # Run the application | |
| CMD ["python3", "app.py"] |