From 858049c965803494cbb6e4ceb4b567bff59af7d9 Mon Sep 17 00:00:00 2001 From: Kamal Nasser Date: Tue, 23 Feb 2021 17:18:04 +0200 Subject: [PATCH] Set $HOME to $CNB_APP_DIR at launch for compatibility with profile.d scripts See: https://github.com/heroku/cnb-shim/pull/23 Squashed commit of the following: commit 1c3d01d48042abfed962dad4bebff32ba09eb1e1 Author: Kamal Nasser Date: Tue Feb 2 00:42:02 2021 +0200 set HOME env to app dir at runtime for profile.d scripts --- bin/build | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/build b/bin/build index a0b31b1..d7809cf 100755 --- a/bin/build +++ b/bin/build @@ -10,6 +10,7 @@ source_dir="${bp_dir}/target" layers_dir="${1:?}" platform_dir="${2:?}" +app_dir="$(pwd)" # translate new stack ID to old stack ID export STACK="$CNB_STACK_ID" @@ -24,13 +25,18 @@ cache_dir="${layers_dir}/shim" mkdir -p "${cache_dir}" echo "cache = true" > ${layers_dir}/shim.toml -"${target_dir}/bin/compile" "$(pwd)" "${cache_dir}" "${platform_dir}/env" +"${target_dir}/bin/compile" "$app_dir" "${cache_dir}" "${platform_dir}/env" # copy profile.d scripts into a layer so they will be sourced if [[ -d .profile.d ]]; then profile_dir="${layers_dir}/profile" + mkdir -p "${profile_dir}/profile.d" cp .profile.d/* "${profile_dir}/profile.d/" + + mkdir -p "${profile_dir}/env.launch" + echo -n "$app_dir" > "${profile_dir}/env.launch/HOME.override" + echo "launch = true" > "${profile_dir}.toml" fi @@ -41,4 +47,4 @@ if [[ -f "${target_dir}/export" ]]; then fi # run bin/release, read Procfile, and generate launch.toml -"${bp_dir}/bin/release" "${target_dir}" "${layers_dir}" "${platform_dir}" "$(pwd)" +"${bp_dir}/bin/release" "${target_dir}" "${layers_dir}" "${platform_dir}" "$app_dir"