pulumi / pulumi-awsx

AWS infrastructure best practices in component form!
https://www.pulumi.com/docs/guides/crosswalk/aws/
Apache License 2.0
227 stars 104 forks source link

Is it possible to get the docker build log output from awsx.ecr.Image ? #1401

Open anentropic opened 2 weeks ago

anentropic commented 2 weeks ago

Hello!

Issue details

I am running pulumi up --verbose=7

It fails with:

  docker:index:Image (30978633-container):
    error: error reading build output: process "/bin/sh -c poetry run ./manage.py collectstatic" did not complete successfully: exit code: 1

I execute the same docker build outside of Pulumi on my machine then the build succeeds.

My problem is I can't work out how to get more details about what the Pulumi resource is doing differently, or what the actual error returned from that command was.

I didn't see any difference in the verbosity of output by adding --verbose=7

Is there a build log somewhere?

It'd be great if it just showed the actual output.

Affected area/feature

awsx.ecr.Image Docker builds

anentropic commented 2 weeks ago

Usually in Docker Desktop I can see build logs there...

But for some reason the builds that Pulumi/awsx.ecr is doing don't allow that

e.g. here Image

The successful build is one I ran manually. If I click on that I can see lots of details about the build, including a logs tab.

The ones with http://build-context... names are the Pulumi ones. If I click on that I just see:

Image

t0yv0 commented 2 weeks ago

Hi @anentropic thank you for reporting this problem.

https://www.pulumi.com/registry/packages/docker/api-docs/image/ has some more info on how Pulumi is building the image.

I have tried to reproduce this and I get close to reproducing it if I edit my Dockerfile to intentionally fail.

For example, if I inject an error in ts-ecr-simple:

[1] anton@anton-mbp-m3> docker build .        ~/code/pulumi-awsx/examples/ts-ecr-simple/app
[+] Building 0.0s (2/2) FINISHED                                                             => [internal] load build definition from Dockerfile                                   0.0s
 => => transferring dockerfile: 89B                                                    0.0s
 => [internal] load .dockerignore                                                      0.0s
 => => transferring context: 2B                                                        0.0s
dockerfile parse error on line 2: unknown instruction: CO (did you mean CMD?)

Pulumi reports parse error on line 2: unknown instruction: CO (did you mean CMD?) in the failure but adding verbose logging does not recover any of the additional messages I can observe from docker build ..

t0yv0 commented 2 weeks ago

Digging a little deeper here, the docker.Image resource is using buildkit to build the image. But there might be a problem with log processing code where some of the information surfaced by buildkit is not being propagated to the user as expected.

I have filed https://github.com/pulumi/pulumi-docker/issues/1268 to investigate if this is the case.

anentropic commented 2 weeks ago

Thank you for looking into it!

I note that the linked docs say:

Note: We recommend you migrate your images to the more modern Docker Build provider to get the best possible support, features, and performance.

I will also experiment with using that... it's not as straightforward as awsx.ecr.Image but the docs there do show an example of using it to push to ECR.

t0yv0 commented 2 weeks ago

Yes unfortunately you cannot migrate the awsx.ecr.Image resource to the more modern Docker Build provider, this would require a (potentially breaking) change to this repository which our team needs to consider separately.

anentropic commented 1 week ago

FWIW using the recipe here: https://www.pulumi.com/registry/packages/docker-build/

That docker build completes successfully, unlike the awsx.ecr.Image one.

But the nicer thing about this docker_build.Image resource is I get full details of the build in the Docker Desktop app: Image

(instead of missing digest error)