pulumi / pulumi-docker

A Docker Pulumi resource package, providing multi-language access to Docker resources and building images.
77 stars 13 forks source link

[Docs] Example for ecr push has some mistakes #1150

Closed MitchellGerdisch closed 1 week ago

MitchellGerdisch commented 2 weeks ago

Describe what happened

The example here: https://www.pulumi.com/registry/packages/docker/api-docs/image/#docker-image-build-using-caching-with-aws-elastic-container-registry does not work as documented.

Specifically, the dockerfile property was missing the presumed app and the registry property was missing the ecr user_name.

Here is a corrected version:

my_app_image = docker.Image("my-app-image",
    build=docker.DockerBuildArgs(
        args={
            "BUILDKIT_INLINE_CACHE": "1",
        },
        cache_from=docker.CacheFromArgs(
            images=[ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest")],
        ),
        context="app/",
        dockerfile="app/Dockerfile",
    ),
    image_name=ecr_repository.repository_url.apply(lambda repository_url: f"{repository_url}:latest"),
    registry=docker.RegistryArgs(
    username=auth_token.user_name,
        password=pulumi.Output.secret(auth_token.password), 
        server=ecr_repository.repository_url,
    ))

Sample program

See above

Log output

N/A

Affected Resource(s)

No response

Output of pulumi about

Dependencies: NAME VERSION pip 23.0.1 pulumi_aws 6.40.0 pulumi_aws_native 0.108.3 pulumi_docker 4.5.4 setuptools 65.5.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).