acoustic-library-86413
07/28/2023, 1:49 PMPANTS_CONCURRENT=True pants package /path/to/Dockerfile
as my command. I have also tried setting PANTS_PANTSD=False
to see if that made a difference, but it did not. This is a brand new laptop (X1 Carbon) with 16 cores and 32Gb of RAM, so it should be more than up to par for the task.fresh-cat-90827
07/28/2023, 2:08 PMPANTS_CONCURRENT
is used to control how multiple invocations of Pants start i.e. when you run pants test ::
and pants lint ::
in two different terminals.fresh-cat-90827
07/28/2023, 2:11 PMdocker_image
target for each of the files? When you do pants package ::
, Pants runs operations in parallel and I believe building Docker images is safe to build in parallel? In other words, is it safe to run docker build -f first.Dockerfile
and docker build -f second.Dockerfile
each in own terminal?fresh-cat-90827
07/28/2023, 2:12 PMpants package ::
, your Docker images should be built in parallelacoustic-library-86413
07/28/2023, 2:16 PMpants package ::
does reduce the time to 20 seconds. However, I may still be at a loss, given that I'm using Tilt as an intermediary to rebuild images on code changes. This expects a command
as such, which is why it's trying to run 17 instances of Pants concurrently:
custom_build(
ref="my-service",
command="pants package projects/my-service/Dockerfile",
deps=["projects/my-service"]
)
Maybe I'm able to trick it though.flat-zoo-31952
07/28/2023, 2:20 PMpants --loop package ::
to accomplish the same thingflat-zoo-31952
07/28/2023, 2:21 PMacoustic-library-86413
07/28/2023, 2:22 PMpants package ::
should in theory be completely memoized after the first run. So I can probably substitute each command with that and rely on the caching mechanisms in pants.fresh-cat-90827
07/28/2023, 2:23 PMPANTS_CONCURRENT
works as without this enabled, Pants will start up all concurrent invocations (e.g. in other terminals) without pantsd
fresh-cat-90827
07/28/2023, 2:23 PMpantsd
- no memoization (but still local/remote cache)fresh-cat-90827
07/28/2023, 2:24 PMflat-zoo-31952
07/28/2023, 2:24 PM--concurrent
but I wouldn't say this is a well-trodden path. Pants is pretty picky about producing deterministic and reproducible results from your source, so it kinda wants to be the tool that is orchestrating the actions of your builds based on changesflat-zoo-31952
07/28/2023, 2:25 PMTilt
could be integrated as a tool that can be published
?acoustic-library-86413
07/28/2023, 2:25 PMPANTS_CONCURRENT
or if it also brings improved concurrent performance.acoustic-library-86413
07/28/2023, 2:26 PMpants --loop package ::
and using deps
in Tilt to have the service be redeployed on changes. That way pants will only be invoked once. Regardless, running with ::
was a super helpful tip, thanks!acoustic-library-86413
07/28/2023, 2:28 PMpants publish
at all, I'll have to give it a look. That could possibly work as well. That way I could have something running pants publish
to push to my local registry, and have Tilt simply use this pre-built image and again invalidating manually for local development using deps
.fresh-cat-90827
07/28/2023, 2:30 PMRegardless, running withyou are very welcome. If you ever need to tune what targets you want to pass to a goal, you may find this https://www.pantsbuild.org/docs/goals#goal-arguments helpful, e.g. you can ignore targets withwas a super helpful tip, thanks!::
-
as well.flat-zoo-31952
07/28/2023, 2:31 PMacoustic-library-86413
07/28/2023, 2:42 PMpants package
to be honest. If I get it working I'll write up a blog post about the entire process.
The end goal here is to have a development environment that is identical to the one used in staging and production, with the exception of environment variables and secrets, whilst still maintaining features like hot reloading on local dev. I've had it working superbly for a while now in a non-monorepo context, so this is really just the missing piece for what I believe would be a great developer experience.fresh-cat-90827
07/28/2023, 2:49 PMIf I get it working I'll write up a blog post about the entire process.sounds awesome, feel free to share any drafts, happy to help with proofreading/formatting/etc if desired π
acoustic-library-86413
07/28/2023, 3:07 PMpants package ::
without making any changes to any file isn't being memoized. I would assume images whose dependencies have not been altered to be cached.acoustic-library-86413
07/28/2023, 3:07 PMhappy-kitchen-89482
07/28/2023, 6:24 PMpackage
was building a .pex file or something. But Docker images are cached externally to Pants, by the Docker daemon.happy-kitchen-89482
07/28/2023, 6:25 PMdocker build
doesn't produce an image file that Pants can cache, it produces a side effect in its own cache.happy-kitchen-89482
07/28/2023, 6:25 PMhappy-kitchen-89482
07/28/2023, 6:25 PMacoustic-library-86413
07/28/2023, 6:25 PMhappy-kitchen-89482
07/28/2023, 6:26 PMdocker
produced some artifact that Pants could internally cachehappy-kitchen-89482
07/28/2023, 6:26 PMhappy-kitchen-89482
07/28/2023, 6:26 PMflat-zoo-31952
07/28/2023, 6:28 PMdocker info
on it to poll if it still is thereacoustic-library-86413
07/28/2023, 6:28 PMpants --loop package ::
in a background process, and have tilt bring up the stack. I could then set up file watchers to have it re-deploy on file-changes, but since they are now indepedentent, Tilt would have no way of knowing if the image has been rebuilt yet.flat-zoo-31952
07/28/2023, 6:29 PMhappy-kitchen-89482
07/28/2023, 6:30 PMacoustic-library-86413
07/28/2023, 6:30 PMhappy-kitchen-89482
07/28/2023, 6:30 PMdocker info
trick would workflat-zoo-31952
07/28/2023, 6:31 PMpodman
instead of docker and configured it to keep all of its state in directories pants knows about and can cache, but that would be a ton of work for something that would only work on linuxflat-zoo-31952
07/28/2023, 6:33 PMacoustic-library-86413
07/28/2023, 6:33 PMflat-zoo-31952
07/28/2023, 6:34 PMflat-zoo-31952
07/28/2023, 6:35 PMacoustic-library-86413
07/28/2023, 6:36 PMdocker info
as you mentioned.flat-zoo-31952
07/28/2023, 6:37 PMdocker info
hack might be "okay" for many use cases). I doubt a plugin could do that though because it the non-cacheable nature is probably specified on the rule get itselfflat-zoo-31952
07/28/2023, 6:37 PMflat-zoo-31952
07/28/2023, 6:39 PMflat-zoo-31952
07/28/2023, 6:40 PMpants --loop
acoustic-library-86413
07/28/2023, 6:46 PMpants -loop package projects/::
in a separate process
2. Allow Tilt
to start the services, display the logs, status etc. for my developers
3. Integrate a button on each service into the Tilt UI to restart it on demand with the latest image
This isn't quite as good as native hot reloading, but it should be far less taxing on the system, enables us to have faster startup times, and at least the containers will build automatically.acoustic-library-86413
07/28/2023, 6:49 PMflat-zoo-31952
07/28/2023, 7:00 PMacoustic-library-86413
07/29/2023, 8:39 PMpants package
followed by tilt trigger <service>
to trigger a restart once the image has been built. It doesn't work as well as true hot reloading and file-watchers would, but at least it's just one click and relatively fast.