Skip to content

Commit df0fc91

Browse files
authored
[planner] Optimize nodejs final image size (#89)
## Summary Optimize nodejs final image size by getting rid of dev packages in the final image. I'm open to a better schema if postCommandHook is not the best way to go about it. Tried it on a fairly complex NodeJS web app: - size before: 837 MB - size after (with yarn): 519 MB - size after (with npm): 515 MB Sample planner output with yarn: ``` { "install_stage": { "command": "yarn install", "input_files": [ "package.json", "yarn.lock" ] }, "build_stage": { "command": "yarn build && yarn install --production --ignore-scripts --prefer-offline", "input_files": [ "." ], }, "start_stage": { "command": "yarn start", "input_files": [ "." ] }, "dev_packages": [ "nodejs", "yarn" ], "runtime_packages": [ "nodejs", "yarn" ] } ``` Sample planner output with npm: ``` "install_stage": { "command": "npm install", "input_files": [ "package.json" ] }, "build_stage": { "command": "npm prune --production", "input_files": [ "." ] }, "start_stage": { "command": "node index.js", "input_files": [ "." ] }, "dev_packages": [ "nodejs" ], "runtime_packages": [ "nodejs" ] ``` ## How was it tested? `devbox plan` `devbox build`
1 parent 6f434d3 commit df0fc91

File tree

7 files changed

+87
-451
lines changed

7 files changed

+87
-451
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Devbox currently detects the following languages:
143143

144144
- Go
145145
- Python (Poetry)
146+
- NodeJS
146147
- PHP
147148

148149
Want more languages? [Ask for a new Language](https://github.com/jetpack-io/devbox/issues) or contribute one via a Pull Request.

0 commit comments

Comments
 (0)