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

0

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
BUILD State: FAILED
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 個回答
1

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
Syd
已回答 2 年前
  • 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...

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南