-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (45 loc) · 1.56 KB
/
Dockerfile
File metadata and controls
56 lines (45 loc) · 1.56 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
FROM node:20.9.0-alpine
WORKDIR /app
# Install dependencies for node-canvas
RUN apk add --no-cache \
build-base \
g++ \
make \
python3 \
git \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
pixman-dev \
freetype-dev
# Configure npm for better network handling and reduced connection issues
# maxsockets 1: Limits concurrent connections to prevent EventEmitter warnings
# fetch-retries 5: Retry failed downloads up to 5 times
# fetch-retry-*: Set timeout ranges for retries (20s min, 2min max)
RUN npm config set maxsockets 1 && \
npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000
# Configure Node.js environment variables
# max-old-space-size=4096: Increase heap memory to 4GB to prevent OOM during builds
# UV_THREADPOOL_SIZE=128: Increase thread pool for better I/O performance
ENV NODE_OPTIONS="--max-old-space-size=4096"
ENV UV_THREADPOOL_SIZE=128
# Configure npm to prefer prebuilt binaries over source compilation
# This helps avoid native compilation issues with tree-sitter and similar packages
ENV npm_config_build_from_source=false
ENV npm_config_cache=/tmp/.npm
# Copy package files for dependency installation
COPY package.json package-lock.json ./
# Install dependencies
# --maxsockets 1: Limit concurrent connections during install
RUN npm ci --audit-level=high --maxsockets 1
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Expose the port the app runs on
EXPOSE 3000
# Command to run the app
CMD ["npm", "start"]