Search code examples
buildpack

Binary Installed Through Buildpack Not Found After Creating Container


I have a buildpack (see code below) that installs a Julia binary and adds it to PATH. The buildpack runs without any issues but after I build the container the binary is not available.

Does anyone have any ideas on what could be the issue?

#!/usr/bin/env bash
set -euo pipefail

# 1. Get Args
layers_dir="$1"
env_dir="$2/env"
plan_path="$3"

# 2. Download Julia
JULIA_LAYER_DIR="${layers_dir}/julia"
JULIA_VERSION=$(curl -s "https://api.github.com/repos/JuliaLang/julia/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
JULIA_MINOR_VERSION=$(echo $JULIA_VERSION | grep -Po "^[0-9]+.[0-9]+")

curl -o julia.tar.gz "https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_MINOR_VERSION}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz"

mkdir -p ${JULIA_LAYER_DIR}
echo ${JULIA_LAYER_DIR}
tar xf julia.tar.gz --strip-components=1 -C ${JULIA_LAYER_DIR}

# 3. Add Julia to PATH
export PATH=${JULIA_LAYER_DIR}/bin:$PATH

rm -rf julia.tar.gz

# 4. Install Julia packages
#julia --project=. -e 'using Pkg; Pkg.instantiate()'
julia packages.jl

Solution

  • You'll need to set launch = true in the file ${JULIA_LAYER_DIR}.toml. For example:

    cat <<TOML > ${JULIA_LAYER_DIR}.toml
    [types]
      launch = true
    TOML
    

    https://buildpacks.io/docs/buildpack-author-guide/caching-strategies/