Unable to run 'npm run build' in docker using craco

Prithvi Sathiya May 21, 2024

Im trying to build a simple react based docker image in the bitbucket pipelines. Here is snippet of the yaml file:

 

image: python:3.10
definitions:
- step: &BuildPush
name: Build
size: 2x
services:
- docker
script:
- pip install --upgrade pip && pip install docker-compose
- export DOCKER_BUILDKIT=1
- cd frontend && docker build -t espace.jfrog.io/mcs/mcs-react:latest .

The same `docker build` command works in my local laptop. But it seems to hang (and eventually fail) when running on pipelines, during the `npm run build` step within the Dockerfile, due to some memory error. However, when running locally, I can see it doesn't use too much memory, and i even ran the pipeline with "2x" size. Here is the error after about 10 min of runtime:

 

#13 677.5 The build failed because the process exited too early.
230
#13 677.5 This probably means the system ran out of memory or someone called
231
#13 677.5 `kill -9` on the process.
232
#13 677.5
233
#13 ERROR: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
234
------
235
> [builder 7/7] RUN npm run build:
236
------
237
process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

 

Any idea what is causing this? 

1 answer

1 vote
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2024

G'day, @Prithvi Sathiya 

I suggest adding the following docker service definition to give more memory to the docker service container. Using 2x only without explicitly increasing the docker container memory will not work as the default given is only 1 GB.

definitions:
  services:
    docker:
      memory: 2147

<Rest of your YAML>

We have documentation that touches explicitly on the docker memory limit that I highly suggest you check out at:

Docker memory limit

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events