Spaces:
Running
Running
File size: 2,651 Bytes
fd5dd94 f4200e4 fd5dd94 | 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 | # syntax=docker/dockerfile:1.7
# WorkPilot as ONE container for a Hugging Face Docker Space (a public demo).
#
# A Space exposes a single port (7860) and has no persistent disk, so everything runs here:
# embedded Postgres 16 + pgvector (pgserver), migrated and seeded with the demo tenant on
# every start -> API (127.0.0.1:8000) + DBOS worker -> Next.js on :7860, which forwards
# /backend/* to the API (web/next.config.ts, WP_BACKEND_PROXY).
# deploy/hf/start.py supervises the processes. Model keys come from Space secrets.
# Build context: the repository root (the publish workflow copies this file to /Dockerfile).
# ---- web: Next.js standalone build, API reached through the same origin -----------------
FROM node:24-bookworm-slim AS web
WORKDIR /web
COPY web/package.json web/package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY web/ ./
# web/public may be empty, and empty folders are not uploaded to the Space.
RUN mkdir -p public
ENV NEXT_OUTPUT=standalone \
NEXT_TELEMETRY_DISABLED=1 \
NEXT_PUBLIC_API_URL=/backend \
WP_BACKEND_PROXY=http://127.0.0.1:8000
RUN npm run build
# ---- python: the app + LLM providers + embedded Postgres -------------------------------
FROM python:3.12-slim-bookworm AS py
ENV PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
RUN python -m venv /opt/venv
ENV PATH=/opt/venv/bin:$PATH
WORKDIR /app
COPY pyproject.toml README.md ./
COPY core ./core
COPY packs ./packs
COPY evals ./evals
COPY mcp_servers ./mcp_servers
# hadolint ignore=DL3013
RUN pip install --no-cache-dir ".[llm]" "pgserver>=0.1.4"
# ---- runtime ---------------------------------------------------------------------------
FROM python:3.12-slim-bookworm
# libstdc++6: the node binary's runtime; libgomp1: LightGBM if it is ever added.
RUN apt-get update \
&& apt-get install -y --no-install-recommends libstdc++6 libgomp1 \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --create-home --uid 1000 user
COPY --from=web /usr/local/bin/node /usr/local/bin/node
COPY --from=py /opt/venv /opt/venv
WORKDIR /app
COPY alembic.ini ./
COPY alembic ./alembic
COPY core ./core
COPY packs ./packs
COPY evals ./evals
COPY mcp_servers ./mcp_servers
COPY deploy/scripts ./deploy/scripts
COPY deploy/hf ./deploy/hf
COPY --from=web /web/.next/standalone ./web
COPY --from=web /web/.next/static ./web/.next/static
COPY --from=web /web/public ./web/public
# Hugging Face runs the container as uid 1000; Postgres refuses to run as root anyway.
USER user
ENV PATH=/opt/venv/bin:$PATH \
PYTHONPATH=/app \
PYTHONUNBUFFERED=1 \
HOME=/home/user \
WP_ENV=production
EXPOSE 7860
CMD ["python", "deploy/hf/start.py"]
|