Cannot prevent repeated precompilation in docker runtime

Hello, I’m deploying a julia script via docker, and can’t seem to prevent precompilation during runtime, which is very expensive, time-wise.

So I observe that precompilation happens normally during the build time, but it always seems to repeat again during each runtime.

I’ve already tried a bunch of tricks (see below), and wondering if some kind of CPU architecture mismatch might be triggering this.

Any advice would be greatly appreciated.

FROM julia:1.12-bookworm

ENV JULIA_PROJECT=/app \
    JULIA_DEPOT_PATH=/usr/local/julia-depot \
    JULIA_NUM_THREADS=auto \
    JULIA_CPU_TARGET=generic \
    JULIA_PKG_PRECOMPILE_AUTO=0

RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    ca-certificates \
    bzip2 \
    coreutils \
    perl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY Project.toml ./
RUN julia --project=/app -e 'using Pkg; Pkg.instantiate()'

COPY src ./src
COPY scripts/my_script.jl ./scripts/my_script.jl
RUN julia --project=/app -e 'using Pkg; Pkg.precompile(); using MyPackage'
RUN julia --project=/app --compiled-modules=existing --pkgimages=existing /app/scripts/my_script.jl --help

RUN useradd --create-home --uid 10001 appuser \
    && mkdir -p /workspace /output \
    && chown -R appuser:appuser /app /workspace /output /usr/local/julia-depot

USER appuser

ENTRYPOINT ["julia", "--project=/app", "--compiled-modules=existing", "--pkgimages=existing", "/app/scripts/my_script.jl"]
CMD ["--help"]