bright-magician-13023
02/03/2025, 9:37 PMpulumi-docker
to deploy images on an ECR repository; the pulumi up
command works on my laptop but not on my colleague one; we tried to build the image locally and also pushing it to the ECR repo using the commands suggested in the AWS documentation, but the build/push fails when run through pulumi.
this is the error message:
(...)
error: error reading build output: failed to read downloaded context: failed to load cache key: invalid response status 403
this is the code in the pulumi main script:
ref_admin = pulumi.StackReference(f"{org}/admin/{stack}")
service_assets = ref_admin.get_output("ecs")
image_repo = service_assets['ecrs']['myservice']['repo']
image_name = image_repo.apply(lambda val: f"{val}:{get_docker_tag()}")
image = docker.Image(
"myservice-image",
build=docker.DockerBuildArgs(
context="..", # Path to the build context
platform="linux/amd64",
),
image_name=image_name,
registry=docker.RegistryArgs(
server=image_repo,
username=aws.ecr.get_authorization_token().user_name,
password=aws.ecr.get_authorization_token().password,
),
)
I'm not quite sure what the problem is... I tried to add extra logging with --logtostderr --logflow -v=10 2> out.txt
, and I can see the token being passed:
(...)
17:43:57.730951 93774 eventsink.go:59] I0203 17:43:57.730430 93845 rpc.go:292] Unmarshaling property for RPC[]: registry={map[password:{====REDACTED-TOKEN====} server:{123REDACTED456.dkr.ecr.us-east-1.amazonaws.com/myservice} username:{AWS}]}
(...)
I can also see these lines that may suggest some other error:
I0203 17:43:58.687476 93774 eventsink.go:70] eventSink::Info(<{%reset%}>digest: sha256:63fd8b53c2e09b89dc1972305eaf0139e403ef05cb750de076299726b4c1881a
[internal] load remote build context
error: invalid response status 403<{%reset%}>)
I0203 17:43:58.687678 93774 eventsink.go:59] time="2025-02-03T17:43:58Z" level=error msg="Can't add file /.../.venv/bin/ruff to tar: io: read/write on closed pipe"
I'm not sure if this is related at all as ruff
is not used by the Dockerfile
and running docker build ..
works as expected... and the error mention a 403
error which looks like an HTTP forbidden error code...
any help would be much appreciated...little-cartoon-10569
02/03/2025, 10:14 PMbright-magician-13023
02/03/2025, 10:35 PMaws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123REDACTED.dkr.ecr.us-east-1.amazonaws.com
docker build -t myservice ..
docker tag myservice:latest 123REDACTED.dkr.ecr.us-east-1.amazonaws.com/myservice:latest
docker push 123REDACTED.dkr.ecr.us-east-1.amazonaws.com/myservice:latest
those are the commands that AWS suggests when one navigate to the ECR repo and click on "Show push commands" buttonbright-magician-13023
02/03/2025, 10:36 PMdefault
profile credentials and set it on the Pulumi.develop.yaml file toobright-magician-13023
02/03/2025, 10:40 PMimage = docker.Image(
# ...
registry=docker.RegistryArgs(
server=image_repo,
username=aws.ecr.get_authorization_token().user_name,
password=aws.ecr.get_authorization_token().password,
)
)
and they seem to be fine...little-cartoon-10569
02/03/2025, 10:47 PMlittle-cartoon-10569
02/03/2025, 10:47 PMbright-magician-13023
02/03/2025, 11:06 PM/aws/credentials
file) and the aws.ecr.get_authorization_token()
seem to work correctly...modern-zebra-45309
02/03/2025, 11:17 PMdocker
CLI command). Are you running the same Docker version on your machines? A cursory Google search suggests that the errors you see are all somehow related to BuildKit, e.g., https://github.com/moby/buildkit/issues/5623bright-magician-13023
02/03/2025, 11:18 PMmodern-zebra-45309
02/03/2025, 11:19 PMbright-magician-13023
02/03/2025, 11:19 PMbright-magician-13023
02/03/2025, 11:20 PMmodern-zebra-45309
02/03/2025, 11:20 PMmy version is very old while his is a lot more recent...Since Docker 23.0, BuildKit is the default builder for Docker Desktop and Docker Engine
modern-zebra-45309
02/03/2025, 11:21 PMbright-magician-13023
02/03/2025, 11:21 PMmodern-zebra-45309
02/03/2025, 11:22 PMbright-magician-13023
02/03/2025, 11:22 PM$ docker --version
Docker version 24.0.7, build afdd53b
modern-zebra-45309
02/03/2025, 11:22 PMbright-magician-13023
02/03/2025, 11:22 PMmodern-zebra-45309
02/03/2025, 11:22 PMbright-magician-13023
02/03/2025, 11:23 PMbright-magician-13023
02/03/2025, 11:24 PMmodern-zebra-45309
02/03/2025, 11:26 PMso you suggests he downgraders to the same version as mine?You could try that but I don't think that's a good solution. I'd look into https://github.com/moby/buildkit/issues/5623 and see if your colleague's setup matches the configuration described in the issue
bright-magician-13023
02/03/2025, 11:27 PMbright-magician-13023
02/03/2025, 11:28 PMruff
? unrelated?modern-zebra-45309
02/03/2025, 11:30 PMmodern-zebra-45309
02/03/2025, 11:30 PM/.../.venv/bin/ruff
is most likely the very first file that you're trying to add, it's just the first thing that shows up alphabeticallybright-magician-13023
02/03/2025, 11:31 PMmodern-zebra-45309
02/03/2025, 11:33 PMfind .
in the directory you're building from, it's the first file that's not ignored by Docker that shows up. (You should probably add your virtualenv to .dockerignore
but then you'll just get the next-best file in the error message.)bright-magician-13023
02/03/2025, 11:34 PMmodern-zebra-45309
02/03/2025, 11:35 PMbright-magician-13023
02/03/2025, 11:36 PMbright-magician-13023
02/03/2025, 11:45 PMdocker build
command from the command line works? 🤔
isn't it using the same api to build the image?modern-zebra-45309
02/04/2025, 12:00 AMmodern-zebra-45309
02/04/2025, 12:01 AMbright-magician-13023
02/04/2025, 12:43 AMbright-magician-13023
02/04/2025, 12:46 AMdocker-build
provider or disable containerd
bright-magician-13023
02/04/2025, 12:50 AMchilly-baker-88501
02/04/2025, 11:57 AM