Hi all, I've got a fairly unusual question (judgin...
# general
c
Hi all, I've got a fairly unusual question (judging by the search results) regarding the
pantsd
. I have a dev setup where we're using a wrapper layer to define higher-order dev commands written in Go. This layer also allows us to seamlessly execute each dev command in a disposable Docker container (disposable part is crucial as each command invocation starts/stops a separate container). So far it worked well for us as it allowed to keep dev environments pinned via Dockerfile. Howewer once we started working with Pants we noticed the overhead from Pants bootstrap that adds an uncomfortable 10sec delay to each command execution. Enabling
pantsd
and running commands locally has removed the delay. What I am looking for now is a way to run
pantsd
locally and expose it somehow inside the container. I did not find a lot of information about the pantsd in the v2 documentation which is why I'm writing here. In short, here are the questions that I'm looking an answer for: 1. Is it possible to start
pantsd
standalone? 2. Is it possible to specify not only
pantsd
connection port (
--pantsd-pailgun-port
) but also the IP to be to access locally running pantsd from within container? 3. What dependencies does
pantsd
have? Does it need Python? Or is it a pre-compiled binary?
g
I'd suggest reading up on Pants docker environments, which does this for you. https://www.pantsbuild.org/dev/docs/using-pants/environments.
(I don't really understand your core ask; so in classic SO fashion I'm going to suggest doing it differently.)
c
> I don't really understand your core ask; so in classic SO fashion I'm going to suggest doing it differently Fair point, let me add some substance to the question: Given a Dockerfile:
Copy code
// myimage:latest
FROM rockylinux:9-minimal

RUN <install some deps>
RUN <install Pants launcher>
// Other image adjustments
When I run following commands
Copy code
$ docker run --rm -v <local_workdir>:<container_workdir> myimage:latest pants package ...
// and again...
$ docker run --rm -v <local_workdir>:<container_workdir> myimage:latest pants package ...
Then I don't have to wait for pants bootstrap on the 2nd run:
Copy code
Bootstrapping Pants 2.26.0
Installing pantsbuild.pants==2.26.0 into a virtual environment at ...
New virtual environment successfully created at ...
I forgot to mention that I'm already setting up
local_store_dir
and
named_caches_dir
to ensure that cache is reused between containers runs
> I'd suggest reading up on Pants docker environments, which does this for you. https://www.pantsbuild.org/dev/docs/using-pants/environments. Thanks for the pointer, I didn't know about this feature. Although after an initial glance at the docs I didn't find any mention of pantsd or any sort of host/container communication so it's not clear how this built in feature might be reusing a single pantsd daemon to benefit from the resulting speed up (thus not making it clear how I might reuse the mechanism with a custom Dockerfile)
g
I'll admit I don't use the Docker environments personally, but my understanding is that you give it an image with dependencies, and it'll run any subprocesses etc inside that container. So instead of getting communication out to
pantsd
, you've got
pantsd
running commands in that container.
c
you've got
pantsd
running commands in that container.
Ok, but this only helps avoid bootstrapping delays if the container outlives multiple commands. In my case container is ephemeral and does not outlive the command it was created to execute
g
Yes; which is what Pants docker environments do. What I'm suggesting (to investigate) is instead of your tool running pants commands in a container, you run pants commands on the host and let pants do the container bit internally. I'm not sure why/if having the container be temporary is a requirement.
c
Ok, I think I get what you mean now. Btw, this seems to be the relevant piece of documentaiton: https://www.pantsbuild.org/dev/reference/targets/docker_environment