I have been trying to get a self contained apptainer image, where all the packages are saved within a directory within the container (such as /usr/local/julia/) instead of a directory on the host (usually /.julia) in order to avoid conflicts and keep my code fully contained. The .def file I am using is:
Bootstrap: docker
From: julia:1.12.1
%post
    export JULIA_DEPOT_PATH="/usr/local/julia"
    export PATH="/usr/local/julia:${PATH}"
%environment
    export JULIA_DEPOT_PATH="/usr/local/julia"
    export JULIA_HISTORY="/usr/local/julia/julia_history"
Building this as a sandbox (apptainer build --sandbox test_sb test.def) and going into the shell in writable mode (apptainer shell --writable test_sb) should, by my understanding, allow me to then run julia and then add packages which will then be saved to the new JULIA_DEPOT_PATH. However, when I run using Pkg it fails to compile. Some packages, like LinearAlgebra load just fine.
I assume I am going about this the wrong way or at the very least I am missing something important! Is what I am trying even feasible with Apptainer and if so what bits am I missing?
Thanks in advance!!