jshimko / meteor-launchpad

A base Docker image for Meteor applications.
https://hub.docker.com/r/jshimko/meteor-launchpad/
MIT License
276 stars 152 forks source link

Out of memory errors - can I increase the max memory size? #120

Closed benjii closed 5 years ago

benjii commented 5 years ago

Hi,

Firstly, I have seen some other issues here that appear to reference memory issues. However, after trying suggestions given as best I could I have had no luck. And so I hope you don't mind that I have made by own issue.

Problem: I am getting these kinds of errors:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Goal: double the memory available to my Meteor app (to 4Gb)

What I Have Tried:

  1. Passing this build-arg:

    --build-arg TOOL_NODE_FLAGS="--max-old-space-size=4096"

This caused a build error later on:

2018-09-21T10:58:30.7145253Z Error: Cannot find module '/opt/meteor/src/"--max-old-space-size=4096"'
2018-09-21T10:58:30.7165833Z     at Function.Module._resolveFilename (module.js:536:15)
2018-09-21T10:58:30.7184355Z     at Function.Module._load (module.js:466:25)
2018-09-21T10:58:30.7202496Z     at Function.Module.runMain (module.js:676:10)
2018-09-21T10:58:30.7220774Z     at startup (bootstrap_node.js:187:16)
2018-09-21T10:58:30.7241977Z     at bootstrap_node.js:608:3
2018-09-21T10:58:52.8506949Z The command '/bin/sh -c cd $APP_SOURCE_DIR &&   $BUILD_SCRIPTS_DIR/install-deps.sh &&   $BUILD_SCRIPTS_DIR/install-node.sh &&   $BUILD_SCRIPTS_DIR/install-phantom.sh &&   $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh &&   $BUILD_SCRIPTS_DIR/install-mongo.sh &&   $BUILD_SCRIPTS_DIR/install-meteor.sh &&   $BUILD_SCRIPTS_DIR/build-meteor.sh &&   $BUILD_SCRIPTS_DIR/post-build-cleanup.sh' returned a non-zero code: 1
2018-09-21T10:58:52.8815664Z ##[error]The command '/bin/sh -c cd $APP_SOURCE_DIR &&   $BUILD_SCRIPTS_DIR/install-deps.sh &&   $BUILD_SCRIPTS_DIR/install-node.sh &&   $BUILD_SCRIPTS_DIR/install-phantom.sh &&   $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh &&   $BUILD_SCRIPTS_DIR/install-mongo.sh &&   $BUILD_SCRIPTS_DIR/install-meteor.sh &&   $BUILD_SCRIPTS_DIR/build-meteor.sh &&   $BUILD_SCRIPTS_DIR/post-build-cleanup.sh' returned a non-zero code: 1
2018-09-21T10:58:52.8922695Z ##[error]/usr/local/bin/docker failed with return code: 1
2018-09-21T10:58:52.9675576Z ##[section]Finishing: Build an image
  1. Attempting to set NODE_OPTIONS="--max-old-space-size=4096"

I run this script on release:

cd deploy
ls
export METEOR_SETTINGS=$(cat settings-uat.json)
export ROOT_URL=[filtered]
export MONGO_URL=[filtered]
export NODE_OPTIONS="--max_old_space_size=4096"
docker stack deploy --compose-file [filtered] [filtered] --with-registry-auth

The first 3 environment variables do show up in the services, but the last one does not.

So am I doing something wrong here? Or missing something simple perhaps? I am a bit new to Docker I must admit.

Any help that can be provided would be greatly appreciated.

Thanks in advance, Ben

benjii commented 5 years ago

Never mind - newbie error. You can set NODE_OPTIONS in the Docker compose file, of course. A bug at my end meant that it wasn't getting copied over / respected by my build process.

All fixed now.