Hey team! The new Docker provider version v4+ comp...
# general
t
Hey team! The new Docker provider version v4+ completely changes the output of docker.Image in imageName. In the new version there’s now image hash attached. For example: v3:
imageName = <http://gcr.io/xxxxx/my-app:dd173278046fcc735e6bd5f884a42ace408775b3aea38431aafe9267a46647ba|gcr.io/xxxxx/my-app:dd173278046fcc735e6bd5f884a42ace408775b3aea38431aafe9267a46647ba>
v4:
imageName = <http://gcr.io/xxxxx/my-app|gcr.io/xxxxx/my-app>
With this change, the resources that depend on the Docker image don’t get updated whenever the docker image is updated. That also breaks many of the examples provided by Pulumi that involve deploying a docker image to the cloud. Is that intentional or it’s a bug?
l
This is intentional. The old way was really frustrating for a lot of use cases.
You will either need to pin you version to the old one, or update your code and the way you expect the build to work.
t
So how can I get the image hash with the new version? Should I parse the output of repoDigest?
l
Do you need the hash? The Image now behaves like a normal Pulumi resource, maybe you can use that functionality instead? For example, opt dependsOn can now have the image passed to it, since it is updated only when the image is really changed (before, the image resource always changed, even if there was no actual change involved).
If you do need the hash, then: I don't know! I'll have a quick look.
t
I tried dependsOn but it didn’t work
This is what I have:
Copy code
const appImage = new docker.Image("app-image", {
  imageName: `<http://gcr.io/${project}/${imageName}|gcr.io/${project}/${imageName}>`
}

const appService = new gcp.cloudrunv2.Service("app-service", {
  location: location,
  template: {
    containers: [
      {
        image: appImage.imageName,
      },
    ],
  },
  traffics: [
    {
      type: "TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST",
      percent: 100,
    },
  ],
}, {
  dependsOn: [appImage],
});
I want the
appService
resource to be updated when
appImage
is updated
With Docker V3 that worked great
With V4 it doesn’t work
l
I expect that to work. Does it update the service and the service doesn't change? Or does it not update the service at all?
t
So
appImage
gets updated, but
appService
doesn’t get updated at all
l
I've looked through the docs and it looks all good to me. You could maybe try changing the dependsOn from appImage to appImage.repoDigest, but if that works, then I'm at a loss to explain why. I'd raise an issue, either way.
t
appImage.repoDigest
won’t work with dependsOn because it’s not a resource
Thanks for the help!!
w
The
repoDigest
is a valid fully qualified image name - so you should be able to pass that directly instead of
imageName
to get the behavior you are looking for here. The name is slightly unusual, but derived from the term the Docker API uses to refer to this.
t
Yes, that worked. Thanks Luke!