Creating a Docker Base Image for Faster Deployments

My Debian (x86_64) based - Dockerfile fragment :

imho: The key difference might be that I tried to install base Julia and the Julia packages in one step, to keep the final Docker image as small as possible.

FROM debian:bookworm-backports

.....

# Since 1.9.0 Julia, the CPU target is set to "native" by default.
# This settings avoids the need to compile the Julia packages for the specific CPU architecture of the host machine
# Make sure the image can be used on any x86_64 machine by setting JULIA_CPU_TARGET
# to the same value used by the generic julia binaries, see
# https://github.com/JuliaCI/julia-buildkite/blob/4b6932992f7985af71fc3f73af77abf4d25bd146/utilities/build_envs.sh#L23-L31
ENV JULIA_CPU_TARGET="generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1);x86-64-v4,-rdrnd,base(1);znver4,-rdrnd,base(1)"

ENV JULIA_MAJOR=1.11
ENV JULIA_VERSION=1.11.0
ENV JULIA_SHA256=bcf815553fda2ed7910524c8caa189c8e8191a40a799dd8b5fbed0d9dd6b882c
ENV JULIA_DIR=/usr/local/julia
ENV JULIA_PATH=${JULIA_DIR}
ENV JULIA_DEPOT_PATH=${JULIA_PATH}/local/share/julia

RUN set -eux \
    && mkdir ${JULIA_DIR} \
    && cd /tmp  \
    && wget -q https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_MAJOR}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz \
    && echo "$JULIA_SHA256 julia-${JULIA_VERSION}-linux-x86_64.tar.gz" | sha256sum -c - \
    && tar xzf julia-${JULIA_VERSION}-linux-x86_64.tar.gz -C ${JULIA_DIR} --strip-components=1 \
    && rm /tmp/julia-${JULIA_VERSION}-linux-x86_64.tar.gz \
    && ln -fs ${JULIA_DIR}/bin/julia /usr/local/bin/julia \
    \
    && julia -e 'using Pkg; Pkg.add(["PackageCompiler","Arrow","ClickHouse","CpuId","CSV","DataFrames","DuckDB","JSON3","LibPQ","Parquet2","PyCall","SQLite","XLSX"]);Pkg.precompile()' \
    && julia -e 'using CpuId, Arrow, ClickHouse, CSV, DataFrames, DuckDB, JSON3, LibPQ, Parquet2, PyCall, SQLite, XLSX;' \
    && julia -e 'using InteractiveUtils; versioninfo()'

....
3 Likes