-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
67 lines (45 loc) · 1.38 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
64
65
66
67
# Copied from https://github.com/kaogeek/kaogeek-discord-bot
# ? -------------------------
# ? Builder: Complile TypeScript to JS
# ? -------------------------
FROM node:20-alpine as builder
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN apk add python3 make gcc g++
# 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_modules that contains just production dependencies
# ? -------------------------
FROM node:20-alpine as deps-prod
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN apk add python3 make gcc g++
RUN npx pnpm -r i --frozen-lockfile --prod
COPY ./prisma ./prisma
RUN npx prisma generate
# ? -------------------------
# ? Runner: Production to run
# ? -------------------------
FROM node:20-alpine as runner
LABEL name "salim-bot"
USER node
ENV NODE_ENV production
ENV ENVIRONMENT PRODUCTION
# copy all files from layers above
COPY package.json ./
# runtime deps
COPY data ./data
# copy built files
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
CMD ["npm", "start"]