-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (27 loc) · 867 Bytes
/
Dockerfile
File metadata and controls
40 lines (27 loc) · 867 Bytes
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
FROM node:lts-alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
# Install dependencies
COPY package.json ./
RUN npm install
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npx tsc
RUN npm prune --omit=dev
# Production image, copy all the files and run
FROM base AS runner
WORKDIR /app
ARG IMAGE_USER=node
ARG IMAGE_GROUP=node
ARG IMAGE_USER_GROUP=$IMAGE_USER:$IMAGE_GROUP
COPY --from=builder --chown=$IMAGE_USER_GROUP /app/dist ./dist
COPY --from=builder --chown=$IMAGE_USER_GROUP /app/node_modules ./node_modules/
COPY --from=builder --chown=$IMAGE_USER_GROUP /app/package.json ./
RUN mkdir database && chown $IMAGE_USER database
ENV DATABASE_PATH=database/sqlite3.db
USER $IMAGE_USER
CMD ["node", "dist/discord/bot.js"]