-
-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (44 loc) · 1.52 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (44 loc) · 1.52 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Build stage
FROM node:22-bookworm-slim AS builder
WORKDIR /app
# Install only native build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy package files first for better layer caching
COPY package.json package-lock.json ./
# Install ALL dependencies (including dev for build)
RUN npm ci
# Copy TypeScript config and source code
COPY tsconfig.json ./
COPY src/ ./src/
# Build the project
RUN npm run build
# Prune dev dependencies from the final image
RUN npm prune --omit=dev
# Runtime stage
FROM node:22-bookworm-slim AS runtime
WORKDIR /app
# Install dumb-init and ca-certificates for proper signal handling and HTTPS
RUN apt-get update && apt-get install -y --no-install-recommends \
dumb-init \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Set production environment
ENV NODE_ENV=production
# Set persistent home for the bot
ENV OPENCODE_TELEGRAM_HOME=/app/data
# Create data directories with correct ownership for node user
RUN mkdir -p /app/data/logs /app/data/run && \
chown -R node:node /app
# Copy built application and production dependencies from builder
COPY --from=builder --chown=node:node /app/dist ./dist
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
COPY --from=builder --chown=node:node /app/package.json ./package.json
# Run as non-root node user (uid 1000)
USER node
# Single dumb-init entrypoint
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "dist/index.js"]