App Runner - Failed to deploy your application image

0

Hi, I was trying to use app runner to deploy my application application (we are not using s3 because we might need to do some SSR/SEO stuff in the future).

The dockerfile is as follows:

FROM node:alpine AS app

WORKDIR /usr/src/app

COPY . /usr/src/app

RUN npm install

RUN npm run build

FROM nginx:alpine

COPY --from=app /usr/src/app/dist/sampleapp/browser /usr/share/nginx/html

RUN ls /usr/share/nginx/html

COPY ./nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

It is deployed to ECR as public.ecr.aws/b6r5q5g0/sample-angular:latest. It works fine when tested locally.

However, when using the aws app runner (all settings are default except for port changed from 8080 to 80), aws throws as error:

08-11-2024 12:32:15 PM [AppRunner] Starting to deploy your application image.
08-11-2024 12:32:36 PM [AppRunner] Starting to pull your application image.
08-11-2024 12:32:38 PM [AppRunner] Successfully pulled your application image from ECR.
08-11-2024 12:34:08 PM [AppRunner] Failed to deploy your application image.

There's no other logs. Will appreciate some assistance, thank you!

CheeHan
asked a month ago168 views
3 Answers
1
Accepted Answer

So...after banging my head against the wall, it turns out that I had to change one line: From

FROM nginx:alpine

to

FROM --platform=linux/amd64 nginx:latest

Probably because I'm using a mac for my coding. There was a comment from someone on reddit saying they had an issue with their M1 mac, but I thought that since I'm using an M3 mac, it wouldn't affect me...

Anyway if anyone from AWS reads this, please put an official note somewhere in your documentation, thank you.

CheeHan
answered a month ago
profile picture
EXPERT
reviewed a month ago
1

Hello.

Is this what you're trying to do to deploy a Node.js application?
In that case, why not try using CMD in your Dockerfile to start the application as shown below?
https://docs.aws.amazon.com/apprunner/latest/dg/service-source-code-nodejs.html

CMD ["node", "app.js"]
profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • It's an nginx application. The dockerfile I posted is a multistage build: it uses node to build the angular app and moves the file to nginx when creating the container.

1

Hi,

When you say It works fine when tested locally., is it already within a container or as a plain application on your desktop ?

If it's out of a container, I'd suggest that you get it first to run locally on a container (with your local registry) before pushing to ECR: that will make it easier to debug. Then, you'll be sure to have a working image when you switch to ECR and AWS.

Best.

Didier

profile pictureAWS
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • It's working as a container. It is a working image. I have also deleted it off my system, docker pulled it and ran it again with docker run. In fact, it is a public repo: public.ecr.aws/b6r5q5g0/sample-angular:latest and I think anyone should be able to pull it I think. It throws the error on app runners however

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