Spaces:
Sleeping
Sleeping
| # Dockerfile | |
| #FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 | |
| FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 | |
| ARG DEBIAN_FRONTEND=noninteractive | |
| ENV PYTHONUNBUFFERED=1 | |
| RUN apt-get update && apt-get install --no-install-recommends -y \ | |
| build-essential \ | |
| python3.9 \ | |
| python3-pip \ | |
| git \ | |
| ffmpeg \ | |
| && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| # Set environment variables to prevent Python from writing pyc files to disk | |
| # and to force unbuffered output (useful for Docker) | |
| ENV PYTHONDONTWRITEBYTECODE 1 | |
| ENV PYTHONUNBUFFERED 1 | |
| ENV HF_HOME "app/cache" | |
| ENV TRANSFORMERS_CACHE "app/cache" | |
| ### Set up user with permissions | |
| # 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 \ | |
| PYTHONPATH=$HOME/app \ | |
| PYTHONUNBUFFERED=1 \ | |
| GRADIO_ALLOW_FLAGGING=never \ | |
| GRADIO_NUM_PORTS=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 \ | |
| GRADIO_THEME=huggingface \ | |
| SYSTEM=spaces | |
| # Set the working directory in the container | |
| WORKDIR $HOME/app | |
| # Upgrade pip to the latest version and install Python dependencies | |
| COPY --chown=user requirements.txt . | |
| #RUN chown -R user:user /app | |
| RUN pip install --upgrade pip && pip install -r requirements.txt | |
| # Copy the FastAPI application code and other necessary files into the container | |
| COPY --chown=user:user ./app . | |
| COPY --chown=user:user .env . | |
| RUN ls | |
| ### Update permissions for the app | |
| USER root | |
| RUN chmod 777 . | |
| USER user | |
| # Expose port 7860 for the application | |
| EXPOSE 7860 | |
| # Command to run the FastAPI application using uvicorn | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |