-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
52 lines (36 loc) · 1007 Bytes
/
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
# 1
FROM node:lts AS build-deps
RUN apt-get update && \
apt-get -y install tree
COPY package*.json /build/
COPY src/modules /build/modules
RUN find /build/modules \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
RUN tree /build/
WORKDIR /build
RUN npm install
# 2
FROM node:lts AS compile-env
RUN mkdir /compile
COPY --from=build-deps /build /compile
WORKDIR /compile
COPY . .
RUN npm run build
# 3
FROM node:lts AS runtime-deps
COPY package*.json /build/
COPY src/modules /build/modules
RUN find /build/modules \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
WORKDIR /build
RUN npm install --production
# final
FROM node:lts-alpine AS runtime-env
WORKDIR /app
ARG BOT_VERSION
ENV BOT_VERSION=$BOT_VERSION \
NODE_ENV=production \
TZ=Asia/Jakarta
RUN apk add tzdata \
&& rm -rf /var/cache/apk/*
COPY --from=compile-env --chown=node:node /compile/dist /app
COPY --from=runtime-deps --chown=node:node /build /app
CMD ["node", "bot.js"]