Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Docker build logs on failure #7671

Open
palfrey opened this issue Nov 12, 2024 · 2 comments
Open

Feature request: Docker build logs on failure #7671

palfrey opened this issue Nov 12, 2024 · 2 comments
Labels
area/build sam build command type/feature Feature request

Comments

@palfrey
Copy link

palfrey commented Nov 12, 2024

Describe your idea/feature/enhancement

When you run sam build --use-container and your Docker build fails, you get something like the following

Building image for EmploymentTimeEmployeeCachingFunction function
Setting DockerBuildArgs for EmploymentTimeEmployeeCachingFunction function
Failed building function EmploymentTimeEmployeeCachingFunction

Build Failed
Error: The command '/bin/sh -c exit 1' returned a non-zero code: 1

This isn't very useful, as I've got no idea what the build logs actually look like that caused this.

Proposal

Dump the docker build logs on failure. So, for the above example, instead I would like something like

Building image for EmploymentTimeEmployeeCachingFunction function
Setting DockerBuildArgs for EmploymentTimeEmployeeCachingFunction function
Failed building function EmploymentTimeEmployeeCachingFunction
Step 1/19 : FROM public.ecr.aws/lambda/python:3.11 AS base
 ---> 37318d609dfb
Step 2/19 : RUN exit 1
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 6420d9378807
The command '/bin/sh -c exit 1' returned a non-zero code: 1
Build Failed
Error: The command '/bin/sh -c exit 1' returned a non-zero code: 1

Additional Details

The demo log was generated with the following extra code in the BuildError handler in app_builder.py

            for log in ex.build_log:
                if "stream" in log:
                    self._stream_writer.write_str(log["stream"])
                elif "error" in log:
                    self._stream_writer.write_str(log["error"])
@palfrey palfrey added stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature Feature request labels Nov 12, 2024
@mndeveci
Copy link
Contributor

Thanks for creating this issue.

This makes sense from our side, and it should improve the user experience in general. Since you already find the point which needs the update, would like to raise a pull request with the change?

@mndeveci mndeveci added area/build sam build command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 12, 2024
@palfrey
Copy link
Author

palfrey commented Nov 13, 2024

See #7675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build sam build command type/feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants