Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Buildpack compile fixes and refactoring #177

Merged
merged 7 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
34 changes: 15 additions & 19 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir> <env-dir>

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