Hello all, I'm using `FROM <http://gcr.io/distrole...
# general
f
Hello all, I'm using
FROM <http://gcr.io/distroless/python3-debian12@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160|gcr.io/distroless/python3-debian12@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160> AS runtime
in a multi-stage build, but pants errors out with:
Copy code
❯ pants --docker-build-verbose package src/docker/repr
15:18:55.89 [INFO] Completed: Building docker image repr:test
15:18:55.89 [INFO] Completed: Building docker image repr:latest
15:18:55.89 [INFO] Completed: Building docker image repr:debug
15:19:32.62 [INFO] Canceled: Building docker image repr:debug
15:19:32.63 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

DockerBuildTargetStageError: The 'target_stage' field in `docker_image` src/docker/repr:runtime was set to 'runtime', but there is no such stage in `src/docker/repr/Dockerfile`. Available stages: builder, debug, smoke_tests, upstream_debug.

❯
Any idea why this might be?
b
Can you share
src/docker/repr/Dockerfile
(or at least the
FROM
lines of that file)?
f
Copy code
❯ grep FROM src/docker/u21repr/Dockerfile
FROM golang:1.23-bookworm AS builder
FROM <http://gcr.io/distroless/python3-debian12@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160|gcr.io/distroless/python3-debian12@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160> AS runtime
FROM <http://gcr.io/distroless/python3-debian12:debug|gcr.io/distroless/python3-debian12:debug> AS upstream_debug
FROM runtime AS debug
FROM debug AS smoke_tests

❯
b
Weird, why is that one special! Theories: 1. The
runtime
name is special-cased for some reason: can you try just changing it to something else temporarily? 2. The
@sha256:...
reference is handled differently to the
:<tag>
references: can you try switch it to
:debug
or something temporarily?
f
1. Changing
runtime
to
foobar
in both the pants BUILD and Dockerfile results in the same error message (ofc
foobar
stage is now not found instead of
runtime
) 2. Switching
FROM <http://gcr.io/distroless/python3-debian12@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160|gcr.io/distroless/python3-debian12@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160> AS runtime
to a tag works fine.
b
cool, sounds like we have the cause! I don't see a bug about this in https://github.com/pantsbuild/pants/issues. Could you file one? Thanks! (Would you be interested in trying to fix it?)
Potential workaround might be supplying a tag in addition to the sha?
FROM .../python3-debian12:latest@sha256:...
(i have a vague memory that this is valid syntax and might be enough to 'trick' pants, while still using the pinned hash?)
f
I'll file a bug for this first thing tomorrow and I don't mind in trying to help fixing this...
👍 1
Oh, I'll give that a try as well. What happens if the image is retagged? I guess this stops working then?
b
I think the tag is ignored in that case. I tried
docker pull  <http://gcr.io/distroless/python3-debian12:totally_made_up_not_a_real_tag@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160|gcr.io/distroless/python3-debian12:totally_made_up_not_a_real_tag@sha256:8e432c787b5c0697dfbfd783120351d90fd5f23ba9fff29532bbdbb87bc13160>
and that worked fine
f
Indeed, that works fine, interesting 🙂 Anyway, thank you and I'll file that bug!
b
Cool! Hm, weird, the relevant test seems to cover this case and say something about it (
Stage 2 ...
), but not yet obvious to me why, so definitely file a bug and we can see about changing that: https://github.com/pantsbuild/pants/blob/48f4713bdd2d820af82102bd95d3ff492a2b1b92/src/rust/engine/dep_inference/src/dockerfile/tests.rs#L83-L103
👍 1
f
Thank you for your help @broad-processor-92400. Let me know what I can do to try and fix this.