https://pantsbuild.org/ logo
#welcome
Title
# welcome
a

average-spring-99862

12/15/2021, 10:18 AM
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

happy-kitchen-89482

12/15/2021, 2:07 PM
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

curved-television-6568

12/15/2021, 2:25 PM
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

happy-kitchen-89482

12/15/2021, 8:26 PM
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

curved-television-6568

12/15/2021, 9:09 PM
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

polite-garden-50641

12/16/2021, 12:14 AM
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

busy-vase-39202

12/17/2021, 1:35 AM
@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!