pvyas96 commited on
Commit
4a40a3a
·
verified ·
1 Parent(s): 8a2f7bd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -18
Dockerfile CHANGED
@@ -1,31 +1,26 @@
1
- # Stage 1: Build the application
2
- FROM node:20-alpine AS builder
3
 
 
4
  WORKDIR /app
5
 
6
- # Copy package files first to leverage Docker cache for dependencies
7
  COPY package*.json ./
8
 
9
  # Install dependencies
10
  RUN npm install
11
 
12
- # Copy the rest of the application source code
 
 
 
13
  COPY . .
14
 
15
- # Build the application (outputs to /app/dist)
16
  RUN npm run build
17
 
18
- # Stage 2: Serve the application using Nginx
19
- FROM nginx:alpine
20
-
21
- # Remove default nginx static assets
22
- RUN rm -rf /usr/share/nginx/html/*
23
-
24
- # Copy the built React app from the builder stage to Nginx's serve directory
25
- COPY --from=builder /app/dist /usr/share/nginx/html
26
-
27
- # Expose port 80 to the outside world
28
- EXPOSE 80
29
 
30
- # Start Nginx
31
- CMD ["nginx", "-g", "daemon off;"]
 
1
+ # Use Node.js environment
2
+ FROM node:20-alpine
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Copy package files first (better caching)
8
  COPY package*.json ./
9
 
10
  # Install dependencies
11
  RUN npm install
12
 
13
+ # Install a simple static file server
14
+ RUN npm install -g serve
15
+
16
+ # Copy the rest of your application code
17
  COPY . .
18
 
19
+ # Build the React application (creates the 'dist' folder)
20
  RUN npm run build
21
 
22
+ # Expose port 7860 (Required by Hugging Face Spaces)
23
+ EXPOSE 7860
 
 
 
 
 
 
 
 
 
24
 
25
+ # Start the server on port 7860 serving the 'dist' folder
26
+ CMD ["serve", "-s", "dist", "-l", "7860"]