Thanks <@U051221NF> :wave: great to be part of thi...
# welcome
a
Thanks @happy-kitchen-89482 👋 great to be part of this Slack community - I’ve been working at Canva for some time where we use Bazel as a build tool quite well. However, I’m starting my own startup and we use a mix of Django and celery microservices and are starting a small monorepo atm. Therefore I tried to integrate Bazel but had some trouble and have now tried Pants. Sadly I’m still unsuccessful with my first few attempts. There are a few things I want to get out of this: • Dockerise all my Django/Celery microservices. For a production environment this means executing Python binaries such as
gunicorn
and
celery
or otherwise. • Install pip packages such as
psycopg2
that require C libraries. • Still be able to get inside the container and run Django management commands when required.
👋 4
h
Hmm all of these should be possible, I believe. • You can have a pex_binary that depends on your code and runs gunicorn as its entry point (this is pretty common), and a docker_image that depends on that binary and sets it as its entry point. Then when you
./pants package
the image, it will automatically rebuild the binary as needed. • Pants delegates to Pip (via Pex), and should install psycopg2 without difficulty. We use that package internally, for example. • @curved-television-6568 are we able to
./pants run
a docker container with custom args?
c
are we able to 
./pants run
 a docker container with custom args?
Yes,
./pants run <target | Dockerfile> — args..
will pass
args…
to the container entrypoint. Where as, for custom arg for the
docker run
command is pending https://github.com/pantsbuild/pants/pull/13818
h
I guess also, once you have a built image you can create a container outside of Pants
👍 1
I imagine
./pants run
doesn't keep that container alive after it exits? Or does it?
c
It doesn’t keep alive by default, no, but with
--docker-run-args
support (in the pending PR #13818) you could, with:
./pants run --docker-run-args="--detach" …
daemonize the container so it stays alive after pants exits.
p
I have something that might help here, even though it is not done yet. but perhaps point you in the right direction. I have a branch that takes an app called posthog (which is a python django/gunicorn + celery) web app and ports it to use pex (via pants) for packing and deploy. take a look here: https://github.com/asherf/posthog-foss/tree/pants-manual-for-toolchain and specifically: https://github.com/asherf/posthog-foss/tree/pants-manual-for-toolchain/posthog/toolchain https://github.com/asherf/posthog-foss/tree/pants-manual-for-toolchain/toolchain/prod/docker/web
👀 1
❤️ 1
b
@average-spring-99862 please do consider opening issues/feature requests as needed. We aim to make Pants versatile for a wide range of use cases, so getting a deeper understanding of your needs will help us serve you better—as well as ultimately help make Pants more broadly useful for others. Win-win!