Spaces:
Running
Running
File size: 2,175 Bytes
79f1c92 e01ca3b 79f1c92 38d8a7c 79f1c92 955dabc 79f1c92 ae79add 6042424 79f1c92 ed479a9 79f1c92 7a54564 6042424 79f1c92 f03fdde 8dcc328 79f1c92 6042424 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# Base image with CUDA 12.6.3 and cuDNN
# FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04
FROM python:3.10-bookworm
# Set environment variables
ARG DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1 \
GRADIO_FLAGGING_MODE=never \
GRADIO_NUM_PORTS=1 \
GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_THEME=huggingface \
GRADIO_CACHE_DIR=/home/appuser/.gradio_cache \
SYSTEM=spaces \
AM_I_IN_A_DOCKER_CONTAINER=Yes \
PYTHONPATH=/home/appuser/app \
HF_HOME=/home/appuser/.cache \
TORCH_HOME=/home/appuser/.cache \
TMP_DIR=/home/appuser/tmp \
TRANSFORMERS_CACHE=/home/appuser/.cache/transformers \
NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=compute,utility
# Install system dependencies and set Python 3.10 as default
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
curl \
git \
ffmpeg \
libsm6 \
libxext6 \
libgl1 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 appuser
# Set working directory
WORKDIR /home/appuser/app
# Ensure non-root user has write access to cache and tmp directories
RUN mkdir -p /home/appuser/.cache/transformers /home/appuser/tmp /home/appuser/.cache \
&& chown -R appuser:appuser /home/appuser/.cache /home/appuser/tmp/ /home/appuser/app/
# Switch to non-root user
USER appuser
# Expose port for Gradio
EXPOSE 7860
# Install `uv`
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Change shell to bash
SHELL ["/bin/bash", "-c"]
# Copy dependency files and install dependencies
COPY --chown=appuser pyproject.toml dawsonia.toml uv.lock LICENSE.txt LICENSE-RA.txt README.md ./
RUN /home/appuser/.local/bin/uv sync -p 3.10 --frozen --no-cache --no-dev \
&& chown -R appuser:appuser /home/appuser/app/.venv \
&& rm -rf /home/appuser/.cache
# Copy application code
COPY --chown=appuser app app
COPY --chown=appuser table_formats table_formats
COPY --chown=appuser examples examples
COPY --chown=appuser output output
COPY --chown=appuser data data
# Command to run the application
CMD ["/home/appuser/.local/bin/uv", "run", "app/main.py"]
|