Skip to content

Commit

Permalink
Set $HOME to $CNB_APP_DIR at launch for compatibility with profile.d …
Browse files Browse the repository at this point in the history
…scripts

See: heroku#23

Squashed commit of the following:

commit 1c3d01d
Author: Kamal Nasser <[email protected]>
Date:   Tue Feb 2 00:42:02 2021 +0200

    set HOME env to app dir at runtime for profile.d scripts
  • Loading branch information
kamaln7 committed Feb 23, 2021
1 parent 9ba88d4 commit 858049c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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"

0 comments on commit 858049c

Please sign in to comment.