# Speed up dockerization

**URL:** https://discourse.julialang.org/t/speed-up-dockerization/135971
**Category:** General Usage
**Tags:** docker, package-compiler
**Created:** [March 2, 2026, 6:39pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971 "2026-03-02T18:39:18Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [March 2, 2026, 6:39pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/1 "2026-03-02T18:39:18Z")

</div>

I am deploying Julia code using docker. In order to speed up the startup of the container I build a package using PackageCompiler.jl.

However this is painfully slow, as it rebuilds everything even if I change one line in the final main entrypoint. Are there any best practices to speed this up? How could I build a sysimage with just the packages and do not precompile my application code? Do I just make a sysimage in a `builder` stage and copy it over into the the final output stage of the image, together with the main application source code?

---

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [March 2, 2026, 7:21pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/2 "2026-03-02T19:21:09Z")

</div>

I went with a persistent build cache that stores the precompiled package images so that the dependencies don’t need to be recompiled every time. I followed [this post.](https://discourse.julialang.org/t/proposed-julia-docker-workflow-to-use-a-persistent-depot/97963)

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [March 2, 2026, 8:22pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/3 "2026-03-02T20:22:11Z")

</div>

Is the source code of the packages still in the image? I cannot have that for some private packages.

---

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [March 3, 2026, 11:02am UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/4 "2026-03-03T11:02:49Z")

</div>

Oh, I see. In our case that wasn’t a restriction, and the source code is indeed present in the image.

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [March 3, 2026, 11:20am UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/5 "2026-03-03T11:20:12Z")

</div>

If I do not need to copy the whole `.julia` this might be possible.

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [March 3, 2026, 11:21am UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/6 "2026-03-03T11:21:12Z")

</div>

In my limited experience, PrecompileTools.jl can usually make the load time fast enough, so I don’t resort to PackageCompiler, considering that there’s also a startup delay in launching any Docker container. (To clarify, the precompile process is added as a build step for the Docker image.)

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [March 3, 2026, 4:23pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/7 "2026-03-03T16:23:14Z")

</div>

Also nice. What part of the JULIA\_DEPOT\_PATH do I need to copy over from the builder stage?

---

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [March 3, 2026, 7:05pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/8 "2026-03-03T19:05:10Z")

</div>

Sorry, I meant just as a step in Dockerfile, not in a separate builder image. If you run “Pkg.precompile()” in the Dockerfile, then the precompile cache is saved.

---

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [March 3, 2026, 9:52pm UTC](https://discourse.julialang.org/t/speed-up-dockerization/135971/9 "2026-03-03T21:52:28Z")

</div>

I understood that, but I do not want to copy everything. As I wrote earlier I specifically do not want the source code in the final image.
