2

We are trying to deploy a NodeJS Docker in AWS Fargate using ECS. Code is configured to come through GitHub -> CodeBuild -> ECR -> ECS Fargate.

We are facing standard_init_linux.go:219: exec user process caused: exec format error when we run the ECS Service. When we run the image in local, it is running without an issue. When we searched regarding this error, it was mentioned that it is due to architecture mismatch.

DockerFile:

FROM node:14 as builder

COPY . /contents
WORKDIR /contents

RUN npm install

RUN npm run build

...


EXPOSE 3000

The CodeBuild architecture we tried are

  1. AL2 aarch64 1.0/2.0
  2. AL2 x86-64 2.0/3.0
  3. Ubuntu 3.0/4.0/5.0

What is the right environment for node 14 for CodeBuild? Is there anything else that might be causing the issue?

Any help is appreciated. Thanks!

1 Answer 1

0

As you pointed out this problem is typically caused by an architecture mismatch. Fargate does NOT support (yet) Graviton/Arm architectures and it always expects an x86-64 based image. Because Codebuild supports multiple architecture it is likely that that is where the mismatch is occurring. Do NOT use AL2 aarch64 1.0/2.0 with CodeBuild because that option will provision a Graviton/Arm environment to build and hence the resulting image would NOT work on Fargate. The other two should generate an image that is compatible with Fargate.

The litmus test (to be sure this is due to an architecture mismatch) would be to provision a small Graviton based instance on the fly and test the SAME container image that is failing on Fargate with that error message. If it works with Graviton that is the problem.

Sign up to request clarification or add additional context in comments.

2 Comments

How do we set the image to be x86-64 image as that seems like the option that would work with Far gate. Given that the content comes from github, how do we set Code Build to create an x86-64 image.
The application code source and the CodeBuild environment are decoupled. The GH repo may (optionally) contain a buildspec.yaml file that basically tell CB how to build the artifact(s) but the CB environment to be used is spec'ed out of band (via API, IaC, UI, as you wish) as a build project. The build project basically spec out the source repo, the environment (e.g. x86 vs Arm), the buildspec.yaml (either from repo or in project) and other stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.