Build Failed - Building Images through CodeBuild and Pushing them on ECR.


I am having a codepipeline with codebuild which builds and pushes my docker image to ECR. I also have another pipeline for running docker images in EC2/ECS.

The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.
The command '/bin/sh -c npm run build' returned a non-zero code: 1

Command did not exit successfully docker build --cache-from image-name exit status 1
Pushing the Docker images..
An image does not exist locally with the tag

I am not sure about the error, what am i missing? EC2/ECS , memory and space seems good.

1 Answer

Try giving your CodeBuild instance a higher compute type since the error mentions that it's run out of memory. Also check and rule out if you are exceeding the default timeout values for the build job (1 hour). Both these options are available as Additional Configuration in Environment section.

profile picture
answered 2 years ago
  • I was able to resolve this issue by increasing the default configuration in codebuild from smaller cpu to larger one. it was indeed a memory issue.

    Another question, what triggers this memory issue, how to ensure that this memory issue doesn't occur frequently and I don't need to increase the memory frequently.

  • I'm no expert with npm run build. But unless the originally reported issue was intermittent, I would assume that the codebuild instance was undersized. Now that you changed the instance, the issue should not recur soon. The only time you might need more memory / cpu is when whatever npm build does in the background needs more processing capacity due to increased dependencies or more things to build... something of that sort...

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions