Download Dockerfile from urjob/test: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/urjob/test/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/urjob/test/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/urjob/test/resolve/main/Dockerfile
2.17 kB
| FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 | |
| # Set non-interactive frontend for debconf | |
| ARG DEBIAN_FRONTEND=noninteractive | |
| # Install Python and system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| python3.11 \ | |
| python3.11-venv \ | |
| python3-pip \ | |
| build-essential \ | |
| libgl1-mesa-glx \ | |
| libglib2.0-0 \ | |
| ffmpeg \ | |
| tzdata \ | |
| postgresql-client \ | |
| libpq-dev \ | |
| git \ | |
| curl \ | |
| && ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \ | |
| && dpkg-reconfigure --frontend noninteractive tzdata \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user with UID 1000 (required for Hugging Face Spaces) | |
| RUN useradd -m -u 1000 user | |
| # Set up the user environment | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONPATH=/home/user/.local/lib/python3.11/site-packages \ | |
| CUDA_HOME=/usr/local/cuda \ | |
| CUDA_PATH=/usr/local/cuda \ | |
| LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH | |
| # Create and set up working directory | |
| WORKDIR $HOME/app | |
| # Install Python virtual environment | |
| RUN python3.11 -m venv $HOME/venv | |
| ENV PATH="$HOME/venv/bin:$PATH" | |
| # Copy requirements first (for better caching) | |
| COPY --chown=user:user behavior_backend/requirements.txt . | |
| # Install dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Create required directories with proper ownership | |
| RUN mkdir -p $HOME/app/static/uploads $HOME/app/static/results && \ | |
| chown -R user:user $HOME/app | |
| # Create data directory for persistence (if needed) | |
| RUN mkdir -p /data && chown -R user:user /data | |
| # Copy application code with proper ownership | |
| COPY --chown=user:user behavior_backend/app/ ./app/ | |
| COPY --chown=user:user behavior_backend/main.py . | |
| COPY --chown=user:user behavior_backend/.env . | |
| # Switch to non-root user | |
| USER user | |
| # Expose the port that Hugging Face Spaces expects | |
| EXPOSE 7860 | |
| # Command to run the application on the port Hugging Face expects | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |