Bootstrap: library
From: default/debian:10

%post
    # Copied from https://github.com/docker-library/julia/blob/master/1.6/buster/Dockerfile
    apt-get -y update
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        procps
    rm -rf /var/lib/apt/lists/*

    export JULIA_GPG="3673DF529D9049477F76B37566E3C7DC03D6E495"
    export JULIA_VERSION="1.6.1"
    export JULIA_PATH=/usr/local/julia
    export PATH=$JULIA_PATH/bin:$PATH

    savedAptMark="$(apt-mark showmanual)"

    if ! command -v gpg > /dev/null; then
        apt-get update
        apt-get install -y --no-install-recommends \
            gnupg \
            dirmngr
        rm -rf /var/lib/apt/lists/*
    fi

    export tarArch='x86_64'
    export dirArch='x64'
    export sha256='7c888adec3ea42afbfed2ce756ce1164a570d50fa7506c3f2e1e2cbc49d52506'

    export folder="$(echo "$JULIA_VERSION" | cut -d. -f1-2)"
    curl -fL -o julia.tar.gz.asc "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${folder}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz.asc"
    curl -fL -o julia.tar.gz     "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${folder}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz"

    echo "${sha256} *julia.tar.gz" | sha256sum -c -

    export GNUPGHOME="$(mktemp -d)"
    gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$JULIA_GPG"
    gpg --batch --verify julia.tar.gz.asc julia.tar.gz
    command -v gpgconf > /dev/null && gpgconf --kill all
    rm -rf "$GNUPGHOME" julia.tar.gz.asc

    mkdir "$JULIA_PATH"
    tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1
    rm julia.tar.gz

    apt-mark auto '.*' > /dev/null
    [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false

%environment
    export JULIA_PATH=/usr/local/julia
    export PATH=$JULIA_PATH/bin:$PATH

%test
    if [ ! "$(command -v julia)" ]; then
        echo "command julia not found!"
        FAILED_TESTS="TRUE"
    fi

    if [ ! "$(command -v bash)" ]; then
        echo "command bash not found!"
        FAILED_TESTS="TRUE"
    fi

    if [ ! "$(command -v ps)" ]; then
        echo "command ps not found!"
        FAILED_TESTS="TRUE"
    fi

    if [ -n "$FAILED_TESTS" ]; then
        exit 1
    fi


%runscript
    julia "$@"

%labels
    Author 25492070+MillironX@users.noreply.github.com
    Version v2.3.1
