Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +13 -18
Dockerfile
CHANGED
|
@@ -1,31 +1,26 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM node:20-alpine
|
| 3 |
|
|
|
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Copy package files first
|
| 7 |
COPY package*.json ./
|
| 8 |
|
| 9 |
# Install dependencies
|
| 10 |
RUN npm install
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
| 13 |
COPY . .
|
| 14 |
|
| 15 |
-
# Build the application (
|
| 16 |
RUN npm run build
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 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
|
| 31 |
-
CMD ["
|
|
|
|
| 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"]
|