I am curious if anyone else has been running into this while running building a custom Reaction docker image with docker build.
I am unable to reproduce this issue with a fresh reaction install. However, my custom app which includes an additional dozen or so npm packages and lots of additional code in /imports/plugins/custom/ no longer succeeds when running docker build. It does however successfully generate a tar ball when running meteor build.
I've been following this related issue and the suggestion to remove standard-minifiers-js or use abernix:[email protected] does not have an effect. In fact, the error message varies greatly in the stack trace as to where it hit memory issues.
Here is a sample of the error:
<--- Last few GCs --->
347149 ms: Mark-sweep 1387.2 (1457.1) -> 1387.8 (1457.1) MB, 1402.8 / 0 ms [allocation failure] [GC in old space requested].
348463 ms: Mark-sweep 1387.8 (1457.1) -> 1391.0 (1457.1) MB, 1515.8 / 0 ms [allocation failure] [GC in old space requested].
350069 ms: Mark-sweep 1391.0 (1457.1) -> 1382.3 (1457.1) MB, 1605.7 / 0 ms [last resort gc].
351539 ms: Mark-sweep 1382.3 (1457.1) -> 1386.8 (1457.1) MB, 1470.5 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1867241b4629 <JS Object>
1: def_function [0x1867241041b9 <undefined>:~3517] [pc=0x2972eb9453c5] (this=0x18eea5efc0a1 <an AST_Function with map 0x120175a62fb1>,symbol=0x8848be30a79 <an AST_SymbolDefun with map 0x3c70d8c56851>)
2: visit [0x1867241041b9 <undefined>:~3317] [pc=0x2972eb938507] (this=0x2e939bded2e9 <a TreeWalker with map 0x3c70d8c0b061>,node=0x8848be30a79 <an AST_SymbolDefun with map 0x3c70d8c56851>,...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
/opt/build_scripts/build-meteor.sh: line 30: 285 Aborted meteor build --directory $APP_BUNDLE_DIR
The command '/bin/sh -c cd $APP_SOURCE_DIR && bash $BUILD_SCRIPTS_DIR/build-meteor.sh && bash $BUILD_SCRIPTS_DIR/post-build-cleanup.sh' returned a non-zero code: 134
Node: 4.8.1
NPM: 4.5.0
Docker: 1.13.1
Reaction CLI: 0.8.0
Reaction: 1.1.1
Reaction Branch: development
Since running meteor build does succeed where as docker build fails consistently with errors like the above I wondering where to look for a solution, perhaps in reaction:base? @jshimko
Hey @owenhoskins. Sorry this issue kind of fell through the cracks.
I coincidentally just fixed this same issue in another image earlier today. Based on the comments from the Meteor issue about the TOOL_NODE_FLAGS environment variable, it sounds like at least setting the --max-old-space-size flag for Node might solve that.
I just added support for setting that variable at build time in the base image. To test it, first update your Dockerfile to use v1.4.0 with:
FROM reactioncommerce/base:v1.4.0
Then try doing a build with that flag set like this:
docker build --build-arg TOOL_NODE_FLAGS="--max-old-space-size=2048" -t reactioncommerce/reaction:latest .
(or whatever memory amount works on your build machine)
Let me know how it goes for you.
Hey @jshimko, Thanks for that build-arg option -- it's exactly what I was looking to set! I've just tested it out and it does the trick. Thanks!
Great. Confirmed fixed by https://github.com/reactioncommerce/base/commit/4901b5586b5095350a3867f4e94aa82180f4884f
Most helpful comment
Hey @owenhoskins. Sorry this issue kind of fell through the cracks.
I coincidentally just fixed this same issue in another image earlier today. Based on the comments from the Meteor issue about the
TOOL_NODE_FLAGSenvironment variable, it sounds like at least setting the--max-old-space-sizeflag for Node might solve that.I just added support for setting that variable at build time in the base image. To test it, first update your Dockerfile to use v1.4.0 with:
Then try doing a build with that flag set like this:
(or whatever memory amount works on your build machine)
Let me know how it goes for you.