sitcod3 commited on
Commit
d736cc9
·
verified ·
1 Parent(s): 92bdf93

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +46 -30
Dockerfile CHANGED
@@ -1,30 +1,46 @@
1
- ARG CACHE_BUST=1
2
- FROM node:22-slim AS builder
3
- WORKDIR /app
4
- COPY package*.json ./
5
- # Lockfile generated on Windows pins win32-only optional native deps (rollup),
6
- # which breaks Linux builds — npm/cli bug #4828. Remove and resolve fresh.
7
- RUN rm -f package-lock.json && npm install --prefer-offline --no-audit --no-fund --no-cache
8
- COPY . .
9
- RUN npm run build --if-present
10
-
11
- FROM node:22-slim
12
- WORKDIR /app
13
- COPY --from=builder /app/dist ./dist
14
- COPY --from=builder /app/package.json ./package.json
15
- RUN npm install --prefer-offline --no-audit --no-fund --no-cache --omit=dev
16
-
17
- # Hugging Face exposes port 7860
18
- ENV PORT=7860
19
- ENV NODE_ENV=production
20
- EXPOSE 7860
21
-
22
- CMD ["npm", "start"]
23
-
24
- # FORCE REBUILD 1789683004
25
-
26
- # FORCE REBUILD 1789683497
27
-
28
- # FORCE REBUILD 1789684079
29
-
30
- # FORCE REBUILD 1789684845
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ---- Stage 1: Build ----
2
+ # Mirrors BRIDGE Modul-E's proven HF pattern (node:20-alpine).
3
+ FROM node:20-alpine AS builder
4
+ WORKDIR /app
5
+
6
+ # Vite bakes VITE_* vars in at BUILD time — pass them as build args.
7
+ # Empty values keep the demo fallback UI.
8
+ ARG VITE_SUPABASE_URL=""
9
+ ARG VITE_SUPABASE_ANON_KEY=""
10
+ ARG VITE_API_URL=""
11
+ ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL \
12
+ VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY \
13
+ VITE_API_URL=$VITE_API_URL
14
+
15
+ # Install dependencies first (layer caching).
16
+ # NOTE: only package.json is copied (no lockfile): the Windows-generated
17
+ # lockfile pins win32-only optional native deps (rollup) which break Linux
18
+ # builds — npm/cli bug #4828. Dependencies resolve fresh on Alpine/musl.
19
+ COPY package.json ./
20
+ RUN npm install --no-audit --no-fund
21
+
22
+ # Copy source and build frontend + bundle server (dist/server.cjs).
23
+ COPY . .
24
+ RUN npm run build
25
+
26
+ # ---- Stage 2: Production ----
27
+ FROM node:20-alpine AS production
28
+ WORKDIR /app
29
+
30
+ # HF Spaces routes to 7860 — the server MUST default to it (see server.ts).
31
+ ENV NODE_ENV=production \
32
+ PORT=7860
33
+
34
+ # Install production-only dependencies (esbuild, vitest, typescript excluded).
35
+ COPY package.json ./
36
+ RUN npm install --omit=dev && npm cache clean --force
37
+
38
+ # Copy the built output from builder stage.
39
+ COPY --from=builder /app/dist ./dist
40
+
41
+ EXPOSE 7860
42
+
43
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
44
+ CMD wget -qO- http://127.0.0.1:7860/api/health >/dev/null 2>&1 || exit 1
45
+
46
+ CMD ["node", "dist/server.cjs"]