Skip to content

Commit 72ff028

Browse files
committed
Add memory detection to Dockerfile
1 parent b59942a commit 72ff028

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ FROM node:lts-alpine AS build-stage
33
# Set environment variables for non-interactive npm installs
44
ENV NPM_CONFIG_LOGLEVEL warn
55
ENV CI true
6+
7+
# Detect available memory and set NODE_OPTIONS with buffer of 128MB
8+
RUN memory=$(awk '/MemTotal/{print $2}' /proc/meminfo); \
9+
memory=$((memory / 1024 / 1024)); \
10+
node_options="--max-old-space-size=$((memory - 128))"; \
11+
export NODE_OPTIONS="$node_options";
12+
613
WORKDIR /app
714
COPY package.json pnpm-lock.yaml ./
815
RUN npm install -g pnpm && pnpm i --frozen-lockfile

0 commit comments

Comments
 (0)