File size: 1,951 Bytes
ffe59ba
 
 
 
 
 
d4ff4a4
 
 
 
 
 
 
 
 
 
4e0f10e
ffe59ba
 
 
d4ff4a4
 
 
 
 
 
ffe59ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Hugging Face Spaces image. Extends the official SIE server image, adds
# Node 22 for the UI server, and runs both processes from one container.
#
# This Dockerfile is HF Spaces specific. Local Docker users should use
# compose.yml (which just runs the unmodified upstream SIE image with the
# Node UI on the host).
#
# We use a multi-stage build to grab Node binaries from the official
# node:22-bookworm-slim image. HF Spaces' build sandbox restricts apt-key
# tmp-file writes, so installing Node via apt fails. Copy approach avoids
# apt entirely.

# --- stage 1: pull Node binaries ---
FROM node:22-bookworm-slim AS node

# --- stage 2: final image ---
FROM ghcr.io/superlinked/sie-server:latest-cpu-transformers5

USER root

# Copy Node 22 from the official image (no apt, no apt-key).
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
 && ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
 && node --version && npm --version

# HF Spaces' persistent storage lives at /data (50 GB free tier).
# Send the HuggingFace cache there so model weights survive Space restarts.
ENV HF_HOME=/data/.cache/huggingface

# UI server lives under /app/ui (the SIE base image already owns /app/...)
WORKDIR /app/ui

COPY package.json tsconfig.json ./
RUN npm install --silent

COPY src ./src
COPY web ./web
COPY data ./data

# Entrypoint script orchestrates both processes (SIE in background, UI in foreground).
COPY hf-entrypoint.sh /usr/local/bin/hf-entrypoint.sh
RUN chmod +x /usr/local/bin/hf-entrypoint.sh

# Make /app/ui world-readable so any HF Space user account can access it.
# Also make /data writable so the HF cache can be written there.
RUN chmod -R a+rx /app/ui && mkdir -p /data && chmod -R a+rwx /data

EXPOSE 7860

ENTRYPOINT ["/usr/local/bin/hf-entrypoint.sh"]