Building React docker image fail by unexpected EOF

aminpaks November 24, 2018

Building a docker image fail at a step running webpack to build the client application (React).

Any tips why this happens?

Bitbucket says: Container 'docker' exceeded memory limit.

 

react-docker-image.png

 

 

Dockerfile:

# Use an official Node runtime as a parent image
FROM node:8-alpine

# Install any needed tools
RUN apk add --no-cache --update curl ca-certificates openssl git && \
update-ca-certificates && \
addgroup -S app && \
adduser -S -g app app && \
mkdir -p /usr/src/app

# Prepare build
WORKDIR /usr/tmp
COPY . /usr/tmp

# CONSUMER KEY & SECRET must be set by environment
ENV CONSUMER_KEY=CONSUMER_KEY__
ENV CONSUMER_SECRET=CONSUMER_SECRET__

# Install deps and build the client
RUN ["npm", "install", "--no-save"]
RUN ["npm", "run", "build:client"]

# Set working directory for image
WORKDIR /usr/src/app
# Copy needed files for runtime
COPY /usr/tmp/node_modules /usr/src/app/node_modules
COPY /usr/tmp/build /usr/src/app/client
COPY ./server/ /usr/src/app/server
COPY ./package.json /usr/src/app
COPY Docker-cmd.sh /
# Set Docker-cmd executable
RUN chmod a+x /Docker-cmd.sh
# Clean up
RUN rm -fr /usr/tmp

# Set client application port
ENV PORT=80

# Make port 80 available to outside this container
EXPOSE ${PORT}

# Run /Docker-cmd.sh when the container launches
CMD [ "/Docker-cmd.sh" ]

 

bitbucket-pipeline.yml:

pipelines:
default:
- step:
name: Build Docker image
script:
- docker build -t test .
services:
- docker
caches:
- docker

 

2 answers

1 accepted

1 vote
Answer accepted
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 2, 2018

Hi Amin,

As the error message says, the Docker process has run out of memory. Do you know which instruction in the Dockerfile it fails on?

You can increase the memory of docker with the following config:

pipelines:
default:
- step:
name: Build Docker image
script:
- docker build -t test .
services:
- docker
caches:
- docker
definitions:
services:
docker:
memory: 3072

More details are listed here. https://confluence.atlassian.com/bitbucket/use-services-and-databases-in-bitbucket-pipelines-874786688.html

Thanks,

Phil

aminpaks December 9, 2018

Thanks!

Still not sure why building this image is taking this much of memory!

Like # people like this
0 votes
Ignacio Mendizabal July 6, 2020

I have this same issue and I don't find a good way to debug what is happening. 

If I build the same image locally and follow the usage of resources with docker stats I can see that the MEM USAGE is never over 700 MiB. 

I have 3072  MiB assigned to docker service in the pipeline. 

Also... It appears to be completely random! Every single time this happens I just re-run the pipe and it works fine the second time. 

etiennecaldichourypys October 27, 2020

Same here

Like Angel Quiroz likes this
Angel Quiroz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 19, 2022

I have the same problem

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events