-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (26 loc) · 930 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
# Initiate a container to build the application in.
FROM node:18-alpine as builder
ENV NODE_ENV=build
WORKDIR /usr/src/app
# Copy the package.json into the container.
COPY package*.json ./
# Install the dependencies required to build the application.
RUN npm install
# Copy the application source into the container.
COPY . .
# Build the application.
RUN npm run build
# Uninstall the dependencies not required to run the built application.
RUN npm prune --production
# Initiate a new container to run the application in.
FROM node:18-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
# Copy everything required to run the built application into the new container.
COPY --from=builder /usr/src/app/package*.json ./
COPY --from=builder /usr/src/app/node_modules/ ./node_modules/
COPY --from=builder /usr/src/app/dist/ ./dist/
# Expose the web server's port.
EXPOSE 3000
# Run the application.
CMD ["node", "dist/main"]