File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- FROM node:20-slim
1+ # ---------- BUILD STAGE ----------
2+ FROM node:20-slim AS builder
3+
4+ WORKDIR /app
25
6+ # Install build deps only for native modules
37RUN apt-get update && apt-get install -y \
4- build-essential cmake python3 make gcc g++ \
8+ build-essential \
9+ python3 \
10+ make \
11+ gcc \
12+ g++ \
13+ cmake \
514 && rm -rf /var/lib/apt/lists/*
615
7- WORKDIR /app
16+ # Copy only package files first (better cache)
817COPY package*.json ./
9- RUN npm install --omit=dev
18+
19+ # Use npm ci for faster + reproducible builds
20+ RUN npm ci --omit=dev
21+
22+ # Copy source after deps (max cache efficiency)
1023COPY . .
11- CMD ["node" , "--optimize-for-size" , "--max-old-space-size=512" , "bot.js" ]
24+
25+ # ---------- RUNTIME STAGE ----------
26+ FROM node:20-slim
27+
28+ WORKDIR /app
29+
30+ # Install tini (important for child process cleanup)
31+ RUN apt-get update && apt-get install -y tini \
32+ && rm -rf /var/lib/apt/lists/*
33+
34+ # Copy node_modules + app from builder
35+ COPY --from=builder /app /app
36+
37+ # Production env
38+ ENV NODE_ENV=production
39+ ENV NODE_OPTIONS="--max-old-space-size=512 --optimize-for-size"
40+
41+ # Use tini as PID 1 to properly reap worker processes
42+ ENTRYPOINT ["/usr/bin/tini" , "--" ]
43+
44+ CMD ["node" , "bot.js" ]
You can’t perform that action at this time.
0 commit comments