Hanzo Dev commited on
Commit
b84e508
·
1 Parent(s): de85526

fix: Simplify Dockerfile for HF Spaces compatibility

Browse files

- Use single-stage build for simplicity
- Use Node.js 18 for better compatibility
- Ensure production=false for build dependencies
- Add NEXT_TELEMETRY_DISABLED env var
- Create public directory explicitly

Files changed (1) hide show
  1. Dockerfile +9 -18
Dockerfile CHANGED
@@ -1,33 +1,23 @@
1
- # Build stage
2
- FROM node:20-alpine AS builder
3
 
 
4
  WORKDIR /app
5
 
6
  # Copy package files
7
  COPY package*.json ./
8
 
9
- # Install dependencies with legacy peer deps
10
- # Using npm install instead of ci for better compatibility
11
- RUN npm install --legacy-peer-deps
12
 
13
- # Copy all files
14
  COPY . .
15
 
16
  # Build the Next.js application
17
  RUN npm run build
18
 
19
- # Production stage
20
- FROM node:20-alpine AS runner
21
-
22
- WORKDIR /app
23
-
24
- # Copy necessary files from builder
25
- COPY --from=builder /app/package*.json ./
26
- COPY --from=builder /app/.next ./.next
27
- COPY --from=builder /app/node_modules ./node_modules
28
-
29
- # Copy public directory if it exists
30
- COPY --from=builder /app/public* ./public/
31
 
32
  # Expose port 7860 for Hugging Face Spaces
33
  EXPOSE 7860
@@ -36,6 +26,7 @@ EXPOSE 7860
36
  ENV NODE_ENV=production
37
  ENV PORT=7860
38
  ENV HOSTNAME=0.0.0.0
 
39
 
40
  # Start the application
41
  CMD ["npm", "start"]
 
1
+ # Single stage build for Hugging Face Spaces
2
+ FROM node:18-alpine
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
  # Copy package files
8
  COPY package*.json ./
9
 
10
+ # Install dependencies with legacy peer deps to avoid conflicts
11
+ RUN npm install --legacy-peer-deps --production=false
 
12
 
13
+ # Copy all application files
14
  COPY . .
15
 
16
  # Build the Next.js application
17
  RUN npm run build
18
 
19
+ # Create public directory if it doesn't exist
20
+ RUN mkdir -p public
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Expose port 7860 for Hugging Face Spaces
23
  EXPOSE 7860
 
26
  ENV NODE_ENV=production
27
  ENV PORT=7860
28
  ENV HOSTNAME=0.0.0.0
29
+ ENV NEXT_TELEMETRY_DISABLED=1
30
 
31
  # Start the application
32
  CMD ["npm", "start"]