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

high-yak-85899

12/06/2022, 8:54 PM
I want to make a macro that autogenerates a
pex_binary
and
docker_image
target for me for the majority of simple cases where we're just doing the standard base image and copying in a pex. Any recommendations on how to autopopulate the
COPY
line of the
Dockerfile
? I'd like to avoid requiring the user to specify the full path to the module that serves as the entrypoint for the
pex_binary
, but I'm not sure there's another way.
b

bitter-ability-32190

12/06/2022, 8:54 PM
Have you tried
build_file_dir()
?
h

high-yak-85899

12/06/2022, 8:55 PM
I have not!
Is that in the docs somewhere?
b

bitter-ability-32190

12/06/2022, 8:55 PM
It's a function you can use in build files, it returns a
pathlib.PurePath
to the current build file dir
Unfortunately, no not yet. It uses stuff which doesn't get auto-generated docs 😞
b

broad-processor-92400

12/06/2022, 9:03 PM
The thread at https://pantsbuild.slack.com/archives/C046T6T9U/p1668559186539269 has what we use (using
build_file_dir
)
h

high-yak-85899

12/06/2022, 11:05 PM
Wow, I wish I had explored macros sooner! Our containerization process just got much simpler.
❤️ 1
5 Views