-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (30 loc) · 949 Bytes
/
Dockerfile
File metadata and controls
45 lines (30 loc) · 949 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
41
42
43
44
45
### Dockerfile with multi-stage build ###
# used node-version
ARG NODE_VERSION=18
## stage 1, compile TypeScript
FROM node:${NODE_VERSION} AS builder
WORKDIR "/usr/src/app"
## needed to avoid error while build
ENV NODE_OPTIONS="--max-old-space-size=1024"
COPY package*.json ./
COPY tsconfig*.json ./
COPY .eslintrc.json ./
COPY .eslintignore ./
COPY ./src ./src
COPY ./workshops ./workshops
## update npm to latest version
RUN npm install --location=global npm@latest
RUN npm ci --silent && npm run build
## stage 2, runnnig service
FROM node:${NODE_VERSION}-slim as final
WORKDIR "/app"
ENV NODE_ENV=production
ENV SERVICE_PORT=8065
COPY package*.json ./
## update npm to latest version
RUN npm install --location=global npm@latest
RUN npm ci --silent --only=${NODE_ENV}
## copy compiled files from stage 1
COPY --from=builder /usr/src/app/dist ./dist
CMD ["node", "/app/dist/server.js"]
EXPOSE ${SERVICE_PORT}