-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (31 loc) · 901 Bytes
/
Dockerfile
File metadata and controls
40 lines (31 loc) · 901 Bytes
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
# ONLY FOR RELEASE, NOT FOR CI/CD. WE CANNOT RUN TESTS FOR THIS BUILD
# Base
FROM node:12.20.0-alpine3.12 AS base
LABEL Name="cart-api"
LABEL Version="1.0"
WORKDIR /app
# Build Dependencies
FROM base AS build_dependencies
COPY package*.json ./
RUN npm install
# We cannot install only prod dependancies for the project. Otherwise the build will not be successful
# There is no need to clear npm cache for this stage
# Release Dependencies
FROM base AS release_dependencies
COPY package*.json ./
RUN npm install --only=prod
# There is no need to clear npm cache for this stage
# Build
FROM build_dependencies AS build
COPY tsconfig*.json ./
COPY src src
RUN npm run build
# Release
FROM base AS release
COPY --from=build /app/dist ./dist
COPY --from=release_dependencies /app/node_modules ./node_modules
USER node
ENV PORT=8080
ENV NODE_ENV=production
EXPOSE 8080
CMD ["node", "dist/main.js"]