-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (36 loc) · 1.31 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
# ---------------------------------------------------------------------------
# Image Build
# ---------------------------------------------------------------------------
# 1st Stage for installing dependencies (fail as fast as possible when having issues)
FROM node:16.10 AS build-deps
COPY package*.json tsconfig*.json /build/
WORKDIR /build
RUN npm ci
# 2nd Stage for compiling typescript
FROM node:16.10 AS compile-env
RUN mkdir /compile
COPY --from=build-deps /build /compile
WORKDIR /compile
# Copy a rest of stuff needed for building
COPY src src/
# put your npm script to compile typescript
RUN npm run build
# 3rd Stage for installing runtime dependencies
FROM node:16.10 AS runtime-deps
COPY package*.json tsconfig*.json /build/
WORKDIR /build
RUN npm ci --production
# ---------------------------------------------------------------------------
# Image Creation
# ---------------------------------------------------------------------------
FROM node:16.10-alpine AS runtime-env
WORKDIR /app
# copy compiled artifacts from compile-env
COPY --from=compile-env --chown=node:node /compile/dist /app
# copy production dependencies
COPY --from=runtime-deps --chown=node:node /build /app
# copy config/ folder if you are using node-config
# COPY --chown=node:node config /app/config
USER node
# EXPOSE 8000
CMD ["npm", "run", "start"]