-
Notifications
You must be signed in to change notification settings - Fork 59
/
Dockerfile
58 lines (41 loc) · 1.27 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
# ? -------------------------
# ? 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 ./
# prisma
COPY ./prisma ./prisma
RUN npx prisma generate
# 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
COPY ./prisma ./prisma
RUN npx prisma generate
# ? -------------------------
# ? Runner: Production to run
# ? -------------------------
FROM node:18-alpine as runner
LABEL name "kaogeek-discord-bot"
USER node
ENV NODE_ENV production
# copy all files from layers above
COPY package.json ./
COPY --chown=node:node --from=deps-prod /app/node_modules ./node_modules
COPY --chown=node:node --from=deps-prod /app/prisma ./prisma
COPY --chown=node:node --from=builder /app/dist ./dist
COPY bot-config.example.toml ./
CMD ["dist/index.js"]
ARG APP_VERSION=unknown
ENV APP_VERSION=${APP_VERSION}