-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (50 loc) · 1.49 KB
/
Dockerfile
File metadata and controls
64 lines (50 loc) · 1.49 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
62
63
64
# Multi-stage build for whatsapp-web.js API server
# Supports both arm64 (Apple Silicon) and amd64 (Intel) architectures
FROM node:20-alpine AS builder
WORKDIR /app
# Install build dependencies for better-sqlite3 compilation
RUN apk add --no-cache \
python3 \
make \
g++ \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev
# Copy package files
COPY package*.json ./
# Install dependencies (use npm install for flexibility; Docker has enough space/time)
# Skip Puppeteer download since we'll use system Chromium
RUN PUPPETEER_SKIP_DOWNLOAD=true npm install
# Final stage
FROM node:20-alpine
WORKDIR /app
# Install runtime dependencies (Chromium/Puppeteer, cairo for QR code rendering)
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
cairo \
jpeg \
pango \
giflib
# Copy built node_modules from builder
COPY --from=builder /app/node_modules ./node_modules
# Copy app source files
COPY . .
# Create directories for connection session and message persistence
RUN mkdir -p sessions data && \
chmod 755 sessions data
EXPOSE 3000
# Set environment defaults for Docker
ENV NODE_ENV=production \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
UI_CREDENTIALS=${UI_CREDENTIALS:-} \
SESSION_SECRET=${SESSION_SECRET:-docker-default-secret-change-in-prod} \
REDIS_URL=${REDIS_URL:-} \
RATE_LIMIT_PER_MINUTE=${RATE_LIMIT_PER_MINUTE:-120}
# Start server
CMD ["node", "server.js"]