-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Dockerfile
52 lines (41 loc) · 1.28 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
42
43
44
45
46
47
48
49
50
51
52
########################################
# First stage of multistage build
########################################
# Use Build image with label `builder
########################################
# use
FROM node:lts-alpine AS builder
# Setup working directory for project
WORKDIR /app
COPY ./package.json ./
COPY ./package-lock.json ./
COPY ./tsconfig.json ./
# install node modules
# use `npm ci` instead of `npm install`
# to install exact version from `package-lock.json`
RUN npm ci
# Copy project files
COPY src ./src
# Build project
RUN npm run build:ts
# sets environment to production
# and removes packages from devDependencies
RUN npm prune --production
########################################
# Second stage of multistage build
########################################
# Use other build image as the final one
# that won't have source codes
########################################
FROM node:lts-alpine
# Setup working directory for project
WORKDIR /app
# Copy published in previous stage binaries
# from the `builder` image
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
# Set URL that App will be exposed
EXPOSE 5000
# sets entry point command to automatically
# run application on `docker run`
ENTRYPOINT ["node", "./dist/index.js"]