diff --git a/README.md b/README.md index 5f17088..895bb31 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,14 @@ [![CI](https://github.com/heroku/cnb-shim/actions/workflows/ci.yml/badge.svg)](https://github.com/heroku/cnb-shim/actions/workflows/ci.yml) -This is a Cloud Native Buildpack that acts as a shim for [Heroku Buildpacks](https://devcenter.heroku.com/articles/buildpacks). +> [!WARNING] +> This project is not actively maintained and does not support modern Buildpack API and lifecycle versions. +> +> Please switch to native CNB implementations rather than using this shim. +> +> See [Heroku's natively supported CNB languages](https://github.com/heroku/buildpacks#supported-languages) or [search for community buildpacks](https://registry.buildpacks.io/). + +This is a Cloud Native Buildpack that acts as a shim for classic [Heroku Buildpacks](https://devcenter.heroku.com/articles/buildpacks). ## Usage diff --git a/bin/build b/bin/build index 8b96a03..c29abb0 100755 --- a/bin/build +++ b/bin/build @@ -1,9 +1,19 @@ #!/usr/bin/env bash -# fail hard -set -o pipefail -# fail harder -set -eu +set -euo pipefail + +ANSI_RED="\033[1;31m" +ANSI_RESET="\033[0m" + +function display_error() { + echo >&2 + # We have to ANSI wrap each line separately to prevent breakage if line prefixes are added + # later (such as when the builder is untrusted, or when Git adds the "remote:" prefix). + while IFS= read -r line; do + echo -e "${ANSI_RED}${line}${ANSI_RESET}" >&2 + done <<< "${1}" + echo >&2 +} bp_dir=$( cd "$(dirname "$0")/.." @@ -17,6 +27,87 @@ platform_dir="${2:?}" # translate new stack ID to old stack ID export STACK="$CNB_STACK_ID" + +if [[ "${STACK}" == "heroku-"* ]]; then + if [[ "${ALLOW_EOL_SHIMMED_BUILDER:-}" == "1" ]]; then + MSG_PREFIX="WARNING" + MSG_FOOTER="Allowing the build to continue since ALLOW_EOL_SHIMMED_BUILDER is set." + else + MSG_PREFIX="ERROR" + MSG_FOOTER="To ignore this error, set the env var ALLOW_EOL_SHIMMED_BUILDER to 1." + fi + + display_error "$(cat <<-EOF + ####################################################################### + + ${MSG_PREFIX}: This buildpack is a legacy buildpack that has been shimmed + for compatibility with Cloud Native Buildpacks (CNBs) using the + cnb-shim service: + https://github.com/heroku/cnb-shim + + The cnb-shim service is not actively maintained and does not support + modern Buildpack API and lifecycle versions. + + In addition, the legacy builder images that use shimmed buildpacks + (such as 'heroku/buildpacks:20' or 'heroku/builder-classic:22') are + no longer supported and will soon stop receiving security updates. + + Please switch to one of our newer 'heroku/builder:*' builder images, + such as 'heroku/builder:22': + https://github.com/heroku/cnb-builder-images#available-images + + If you are using the Pack CLI, you will need to adjust your '--builder' + CLI argument, or else change the default builder configuration using: + 'pack config default-builder ' + + If you are using a third-party platform to deploy your app, check their + documentation for how to adjust the builder image used for your build. + + If you manually specify a cnb-shim buildpack URL (that refers to + 'cnb-shim.herokuapp.com') you will also need to update that to + the ID of a non-shimmed buildpack. + + See here for Heroku's supported CNB languages: + https://github.com/heroku/buildpacks#supported-languages + + Or search for community buildpacks here: + https://registry.buildpacks.io/ + + ${MSG_FOOTER} + + ####################################################################### + EOF + )" + + if [[ "${ALLOW_EOL_SHIMMED_BUILDER:-}" != "1" ]]; then + exit 1 + fi +else + display_error "$(cat <<-'EOF' + ####################################################################### + + WARNING: This buildpack is a legacy buildpack that has been shimmed + for compatibility with Cloud Native Buildpacks (CNBs) using the + cnb-shim service: + https://github.com/heroku/cnb-shim + + The cnb-shim service is not actively maintained and does not support + modern Buildpack API and lifecycle versions. + + Please switch to a buildpack that supports CNBs natively and so does + not need shimming. + + See here for Heroku's supported CNB languages: + https://github.com/heroku/buildpacks#supported-languages + + Or search for community buildpacks here: + https://registry.buildpacks.io/ + + ####################################################################### + EOF + )" +fi + # copy the buildpack source into the target dir target_dir="$(mktemp -d)/target" cp -R "$source_dir" "$target_dir"