Hi, I am new to pants and build systems in general...
# general
c
Hi, I am new to pants and build systems in general, I would like to be able to run end/or deploy services described in a docker-compose file. I could not find any mention to docker-compose files on the docker session of the docs. As an exemple, I am using the following command to build and run my application on docker:
./pants run --docker-run-args="--gpus all --privileged -v /dev:/dev" docker/semantic_segmentation/Dockerfile-gpu
I would like to call a docker-compose file with all the run-args defined in it, how can that be done though pants, so it will build the .pex file?
👋 2
b
I don't think anyone has added docker-compose support yet. And I don't see an issue. Mind filing one with as much useful info as possible?
I suspect it wouldn't be too hard to add, once someone gets familiar with the internals. If you're interested in implementing, let us know we'd love to help you!
c
Thank you for the reply. But there is a way of storing default
docker-run-args
per Dockerfile? I saw that I can add
run_args = ["arg",...]
on the
pants.toml
, but this would act globally.
b
I don't see a field on https://www.pantsbuild.org/docs/reference-docker_image for this. It can likely be added, though. Same spiel about issues and contributions apply here as well 🙂
h
Hi @creamy-ghost-8929 . We're always interested in improving Docker support, and docker-compose does come up from time to time, so an issue would be really valuable so we can use it to start that conversation.
Adding per-target arguments for
run
is interesting, and might even make sense as a generic feature, not just for
docker_image
targets but for any runnable target
What are some examples of args you'd want to use this for?
b
(I think the original post has one example in it 😉 )
h
Ah, so like
--gpus all --privileged -v /dev:/dev
b
Port forwarding is also very common
h
Yeah, makes sense
Wondering if it makes sense as a generic feature of runnable targets?
c
Thank you. I found a work around by building the image with ./pants package <path-to-Dockerfile>, then referencing the built image on the docker-compose.yaml file. I am still learning how to use pants, once I get a better grasp, I will be able to explain better the use cases and I will create the issue.
b
@happy-kitchen-89482 I think so, although I'd maybe wanna think about it more. we probably want to make a convention about it
h
Yeah, if we think that's the direction it would be good to add it the right way
maybe a RunnableTarget mixin or something
b
For reference,
python_*
related targets now have
run_goal_use_sandbox
. so slight convention about using
run_goal_...