Anyone else migrating from `awsx.ecr.Image` to `do...
# aws
f
Anyone else migrating from
awsx.ecr.Image
to
docker.Image
?
To take advantage of better performance, etc
My old code:
Copy code
const imageRepo = new awsx.ecr.Repository(`${name}-repo`, {
    name: `${name}-repo`,
  })
  const image = new awsx.ecr.Image(`${name}-image`, {
    repositoryUrl: imageRepo.url,
    path: imageDir,
    extraOptions: ["--platform", "linux/amd64"],
My new code:
Copy code
const imageRepo = new awsx.ecr.Repository(`${name}-repo`, {
    name: `${name}-repo`,
  })

  const password = new local.Command(`${name}-get-ecr-password`, {
    create: "aws ecr get-login-password --region us-east-2" 
  })

  const image = new docker.Image(`${name}-image`, {
    registry: {
      server: imageRepo.url,
      username: "AWS",
      password: password.stdout
    },
    build: {
      context: imageDir,
      platform: "linux/amd64",
      args: buildArgs
    },
    imageName: imageRepo.url.apply(url => `${url}:latest`),
  })
This seems to work the same, except the image doesn’t get a hash as a tag, it just gets
latest
I can just use the repo digest as a tag, although that’s not the same as what
awsx.ecr.Image
uses. Not sure it matters! Inspired by https://pulumi-community.slack.com/archives/CJ909TL6P/p1678919350593459?thread_ts=1678915866.706349&cid=CJ909TL6P
Well, another hour later, I was still seeing errors like
Copy code
error hashing dockerfile "test-image/Dockerfile": could not open file test-image/Dockerfile: open test-image\test-image\Dockerfile: The system cannot find the path specified.
even with @billowy-army-68599’s latest suggestion. Then I did a
pulumi refresh
and then it worked 🫠
Ah -- one more thing that I had to change.
context
needs to start with
./
if it's not
.
.