Add memory detection to Dockerfile
This commit is contained in:
		
							parent
							
								
									b59942ad9f
								
							
						
					
					
						commit
						72ff02881c
					
				| @ -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 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user