File size: 1,909 Bytes
bc8d843
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM docker.io/library/python:3.10@sha256:76f22e4ce53774c1f5eb0ba145edb57b908e7aa329fee75eca69b511c1d0cd8a

WORKDIR /home/user/app

# Install uv and create virtual environment
RUN python -m pip install uv && \
    uv venv --python=3.12 .venv && \
    . .venv/bin/activate

# Base pip updates and initial packages
RUN pip install --no-cache-dir pip -U && \
    pip install --no-cache-dir datasets "huggingface-hub>=0.19" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"

# System packages installation
RUN --mount=target=/tmp/packages.txt,source=packages.txt \
    apt-get update && \
    xargs -r -a /tmp/packages.txt apt-get install -y && \
    apt-get install -y curl && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs && \
    rm -rf /var/lib/apt/lists/* && \
    apt-get clean

# Fakeroot setup
RUN apt-get update && \
    apt-get install -y fakeroot && \
    mv /usr/bin/apt-get /usr/bin/.apt-get && \
    echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \
    chmod +x /usr/bin/apt-get && \
    rm -rf /var/lib/apt/lists/* && \
    useradd -m -u 1000 user

# Copy files and install requirements
COPY --chown=1000:1000 --from=root / /

# Install requirements in specific order
RUN . .venv/bin/activate && \
    pip install -r .venv/requirements-cpu.txt && \
    pip install -e .venv/. && \
    pip install -e .

RUN pip freeze > /tmp/freeze.txt

# Additional system packages
RUN apt-get update && \
    apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1-mesa-glx && \
    rm -rf /var/lib/apt/lists/* && \
    git lfs install

# Install Gradio and related packages
RUN . .venv/bin/activate && \
    pip install --no-cache-dir gradio[oauth]==5.8.0 "uvicorn>=0.14.0" spaces

COPY --link --chown=1000 ./ /home/user/app
COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt