rockerritesh commited on
Commit
ecec7b5
·
verified ·
1 Parent(s): d2c6a5c

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +48 -29
Dockerfile CHANGED
@@ -1,41 +1,60 @@
1
- # syntax=docker/dockerfile:1.4
2
  #
3
- # HF Spaces shim: clones private GitHub source at build time using
4
- # a Space secret (GITHUB_TOKEN) and runs from there. This keeps the
5
- # actual source code private on GitHub while the Space runs publicly.
6
  #
7
- # Required HF Space secret:
8
- # GITHUB_TOKEN = a GitHub PAT with read access to
9
- # github.com/rockerritesh/sumit-mcp-server (private)
10
  #
11
- # See: https://huggingface.co/docs/hub/en/spaces-sdks-docker#buildtime
 
 
 
12
 
13
- FROM python:3.13-slim
 
 
 
 
 
 
 
 
 
 
14
 
15
- # Install uv + git
 
 
 
 
 
 
 
16
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
17
- RUN apt-get update && \
18
- apt-get install -y --no-install-recommends git ca-certificates && \
19
- rm -rf /var/lib/apt/lists/*
20
 
21
  WORKDIR /app
 
 
22
 
23
- # Clone private source using HF build-time secret
24
- RUN --mount=type=secret,id=GITHUB_TOKEN,required=true \
25
- GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) && \
26
- git clone --depth=1 --branch=main \
27
- "https://x-access-token:${GITHUB_TOKEN}@github.com/rockerritesh/sumit-mcp-server.git" \
28
- . && \
29
- git log -1 --pretty=format:"source: %H %s%n" > /app/BUILD_INFO
30
 
31
- # Install dependencies from the cloned project (locked)
32
- RUN --mount=type=cache,target=/root/.cache/uv \
33
- uv sync --locked
 
 
34
 
35
- # HF Spaces runtime expectations
36
- EXPOSE 7860
37
- ENV PORT=7860
38
- ENV UV_CACHE_DIR=/app/.cache/uv
39
- RUN mkdir -p /app/.cache/uv && chmod -R 777 /app/.cache
40
 
41
- CMD ["uv", "run", "sumit-mcp-server"]
 
 
 
 
1
+ # All-in-one Tatva deployment for a SINGLE Hugging Face Space.
2
  #
3
+ # Clones the private monorepo with a GitHub PAT (build secret GITHUB_TOKEN),
4
+ # builds the Next.js dashboard, installs the MCP server + FastAPI control plane,
5
+ # and runs all of them behind nginx on port 7860 via supervisord.
6
  #
7
+ # This file is self-contained (it clones rather than COPYs) so it can be the
8
+ # root Dockerfile of a thin HF Space the same pattern as `sumit-server`.
 
9
  #
10
+ # Build (local):
11
+ # echo -n "$GITHUB_PAT" | docker build -f deploy/Dockerfile \
12
+ # --secret id=GITHUB_TOKEN,src=/dev/stdin -t tatva-aio .
13
+ # HF Space: add a Space secret GITHUB_TOKEN; HF passes it as a build secret.
14
 
15
+ ARG REPO=github.com/rockerritesh/sumit-mcp-server.git
16
+
17
+ # ---------- stage 1: build the Next.js dashboard ----------
18
+ FROM node:20-slim AS web
19
+ ARG REPO
20
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
21
+ WORKDIR /src
22
+ RUN --mount=type=secret,id=GITHUB_TOKEN \
23
+ git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@${REPO} .
24
+ WORKDIR /src/portal/web
25
+ RUN npm install --legacy-peer-deps && npm run build
26
 
27
+ # ---------- stage 2: runtime (python + node + nginx + supervisor) ----------
28
+ FROM python:3.13-slim
29
+ ARG REPO
30
+ RUN apt-get update \
31
+ && apt-get install -y git nginx supervisor curl ca-certificates \
32
+ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
33
+ && apt-get install -y nodejs \
34
+ && rm -rf /var/lib/apt/lists/*
35
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
 
 
 
36
 
37
  WORKDIR /app
38
+ RUN --mount=type=secret,id=GITHUB_TOKEN \
39
+ git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@${REPO} .
40
 
41
+ # MCP server deps (repo root) + control-plane deps (portal/api)
42
+ ENV UV_CACHE_DIR=/app/.cache/uv
43
+ RUN uv sync --no-dev \
44
+ && cd portal/api && uv sync --no-dev
 
 
 
45
 
46
+ # Next.js standalone server from the build stage (tracing root pinned to web/,
47
+ # so server.js + node_modules sit at .next/standalone/).
48
+ COPY --from=web /src/portal/web/.next/standalone/ /app/portal/web/
49
+ COPY --from=web /src/portal/web/.next/static /app/portal/web/.next/static
50
+ COPY --from=web /src/portal/web/public /app/portal/web/public
51
 
52
+ # Process + proxy config (from the cloned repo)
53
+ RUN cp deploy/nginx.conf /etc/nginx/nginx.conf \
54
+ && cp deploy/supervisord.conf /etc/supervisor/conf.d/tatva.conf \
55
+ && mkdir -p /app/.cache && chmod -R 777 /app/.cache
 
56
 
57
+ # Control-plane + MCP read all other config (MONGO_URI, JWT_SECRET, QDRANT_*,
58
+ # PLATFORM_ADMINS, STRIPE_*) from Space secrets injected as env vars at runtime.
59
+ EXPOSE 7860
60
+ CMD ["supervisord", "-c", "/etc/supervisor/conf.d/tatva.conf"]