@@ -5,7 +5,7 @@ FROM julia:${JULIA_VERSION}
55# Install some dependencies
66RUN /bin/sh -c 'export DEBIAN_FRONTEND=noninteractive \
77 && apt-get update \
8- && apt-get install -y ca-certificates earlyoom gcc git gpg jq \
8+ && apt-get install -y --no-install-recommends ca-certificates earlyoom git gpg jq \
99 && apt-get --purge autoremove -y \
1010 && apt-get autoclean \
1111 && rm -rf /var/lib/apt/lists/*'
@@ -34,8 +34,16 @@ ARG CUDA_VERSION=13.0
3434ARG REACTANT_CUDA_VERSION=13.1
3535
3636# We need a stub `libcuda.so.1` in order to load a CUDA-enabled build of Reactant_jll, but
37- # an empty shared library with that soname is sufficient. Yes, I'm evil.
38- RUN gcc -shared -Wl,-soname=libcuda.so.1 -o libcuda.so.1 /dev/null
37+ # an empty shared library with that soname is sufficient. Install and remove GCC in the
38+ # same step, to avoid caching its entire installation outside of this step.
39+ RUN /bin/sh -c 'export DEBIAN_FRONTEND=noninteractive \
40+ && apt-get update \
41+ && apt-get install -y --no-install-recommends gcc libc-dev \
42+ && gcc -shared -Wl,-soname=libcuda.so.1 -o libcuda.so.1 /dev/null \
43+ && apt-get remove -y gcc libc-dev \
44+ && apt-get --purge autoremove -y \
45+ && apt-get autoclean \
46+ && rm -rf /var/lib/apt/lists/*'
3947
4048# pre-install the CUDA toolkit from an artifact. we do this separately from CUDA.jl so that
4149# this layer can be cached independently. it also avoids double precompilation of CUDA.jl in
@@ -65,21 +73,14 @@ RUN . /julia_cpu_target.sh && JULIA_PKG_PRECOMPILE_AUTO="false" julia --color=ye
6573RUN . /julia_cpu_target.sh && julia --color=yes --check-bounds=${CHECK_BOUNDS} -e 'using Pkg; Pkg.add(; name="CUDA", version="6.0"); \
6674 using CUDA; CUDA.precompile_runtime()'
6775
68- # Clone Breeze
69- RUN git clone --depth=1 https://github.com/NumericalEarth/Breeze.jl /tmp/Breeze.jl
70-
71- # Instantiate environment
72- RUN . /julia_cpu_target.sh && LD_LIBRARY_PATH='.' julia --color=yes --project=/tmp/Breeze.jl/${ENV_NAME} --check-bounds=${CHECK_BOUNDS} -e 'using Pkg; Pkg.instantiate(); Pkg.gc()'
73-
74- # Clean up Breeze clone
75- RUN rm -rf /tmp/Breeze.jl
76+ # Clone NumericalEarth and instantiate environment and clean up NumericalEarth clone within
77+ # the same step so that we don't cache everything was written in this directory. In
78+ # particular, the CondaPkg environment would occupy lots of space in this layer, needlessly.
79+ RUN git clone --depth=1 https://github.com/NumericalEarth/Breeze.jl /tmp/Breeze.jl && \
80+ . /julia_cpu_target.sh && LD_LIBRARY_PATH='.' julia --color=yes \
81+ --project=/tmp/Breeze.jl/${ENV_NAME} \
82+ --check-bounds=${CHECK_BOUNDS} -e 'using Pkg; Pkg.instantiate()' && \
83+ rm -rf /tmp/Breeze.jl
7684
7785# Remove fake libcuda.so.1
7886RUN rm -fv libcuda.so.1
79-
80- # Uninstall packages not needed at runtime, to reduce size of image
81- RUN /bin/sh -c 'export DEBIAN_FRONTEND=noninteractive \
82- && apt-get remove --autoremove -y gcc \
83- && apt-get --purge autoremove -y \
84- && apt-get autoclean \
85- && rm -rf /var/lib/apt/lists/*'
0 commit comments