https://pantsbuild.org/ logo
#general
Title
# general
f

flat-queen-95161

07/14/2022, 9:22 PM
What is the syntax for copying a go binary built by pants package into a Dockerfile built by pants package?
Copy code
% ls dist/cmd.hello-world/bin
dist/cmd.hello-world/bin

% pants filter --target-type=go_binary ::
cmd/hello-world:bin

# From the Dockerfile
...
COPY cmd.hello-world/bin /go/bin/hello-world

# Build docker image
pants package cmd/hello-world:docker
...
 > [2/4] COPY cmd.hello-world/bin /go/bin/hello-world:
------
failed to compute cache key: "/cmd.hello-world/bin" not found: not found
h

high-yak-85899

07/14/2022, 9:23 PM
Need
bin.pex
I think
So
cmd.hello-world/bin.pex
f

flat-queen-95161

07/14/2022, 9:25 PM
how does a pex (python executable) relate to golang?
h

high-yak-85899

07/14/2022, 9:33 PM
Oh
my b. I missed the go part
It doesn't
f

flat-queen-95161

07/14/2022, 10:13 PM
np. any go fans out there who got pants working with docker builds?
h

high-yak-85899

07/14/2022, 10:17 PM
I'm hoping to do this soon so I'm interested in knowing what you find.
b

busy-vase-39202

07/14/2022, 11:03 PM
@fast-nail-55400 or @curved-television-6568 might have a suggestion.
f

flat-queen-95161

07/15/2022, 12:18 AM
Copy code
go_binary(
    name="bin",
)
docker_image(
    name="docker",
    dependencies=[
        ":bin",
    ],
)
b

bitter-ability-32190

07/15/2022, 12:24 AM
docker_image
supports
dependencies
with anything `package`able
It also supports dependency inference on those `package`able things with an
output_path
And, your best debugging tool is always running pants with
--no-process-cleanup
and poking around the relevant sandbox 🙂
h

happy-kitchen-89482

07/16/2022, 4:18 PM
Good question, yeah, I'm pretty sure the targets as you have them will cause the binary to be copied into the sandbox, and the question is just to figure out its path (which of course should be derivable from the information at hand, I just don't know the derivation). So as Joshua suggests, finding the binary in the sandbox in this one case should help figure it out in this and presumably future cases, as I'm assuming the path will be some obvious function of the path and target namee
c

curved-television-6568

07/16/2022, 4:34 PM
The contents of the build context should be presented in the logs in case of docker build issues. Is it not?
5 Views