Skip to content

Commit

Permalink
Add memory detection to Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sierikov committed May 12, 2024
1 parent b59942a commit 72ff028
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ FROM node:lts-alpine AS build-stage
# Set environment variables for non-interactive npm installs
ENV NPM_CONFIG_LOGLEVEL warn
ENV CI true

# Detect available memory and set NODE_OPTIONS with buffer of 128MB
RUN memory=$(awk '/MemTotal/{print $2}' /proc/meminfo); \
memory=$((memory / 1024 / 1024)); \
node_options="--max-old-space-size=$((memory - 128))"; \
export NODE_OPTIONS="$node_options";

WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm i --frozen-lockfile
Expand Down

0 comments on commit 72ff028

Please sign in to comment.