document-ocr / Dockerfile
Filip Makraduli
Switch to transformers5 SIE image; LightOnOCR as default recognition
4e0f10e
# 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"]