Shih-hungg commited on
Commit
0c86b26
·
1 Parent(s): 1411fe8
Files changed (1) hide show
  1. Dockerfile +13 -13
Dockerfile CHANGED
@@ -1,26 +1,26 @@
1
- # Use the official Node.js 18 image
2
  FROM node:20-alpine
3
 
4
- # Set the working directory
5
  WORKDIR /app
6
 
7
- # Copy package files
 
 
 
8
  COPY package*.json ./
9
 
10
- # Install production dependencies (TypeScript is now in production deps)
11
- RUN npm ci
12
 
13
- # Copy the rest of the application
14
  COPY . .
15
 
16
- # Build the Next.js application
17
- RUN npx next build
18
-
19
- # # Remove dev dependencies to reduce image size
20
- # RUN npm prune --production
21
 
22
- # Expose Hugging Face default port
23
  EXPOSE 7860
24
 
25
  # Start Next.js on port 7860
26
- CMD ["npx", "next", "start", "-p", "7860"]
 
1
+ # Use Node.js 20 (LTS) on Alpine for small image size
2
  FROM node:20-alpine
3
 
4
+ # Set working directory inside container
5
  WORKDIR /app
6
 
7
+ # Upgrade npm first (fixes "Exit handler never called!" bug)
8
+ RUN npm install -g npm@11.6.0
9
+
10
+ # Copy package files (for dependency install layer)
11
  COPY package*.json ./
12
 
13
+ # Install dependencies (include devDependencies for build step)
14
+ RUN npm install --legacy-peer-deps
15
 
16
+ # Copy the rest of the source code
17
  COPY . .
18
 
19
+ # Build Next.js application
20
+ RUN npm run build
 
 
 
21
 
22
+ # Expose Hugging Face Spaces default port
23
  EXPOSE 7860
24
 
25
  # Start Next.js on port 7860
26
+ CMD ["npm", "start", "--", "-p", "7860"]