diff --git a/CHANGELOG.md b/CHANGELOG.md index 48effa5f..0cc910a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* [#177](https://github.com/heroku/heroku-buildpack-static/pull/177) Make curl retry in case of a failed download +* [#177](https://github.com/heroku/heroku-buildpack-static/pull/177) Fix the printing of the installed nginx version +* [#177](https://github.com/heroku/heroku-buildpack-static/pull/177) Switch to the recommended S3 URL format +* [#177](https://github.com/heroku/heroku-buildpack-static/pull/177) Remove unused archive caching +* [#177](https://github.com/heroku/heroku-buildpack-static/pull/177) Fail the build early on unsupported stacks ## v4 (2019-09-18) diff --git a/bin/compile b/bin/compile index fc0f36f7..3f351599 100755 --- a/bin/compile +++ b/bin/compile @@ -1,36 +1,32 @@ #!/usr/bin/env bash # bin/compile -set -e +set -euo pipefail build_dir=$1 cache_dir=$2 env_dir=$3 bp_dir=$(dirname $(dirname $0)) -fetch_nginx_tarball() { - local version="1.9.7" - local tarball_file="nginx-$version.tgz" - local stack="cedar-14" - local nginx_tarball_url="https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/nginx/$stack/nginx-$version-ngx_mruby.tgz" - local dest_path="$cache_dir/$stack/$tarball_file" - - if [ -f "$dest_path" ]; then - echo -n "cat $dest_path" - else - echo -n "curl -L $nginx_tarball_url" - fi -} +case "${STACK}" in + cedar-14|heroku-16|heroku-18) + # The buildpack for some time has used binaries meant for Cedar-14 on all stacks (see #165). + # In the future these stacks should be migrated to newer nginx built against the correct stack. + nginx_archive_url='https://heroku-buildpack-ruby.s3.amazonaws.com/nginx/cedar-14/nginx-1.9.7-ngx_mruby.tgz' + ;; + *) + echo "Stack ${STACK} is not supported!" + exit 1 + ;; +esac mkdir -p $build_dir/bin -$(fetch_nginx_tarball) | tar xzC $build_dir/bin -nginx_version=$($build_dir/bin/nginx-$STACK -V 2>&1 | head -1 | awk '{ print $NF }') +curl -sSf --retry 3 --connect-timeout 3 "${nginx_archive_url}" | tar -xzC "${build_dir}/bin" +nginx_version=$("${build_dir}/bin/nginx" -v |& cut -d '/' -f 2-) cp -a $bp_dir/scripts/{boot,config} -t $build_dir/bin/ -echo "-----> Installed ${nginx_version} to /app/bin" +echo "-----> Installed nginx ${nginx_version} to /app/bin" mkdir -p $build_dir/config cp $bp_dir/scripts/config/templates/mime.types $build_dir/config mkdir -p $build_dir/logs - -exit 0