-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDockerfile
63 lines (42 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM node:14.16.0-alpine As dependencies
WORKDIR /usr/src/app
COPY package*.json ./
# install dependencies
RUN npm install
FROM node:14.16.0-alpine as development
ARG APP_NAME
ENV APP_NAME ${APP_NAME}
# requirements
RUN apk update && apk add curl bash && rm -rf /var/cache/apk/*
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://gobinaries.com/tj/node-prune | bash -s -- -b /usr/local/bin
WORKDIR /usr/src/app
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
COPY . .
# build application
RUN npm link webpack && \
npm run build $APP_NAME
# run node prune
RUN /usr/local/bin/node-prune
# remove unused dependencies
RUN rm -rf node_modules/rxjs/src/
RUN rm -rf node_modules/rxjs/bundles/
RUN rm -rf node_modules/rxjs/_esm5/
RUN rm -rf node_modules/rxjs/_esm2015/
RUN rm -rf node_modules/swagger-ui-dist/*.map
FROM node:14.16.0-alpine as production
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /usr/src/app
# copy from build image
COPY --from=development /usr/src/app/dist ./dist
COPY --from=development /usr/src/app/node_modules ./node_modules
# required for migrations
COPY libs/orm-migrations/ libs/orm-migrations/
COPY ormconfig.js ./
# required for run
COPY entrypoints/ ./
COPY package.json ./
COPY tsconfig.json ./
EXPOSE 3000
CMD [ "/bin/sh", "run.sh" ]