forked from kaogeek/kaogeek-discord-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (32 loc) · 1.06 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
# ? -------------------------
# ? Builder: Complile TypeScript to JS
# ? -------------------------
FROM node:18-alpine as builder
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
# no need to waste time installing pnpm globally, we only using it once
RUN npx pnpm -r i --frozen-lockfile
# copy sources
COPY src ./src
COPY tsconfig.json ./
# compile
RUN npx pnpm build
# ? -------------------------
# ? Deps-prod: Obtaining node_moules that contains just production dependencies
# ? -------------------------
FROM node:18-alpine as deps-prod
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN npx pnpm -r i --frozen-lockfile --prod
# ? -------------------------
# ? Runner: Production to run
# ? -------------------------
FROM gcr.io/distroless/nodejs18-debian11:nonroot as runner
LABEL name "kaogeek-discord-bot"
USER nonroot
ENV NODE_ENV production
# copy all files from layers above
COPY package.json ./
COPY --chown=nonroot:nonroot --from=deps-prod /app/node_modules ./node_modules
COPY --chown=nonroot:nonroot --from=builder /app/dist ./dist
CMD ["dist/client.js"]