-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (23 loc) · 846 Bytes
/
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
# Stage 0, "build-stage", based on Node.js, to build and compile React
FROM node:20.18.0-alpine as build-stage
WORKDIR /app
# copy package.json and package-lock.json into workdir /app
COPY package*.json ./
RUN npm install
# copy all files from workspace into workdir /app
COPY . .
# run the build inside workdir /app with output path /app/build
RUN npm run build
# Stage 2, based on NodeJS, to have only the compiled app, ready for production
FROM node:20.18.0-alpine as serve-stage
WORKDIR /app
# copy dependency definitions
COPY --from=build-stage /app/package.json ./
# copy (build-stage)/app/dist in /app
COPY --from=build-stage /app/dist ./build
COPY --from=build-stage /app/server.js ./build/server.js
RUN npm install [email protected]
# Expose the port the app runs in
EXPOSE 5001
# Serve the app
CMD ["node","./build/server.js"]