veltrixcode commited on
Commit
a0ad7c7
·
verified ·
1 Parent(s): 80c80f5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -9
Dockerfile CHANGED
@@ -1,19 +1,29 @@
1
- FROM node:20-slim
2
 
3
- # Create app directory
 
4
  WORKDIR /app
5
 
6
- # Install dependencies
7
- COPY package.json* ./
8
- RUN npm ci --omit=dev || npm install --omit=dev
9
 
10
- # Bundle app source
11
  COPY . .
 
 
 
 
12
 
13
- # Hugging Face Spaces expect the app to listen on $PORT
 
 
14
  ENV PORT=7860
15
 
16
- # Expose the port (for documentation only)
 
 
 
 
17
  EXPOSE 7860
18
 
19
- CMD ["npm", "start"]
 
 
1
 
2
+ FROM node:20-slim AS builder
3
+
4
  WORKDIR /app
5
 
6
+ # Install ALL deps (including dev) for the build step
7
+ COPY package.json package-lock.json* ./
8
+ RUN npm ci
9
 
10
+ # Copy source and build
11
  COPY . .
12
+ RUN npm run build
13
+
14
+ # --- Production image ---
15
+ FROM node:20-slim AS runner
16
 
17
+ WORKDIR /app
18
+
19
+ ENV NODE_ENV=production
20
  ENV PORT=7860
21
 
22
+ # Copy only what's needed to run
23
+ COPY --from=builder /app/public ./public
24
+ COPY --from=builder /app/.next/standalone ./
25
+ COPY --from=builder /app/.next/static ./.next/static
26
+
27
  EXPOSE 7860
28
 
29
+ CMD ["node", "server.js"]