Install only project dependencies? (for more efficient cached docker builds)

I have a project with many dependencies that I’m currently deploying with Docker. I am able to install my package and it works fine by using:

RUN /opt/julia/bin/julia -e 'using Pkg; Pkg.develop(path="/opt/MyPackage"); import MyPackage'

But now every time I rebuild the docker image all ~100 dependencies are installed and built again. Is there any way I can easily install only my project’s dependencies from its Project.toml file with a separate command that Docker will be able to cache, and then do the actual install of my project with a 2nd command?

Maybe use three steps. First COPY a basic template of your package, including Project.toml, but not the src. Then do the above RUN line to install it and it’s dependencies. Then COPY in the actual source.

This way, the first two commands are cached if you only change the source.

1 Like