Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +31 -25
Dockerfile
CHANGED
@@ -1,25 +1,31 @@
|
|
1 |
-
# Use an official Node.js runtime as a parent image
|
2 |
-
FROM node:16 as builder
|
3 |
-
|
4 |
-
# Set the working directory
|
5 |
-
WORKDIR /app
|
6 |
-
|
7 |
-
# Copy package.json and install dependencies
|
8 |
-
COPY package
|
9 |
-
RUN npm install
|
10 |
-
|
11 |
-
# Copy the rest of the application code
|
12 |
-
COPY . .
|
13 |
-
|
14 |
-
# Build the React app
|
15 |
-
RUN npm run build
|
16 |
-
|
17 |
-
# Use an Nginx image to serve the built app
|
18 |
-
FROM nginx:alpine
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
#
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Node.js runtime as a parent image
|
2 |
+
FROM node:16 as builder
|
3 |
+
|
4 |
+
# Set the working directory
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Copy package.json and install dependencies
|
8 |
+
COPY package*.json ./
|
9 |
+
RUN npm install
|
10 |
+
|
11 |
+
# Copy the rest of the application code
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
# Build the React app
|
15 |
+
RUN npm run build
|
16 |
+
|
17 |
+
# Use an Nginx image to serve the built app
|
18 |
+
FROM nginx:alpine
|
19 |
+
|
20 |
+
# Fix permissions for /var/cache/nginx
|
21 |
+
USER root
|
22 |
+
RUN mkdir -p /var/cache/nginx && chmod -R 777 /var/cache/nginx
|
23 |
+
|
24 |
+
# Copy built React files
|
25 |
+
COPY --from=builder /app/build /usr/share/nginx/html
|
26 |
+
|
27 |
+
# Expose port 80
|
28 |
+
EXPOSE 80
|
29 |
+
|
30 |
+
# Start Nginx
|
31 |
+
CMD ["nginx", "-g", "daemon off;"]
|