Skip to content

App Runner Failed with status exit code: 1

0

Hello, I'm trying to configure app runner service with my golang image, pushed in Aws ECR image repository

I need some help to understand the following error. The error description it says “[AppRunner] Your application stopped or failed to start. See logs for more information. Container exit code: 1"

Enter image description here

I also tried health check validation with HTTP, but I was not successful Enter image description here

My image runs perfectly locally, my dockerfile

FROM --platform=linux/amd64  golang:1.23 as builder

WORKDIR /app/revise-payments-api

COPY go.mod ./
COPY go.sum ./

RUN go mod download
RUN go mod verify

COPY . ./

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /revise-payments-api ./src/api

#Certs
FROM --platform=linux/amd64 alpine:3 as certs
RUN apk --no-cache add ca-certificates

#Run stage
FROM --platform=linux/amd64 scratch

ENV GIN_MODE=release

WORKDIR /

COPY --from=builder /revise-payments-api ./
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY /internal/configuration/default.properties ./internal/configuration/

EXPOSE 8080

ENTRYPOINT [ "./revise-payments-api" ]
1 Answer
0

Based on the information provided, it appears that your App Runner service is failing to start properly. The error message "[AppRunner] Your application stopped or failed to start. See logs for more information. Container exit code: 1" indicates that there's an issue with your application's startup process.

Here are a few things to consider:

  1. Port Configuration: Ensure that your application is listening on the correct port. App Runner by default expects your application to listen on port 8080. Your Dockerfile exposes port 8080, which is correct, but make sure your Go application is actually listening on this port.

  2. Start Command: App Runner uses the ENTRYPOINT specified in your Dockerfile to start the application. Make sure that "./revise-payments-api" is the correct command to start your application and that it's located in the right directory.

  3. Environment Variables: If your application requires specific environment variables to run, make sure these are properly set in your App Runner service configuration.

  4. Logs: The error message suggests checking the logs for more information. Review the App Runner logs thoroughly as they might provide more specific details about why the application is failing to start.

  5. Health Check: Your health check configuration appears to be using the HTTP protocol, which is correct for most web applications. However, ensure that your application has a health check endpoint that responds correctly.

  6. Image Build: While your image runs perfectly locally, there could be differences in the environment when running on App Runner. Double-check that all necessary files (especially the "default.properties" file) are included in the image and in the correct locations.

  7. Permissions: Ensure that your application has the necessary permissions to run and access any required resources.

To troubleshoot further:

  1. Try running your container locally with the same configuration as App Runner (e.g., environment variables, start command).
  2. Implement more detailed logging in your application to capture any startup errors.
  3. Consider adding a simple health check endpoint to your application if you haven't already.
  4. Review the App Runner service logs carefully for any specific error messages or stack traces.

If the issue persists, you may need to add more detailed error handling and logging in your Go application to pinpoint the exact cause of the failure.
Sources
App Runner architecture and concepts - AWS App Runner
ImageConfiguration - AWS App Runner
AWS App Runner improves performance for image-based deployments | Containers

answered 2 years ago

  • I run the container locally, here are the logs running correctly

    time="2024-10-20T14:25:42Z" level=info msg="Config loaded successfully in production"
    time="2024-10-20T14:25:43Z" level=info msg="You successfully connected to MongoDB!"
    time="2024-10-20T14:25:43Z" level=info msg="App Running"
    [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
    
    [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
     - using env:   export GIN_MODE=release
     - using code:  gin.SetMode(gin.ReleaseMode)
    
    [GIN-debug] GET    /api/v1/ping              --> github.com/ReviseConcurso/revise-payments/internal/handler.(*web).HandlePing.func1 (3 handlers)
    [GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
    Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
    [GIN-debug] Listening and serving HTTP on :8080
    [GIN] 2024/10/20 - 14:25:57 | 200 |       171.9µs |      172.25.0.1 | GET      "/api/v1/ping"
    [GIN] 2024/10/20 - 14:25:59 | 200 |        15.9µs |      172.25.0.1 | GET      "/api/v1/ping"
    

    Also, I tried changing the health check to HTTP and to no avail.

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.