Spaces:
Paused
Paused
Lenson commited on
Commit ·
cc7d19f
1
Parent(s): f322e04
feat: add Dockerfile for HF Spaces
Browse files- Dockerfile +46 -0
Dockerfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:20-slim
|
| 2 |
+
|
| 3 |
+
# curl: needed by setup-curl.ts and full-update.ts
|
| 4 |
+
# unzip: needed by full-update.ts to extract Codex.app
|
| 5 |
+
# gosu: needed by entrypoint to drop from root to node user
|
| 6 |
+
RUN apt-get update && \
|
| 7 |
+
apt-get install -y --no-install-recommends curl unzip ca-certificates gosu && \
|
| 8 |
+
rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
# 1) Backend deps (postinstall runs tsx scripts/setup-curl.ts)
|
| 13 |
+
COPY package*.json tsconfig.json ./
|
| 14 |
+
COPY scripts/ scripts/
|
| 15 |
+
RUN npm ci
|
| 16 |
+
|
| 17 |
+
# Fail fast if curl-impersonate wasn't downloaded
|
| 18 |
+
RUN test -f bin/curl-impersonate || \
|
| 19 |
+
(echo "FATAL: curl-impersonate not downloaded. Check network." && exit 1)
|
| 20 |
+
|
| 21 |
+
# 2) Web deps (separate layer for cache efficiency)
|
| 22 |
+
COPY web/package*.json web/
|
| 23 |
+
RUN cd web && npm ci
|
| 24 |
+
|
| 25 |
+
# 3) Copy source
|
| 26 |
+
COPY . .
|
| 27 |
+
|
| 28 |
+
# 4) Build frontend (Vite → public/) + backend (tsc → dist/)
|
| 29 |
+
RUN cd web && npm run build && cd .. && npx tsc
|
| 30 |
+
|
| 31 |
+
# 5) Prune dev deps, re-add tsx (needed at runtime by update-checker fork())
|
| 32 |
+
RUN npm prune --omit=dev && npm install --no-save tsx
|
| 33 |
+
|
| 34 |
+
EXPOSE 7860
|
| 35 |
+
|
| 36 |
+
# Ensure data dir exists in the image (bind mount may override at runtime)
|
| 37 |
+
RUN mkdir -p /app/data
|
| 38 |
+
|
| 39 |
+
COPY .hf/setup.sh /usr/local/bin/setup.sh
|
| 40 |
+
RUN chmod +x /usr/local/bin/setup.sh
|
| 41 |
+
|
| 42 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
| 43 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 44 |
+
|
| 45 |
+
ENTRYPOINT ["/usr/local/bin/setup.sh"]
|
| 46 |
+
CMD []
|