-
-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (30 loc) · 1.01 KB
/
Dockerfile
File metadata and controls
43 lines (30 loc) · 1.01 KB
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
# Build stage
FROM node:22-alpine AS builder
WORKDIR /bot
# Copy package files
COPY ./package.json /bot/package.json
COPY ./package-lock.json /bot/package-lock.json
# Install build dependencies and all dependencies (including devDependencies for building)
RUN apk add --no-cache python3 build-base
RUN npm ci
# Copy source code and build configuration
COPY ./src /bot/src
COPY ./tsconfig.json /bot/tsconfig.json
# Build the application
RUN npm run build
# Production stage
FROM node:22-alpine AS production
WORKDIR /bot
# Copy package files
COPY ./package.json /bot/package.json
COPY ./package-lock.json /bot/package-lock.json
# Install build dependencies for native modules
RUN apk add --no-cache python3 build-base
# Install only production dependencies
RUN npm ci --only=production && npm cache clean --force
# Copy built application from builder stage
COPY --from=builder /bot/build /bot/build
# Set NODE_ENV to production
ENV NODE_ENV=production
# Run the application
CMD ["npm", "run", "prod", "--prefix", "/bot"]