Spaces:
Runtime error
Runtime error
| # Use Python 3.9 as base image | |
| FROM python:3.9 | |
| # Set working directory within the container | |
| WORKDIR /code | |
| # Copy requirements.txt to the working directory | |
| COPY ./requirements.txt /code/requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Install ffmpeg (if needed) | |
| RUN apt update && apt install -y ffmpeg | |
| # Create a non-root user | |
| RUN useradd -m -u 1000 user | |
| # Switch to the non-root user | |
| USER user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set working directory for the application | |
| WORKDIR $HOME/app | |
| # Copy the application code to the working directory | |
| COPY --chown=user . $HOME/app | |
| # Expose port 7860 (assuming your FastAPI app runs on this port) | |
| EXPOSE 7860 | |
| # Ensure PyTorch is installed | |
| RUN pip install torch torchvision torchaudio | |
| # Command to run the FastAPI application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |