File size: 2,430 Bytes
d14041c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM node:22-bookworm-slim AS frontend-builder

WORKDIR /app/studio/frontend

# Install dependencies first for better layer caching.
COPY studio/frontend/package.json studio/frontend/bun.lock ./
RUN npm install -g npm@latest && npm install

COPY studio/frontend/ ./
RUN npm run build


FROM python:3.12-slim AS runtime

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME=/data/.huggingface \
    PORT=7860

WORKDIR /app

# Build/runtime dependencies needed by the Unsloth stack.
RUN apt-get update && apt-get install -y --no-install-recommends \
    bash \
    build-essential \
    cmake \
    curl \
    ffmpeg \
    git \
    libsndfile1 \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies in the same order as setup.sh.
COPY studio/backend/requirements /app/studio/backend/requirements
RUN set -eux; \
    REQ_ROOT=/app/studio/backend/requirements; \
    SINGLE_ENV_CONSTRAINTS="$REQ_ROOT/single-env/constraints.txt"; \
    pip install --upgrade pip; \
    pip install --no-cache-dir -c "$SINGLE_ENV_CONSTRAINTS" -r "$REQ_ROOT/base.txt"; \
    pip install --no-cache-dir -c "$SINGLE_ENV_CONSTRAINTS" -r "$REQ_ROOT/extras.txt"; \
    pip install --force-reinstall --no-cache-dir -c "$SINGLE_ENV_CONSTRAINTS" -r "$REQ_ROOT/overrides.txt"; \
    pip install --no-deps --no-cache-dir -r "$REQ_ROOT/triton-kernels.txt"; \
    LLAMA_CPP_DST="$(pip show unsloth-zoo | awk '/^Location:/{print $2}')/unsloth_zoo/llama_cpp.py"; \
    curl -fsSL "https://raw.githubusercontent.com/unslothai/unsloth-zoo/refs/heads/main/unsloth_zoo/llama_cpp.py" -o "$LLAMA_CPP_DST"; \
    VISION_DST="$(pip show unsloth | awk '/^Location:/{print $2}')/unsloth/models/vision.py"; \
    curl -fsSL "https://raw.githubusercontent.com/unslothai/unsloth/80e0108a684c882965a02a8ed851e3473c1145ab/unsloth/models/vision.py" -o "$VISION_DST"; \
    pip install --no-cache-dir -c "$SINGLE_ENV_CONSTRAINTS" -r "$REQ_ROOT/studio.txt"; \
    pip install --no-cache-dir -c "$SINGLE_ENV_CONSTRAINTS" -r "$REQ_ROOT/single-env/data-designer-deps.txt"; \
    pip install --no-cache-dir --no-deps -c "$SINGLE_ENV_CONSTRAINTS" -r "$REQ_ROOT/single-env/data-designer.txt"; \
    python "$REQ_ROOT/single-env/patch_metadata.py"; \
    pip check

COPY . /app
COPY --from=frontend-builder /app/studio/frontend/dist /app/studio/frontend/dist

RUN chmod +x /app/docker/start.sh

EXPOSE 7860

CMD ["/app/docker/start.sh"]