pulumi / pulumi-docker

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

Using CacheFrom causes relative path for context and dockerfile to not work #829

Closed afreakk closed 1 year ago

afreakk commented 1 year ago

What happened?

I have a working dockerfile at ../../x/y This works, but when I uncomment the CacheFrom argument, I get the following error could not open dockerfile at relative path Dockerfile: stat Dockerfile: no such file or directory

Example

docker.NewImage(ctx, repoName, &docker.ImageArgs{
        Build: &docker.DockerBuildArgs{
            // CacheFrom: &docker.CacheFromArgs{
            //  Images: pulumi.StringArray{
            //      ecrRepository.RepositoryUrl.ApplyT(func(repositoryUrl string) (string, error) {
            //          return fmt.Sprintf("%v:latest", repositoryUrl), nil
            //      }).(pulumi.StringOutput),
            //  },
            // },
            Context:    pulumi.String("../../x/y"),
            Dockerfile: pulumi.String("../../x/y" + "/Dockerfile"),
        },
        ImageName: ecrRepository.RepositoryUrl.ApplyT(func(repositoryUrl string) (string, error) {
            return fmt.Sprintf("%v:latest", repositoryUrl), nil
        }).(pulumi.StringOutput),
        Registry: &docker.RegistryArgs{
            Password: pulumi.ToSecret(authToken.ApplyT(func(authToken ecr.GetAuthorizationTokenResult) (*string, error) {
                return &authToken.Password, nil
            }).(pulumi.StringPtrOutput)).(pulumi.StringPtrOutput),
            Server: ecrRepository.RepositoryUrl,
        },
    })

Output of pulumi about

CLI
Version      3.90.1
Go Version   go1.21.3
Go Compiler  gc

Plugins
NAME          VERSION
aiven         6.1.1
aws           6.5.0
aws           5.35.0
awsx          2.0.3
cloudamqp     3.15.1
command       0.6.0
docker        4.4.3
eks           0.42.7
go            unknown
kubernetes    3.22.1
mongodbatlas  3.7.2
mysql         3.1.0
postgresql    3.6.0
rabbitmq      3.2.0
random        4.8.2
spotinst      3.22.0
tailscale     0.11.0
tls           4.6.1

Host
OS       nixos
Version  23.11 (Tapir)
Arch     x86_64

This project is written in go: executable='/nix/store/dwmb0qcai52d0zkgpm6f5ifx2a8yvsdg-go-1.21.3/bin/go' version='go version go1.21.3 linux/amd64'

Backend
Name           pulumi.com
URL            https://app.pulumi.com/afreakk
User           afreakk
Organizations  afreakk, fiveten
Token type     personal

Dependencies:
NAME                                          VERSION
github.com/1Password/connect-sdk-go           1.5.0
github.com/goccy/go-yaml                      1.9.6
github.com/google/uuid                        1.3.0
github.com/iancoleman/strcase                 0.2.0
github.com/pkg/errors                         0.9.1
github.com/pulumi/pulumi-aiven/sdk/v6         6.1.1
github.com/pulumi/pulumi-aws/sdk/v5           5.35.0
github.com/pulumi/pulumi-awsx/sdk/v2          2.0.3
github.com/pulumi/pulumi-cloudamqp/sdk/v3     3.15.1
github.com/pulumi/pulumi-command/sdk          0.6.0
github.com/pulumi/pulumi-eks/sdk              0.42.7
github.com/pulumi/pulumi-kubernetes/sdk/v3    3.22.1
github.com/pulumi/pulumi-mongodbatlas/sdk/v3  3.7.2
github.com/pulumi/pulumi-mysql/sdk/v3         3.1.0
github.com/pulumi/pulumi-postgresql/sdk/v3    3.6.0
github.com/pulumi/pulumi-rabbitmq/sdk/v3      3.2.0
github.com/pulumi/pulumi-random/sdk/v4        4.8.2
github.com/pulumi/pulumi-spotinst/sdk/v3      3.22.0
github.com/pulumi/pulumi-tailscale/sdk        0.11.0
github.com/pulumi/pulumi-tls/sdk/v4           4.6.1
github.com/pulumi/pulumi/sdk/v3               3.91.0
github.com/sirupsen/logrus                    1.9.0
github.com/spf13/cobra                        1.7.0
github.com/stretchr/testify                   1.8.4
gopkg.in/yaml.v3                              3.0.1
gorm.io/driver/mysql                          1.4.3
gorm.io/gorm                                  1.24.1
inet.af/netaddr                               0.0.0-20230525184311-b8eac61e914a

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).

### Tasks
mikhailshilkov commented 1 year ago

@afreakk This looks like a duplicate of https://github.com/pulumi/pulumi-docker/issues/676

Could you try if 4.4.4 fixes your problem?

afreakk commented 1 year ago

Yes it does