-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (33 loc) · 1.09 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Step 1: Build the React application
FROM node:16 AS build
# Set the working directory
WORKDIR /app
# Copy the server package.json and package-lock.json
COPY package.json package-lock.json ./
# Install server dependencies
RUN npm install
# Copy the rest of the server application
COPY . .
# Change directory to the client and copy client package files
WORKDIR /app/client
COPY client/package.json client/package-lock.json ./
# Install client dependencies
RUN npm install
# Build the React app using Vite
RUN npm run build
# Step 2: Set up the production environment
FROM node:16-alpine AS production
# Set the working directory
WORKDIR /app
# Copy the server files
COPY --from=build /app /app
# Install serve to serve static files
RUN npm install -g serve
# Copy the build output to the web server's directory
RUN mkdir -p /app/client/build
COPY --from=build /app/client/dist /app/client/build
# Expose port 80 for the web server and port 9000 for the API server
EXPOSE 6000
EXPOSE 5346
# Start the server and serve the static files
CMD ["sh", "-c", "serve -s /app/client/build -l 4000 & node server.js"]