Docker Build: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

I tried to build docker image in my local Mac.
Get error

sudo chown -Rh <username> .meteor/local


<--- Last few GCs --->

  654572 ms: Mark-sweep 1391.1 (1456.6) -> 1391.1 (1456.6) MB, 1663.6 / 0 ms [allocation failure] [GC in old space requested].
  655989 ms: Mark-sweep 1391.1 (1456.6) -> 1391.1 (1456.6) MB, 1416.9 / 0 ms [allocation failure] [GC in old space requested].
  657579 ms: Mark-sweep 1391.1 (1456.6) -> 1386.7 (1456.6) MB, 1590.1 / 0 ms [last resort gc].
  658914 ms: Mark-sweep 1386.7 (1456.6) -> 1391.1 (1456.6) MB, 1334.7 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x127aa1fb4629 <JS Object>
    1: /* anonymous */(aka /* anonymous */) [0x127aa1f041b9 <undefined>:~2379] [pc=0x248eb75137b4] (this=0x127aa1f041b9 <undefined>,ctor=0x8298fc8c839 <JS Function AST_Function (SharedFunctionInfo 0x1d6cd09848b1)>)
    2: /* anonymous */(aka /* anonymous */) [0x127aa1f041b9 <undefined>:~2599] [pc=0x248eb7519aa1] (this=0x127aa1f041b9 <undefined>,allow_calls=0x127aa1f04211 <true>)
    3: /* anony...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Aborted
ERROR: Service 'app-build' failed to build: The command '/bin/sh -c echo '\n[*] Building Meteor bundle' && meteor build --server-only --allow-superuser --directory /opt/app' returned a non-zero code: 134

I tried

export NODE_OPTIONS=--max_old_space_size=4096

But still don’t work
My dockefile

# https://github.com/banjerluke/meteor-dockerfile

# --- Stage 1: build Meteor app and install its NPM dependencies ---

# Make sure both this and the FROM line further down match the
# version of Node expected by your version of Meteor -- see https://docs.meteor.com/changelog.html
FROM node:4.6.2 as builder

# METEOR_VERSION should match the version in your .meteor/release
# APP_SRC_FOLDER is path the your app code relative to this Dockerfile
# /opt/src is where app code is copied into the container
# /opt/app is where app code is built within the container
ENV METEOR_VERSION=1.4.2.3 \
    APP_SRC_FOLDER=.

RUN mkdir -p /opt/app /opt/src

RUN echo "\n[*] Installing Meteor ${METEOR_VERSION} to ${HOME}"\
&& curl -s https://install.meteor.com/?release=${METEOR_VERSION} | sed s/--progress-bar/-sL/g | sh

WORKDIR /opt/src

# Copy in NPM dependencies and install them
COPY $APP_SRC_FOLDER/package*.json /opt/src/
RUN echo '\n[*] Installing app NPM dependencies' \
&& meteor npm install --only=production

# Copy app source into container and build
COPY $APP_SRC_FOLDER /opt/src/
RUN echo '\n[*] Building Meteor bundle' \
&& meteor build --server-only --allow-superuser --directory /opt/app

# Note: the line above will show a warning about the --allow-superuser flag.
# You can safely ignore it, as it doesn't apply here. The server *is* being built, silently.
# If the process gets killed after awhile, it's probably because the Docker VM ran out of memory.


# --- Stage 2: install server dependencies and run Node server ---

FROM node:4.6.2-alpine as runner

ENV NODE_ENV=production

# Install OS build dependencies, which we remove later after we’ve compiled native Node extensions
RUN apk --no-cache --virtual .node-gyp-compilation-dependencies add \
		g++ \
		make \
		python \
	# And runtime dependencies, which we keep
	&& apk --no-cache add \
		bash \
		ca-certificates

# Copy in app bundle built in the first stage
COPY --from=builder /opt/app/bundle /opt/app/

# Install NPM dependencies for the Meteor server, then remove OS build dependencies
RUN echo '\n[*] Installing Meteor server NPM dependencies' \
&& cd /opt/app/programs/server/ \
&& npm install --production && npm run install --production \
&& apk del .node-gyp-compilation-dependencies

# Move into bundle folder
WORKDIR /opt/app/

CMD ["node", "main.js"]

Looks like docker iteself needs more memory:


and

thanks, I will try :blush: