mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 21:37:11 -04:00
Add memory detection to Dockerfile
This commit is contained in:
parent
b59942ad9f
commit
72ff02881c
1 changed files with 7 additions and 0 deletions
|
@ -3,6 +3,13 @@ FROM node:lts-alpine AS build-stage
|
||||||
# Set environment variables for non-interactive npm installs
|
# Set environment variables for non-interactive npm installs
|
||||||
ENV NPM_CONFIG_LOGLEVEL warn
|
ENV NPM_CONFIG_LOGLEVEL warn
|
||||||
ENV CI true
|
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
|
WORKDIR /app
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN npm install -g pnpm && pnpm i --frozen-lockfile
|
RUN npm install -g pnpm && pnpm i --frozen-lockfile
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue