diff --git a/DOCKER.md b/DOCKER.md index 404505e..75d10e3 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -103,6 +103,14 @@ RUN npm config set strict-ssl false && npm install This is necessary in some build environments with certificate validation issues. +### Out of Memory During Build + +The production build is memory-intensive (the app compiles thousands of modules). If `docker compose up` or `docker build` fails with an out-of-memory error such as `Reached heap limit` or `cannot allocate memory` during the `npm run build` step, increase the memory available to Docker: + +- **Docker Desktop**: Settings, then Resources, then Memory. Set it to at least **6-8 GB** and apply. + +The Dockerfile raises the Node heap (`NODE_OPTIONS=--max-old-space-size`) for the build. That heap size must fit inside the memory available to Docker, so raising the Docker memory limit is the fix when the build runs out of memory. + ### Container Not Starting Check the logs: diff --git a/package-lock.json b/package-lock.json index 2e2e1eb..86ad547 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,6 +86,7 @@ "@typescript-eslint/parser": "8.11.0", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "10.4.19", + "cross-env": "^7.0.3", "esbuild": "^0.28.0", "eslint": "^8.57.0", "eslint-config-prettier": "9.1.0", @@ -8363,6 +8364,25 @@ "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", "license": "MIT" }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/package.json b/package.json index 0fff4de..b3ff9af 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "tsc && cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build", "lint": "eslint -c .eslintrc.json ./src/**/**/*.{ts,tsx} --fix", "preview": "vite preview" }, @@ -88,6 +88,7 @@ "@typescript-eslint/parser": "8.11.0", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "10.4.19", + "cross-env": "^7.0.3", "esbuild": "^0.28.0", "eslint": "^8.57.0", "eslint-config-prettier": "9.1.0",