Skip to content

Commit

Permalink
Update for Heroku 22 Stack
Browse files Browse the repository at this point in the history
* Remove Heroku 16
* Add Heroku 22
* Update dependency versions
* Rebuild
  • Loading branch information
agrberg committed Jul 19, 2022
1 parent 3ede917 commit a50ca1e
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
build: build-heroku-16 build-heroku-18 build-heroku-20

build-heroku-16:
@echo "Building nginx in Docker for heroku-16..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-16" -e "NGINX_VERSION=1.9.5" -e "PCRE_VERSION=8.37" -e "HEADERS_MORE_VERSION=0.261" -w /buildpack heroku/heroku:16-build scripts/build_nginx /buildpack/nginx-heroku-16.tgz
build: build-heroku-18 build-heroku-20 build-heroku-22

build-heroku-18:
@echo "Building nginx in Docker for heroku-18..."
Expand All @@ -12,6 +8,10 @@ build-heroku-20:
@echo "Building nginx in Docker for heroku-20..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-20" -w /buildpack heroku/heroku:20-build scripts/build_nginx /buildpack/nginx-heroku-20.tgz

build-heroku-22:
@echo "Building nginx in Docker for heroku-22..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-22" -w /buildpack heroku/heroku:22-build scripts/build_nginx /buildpack/nginx-heroku-22.tgz

shell:
@echo "Opening heroku-18 shell..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-18" -e "PORT=5000" -w /buildpack heroku/heroku:18-build bash
@echo "Opening heroku-22 shell..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-22" -e "PORT=5000" -w /buildpack heroku/heroku:22-build bash
25 changes: 25 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ echo "-----> nginx-buildpack: Installed libmaxminddb to app/.geoip"

nginx_version=$($BUILD_DIR/bin/nginx -V 2>&1 | head -1 | awk '{ print $NF }')
echo "-----> nginx-buildpack: Installed ${nginx_version} to app/bin"

# The ERB templating feature requires a Ruby install at runtime, for the `erb` command.
# As of Heroku-22, there is no system Ruby installation in the stack image, so if the
# app doesn't already have the Ruby buildpack set before this one, we have to vendor
# our own copy of Ruby and ensure it's on PATH at runtime.
if ! command -v erb &> /dev/null; then
echo "-----> nginx-buildpack: An existing Ruby installation was not found (required for erb template support)"
ruby_version="3.1.2"
ruby_url="https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/${STACK}/ruby-${ruby_version}.tgz"
vendored_ruby_dir=".heroku-buildpack-nginx/ruby"
mkdir -p "${BUILD_DIR}/${vendored_ruby_dir}"

if ! curl --silent --show-error --fail --retry 3 --retry-connrefused --connect-timeout 5 "${ruby_url}" | tar -zxC "${BUILD_DIR}/${vendored_ruby_dir}"; then
echo " ! Failed to download Ruby from '${ruby_url}'" >&2
exit 1
fi

mkdir -p "${BUILD_DIR}/.profile.d"
# Deliberately pick the same profile.d script filepath as the Ruby buildpack,
# so if the Ruby buildpack comes after this one, it will overwrite this script.
echo "export PATH=\"\${HOME}/${vendored_ruby_dir}/bin:\${PATH}\"" > "${BUILD_DIR}/.profile.d/ruby.sh"

echo "-----> nginx-buildpack: Installed Ruby ${ruby_version}"
fi

cp bin/start-nginx "$BUILD_DIR/bin/"
echo '-----> nginx-buildpack: Added start-nginx to app/bin'
cp bin/start-nginx-debug "$BUILD_DIR/bin/"
Expand Down
3 changes: 2 additions & 1 deletion config/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ http {
gzip on;
gzip_comp_level 2;
gzip_min_length 512;
gzip_proxied any; # Heroku router sends Via header

server_tokens off;

Expand All @@ -29,7 +30,7 @@ http {
default "$geoip2_city, $geoip2_state";
}

log_format l2met '[nginx] request_time=$request_time request_id=$http_x_request_id' location=$location;
log_format l2met '[nginx] measure#nginx.service=$request_time request_id=$http_x_request_id' location=$location;
access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met;
error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>;

Expand Down
Binary file removed nginx-heroku-16.tgz
Binary file not shown.
Binary file modified nginx-heroku-18.tgz
Binary file not shown.
Binary file modified nginx-heroku-20.tgz
Binary file not shown.
Binary file added nginx-heroku-22.tgz
Binary file not shown.
12 changes: 6 additions & 6 deletions scripts/build_nginx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
# image. More information on the Heroku Stack can be found
# at https://devcenter.heroku.com/articles/stack

GEO_IP2_VERSION=${GEO_IP2_VERSION-3.3}
GEO_IP2_VERSION=${GEO_IP2_VERSION-3.4}
HEADERS_MORE_VERSION=${HEADERS_MORE_VERSION-0.33}
MAXMIND_VERSION=${MAXMIND_VERSION-1.4.3}
NGINX_VERSION=${NGINX_VERSION-1.18.0}
PCRE_VERSION=${PCRE_VERSION-8.44}
MAXMIND_VERSION=${MAXMIND_VERSION-1.6.0}
NGINX_VERSION=${NGINX_VERSION-1.20.2}
PCRE_VERSION=${PCRE_VERSION-8.45}
UUID4_VERSION=${UUID4_VERSION-master}
ZLIB_VERSION=${ZLIB_VERSION-1.2.11}
ZLIB_VERSION=${ZLIB_VERSION-1.2.12}

geo_ip2_module_url=https://github.com/leev/ngx_http_geoip2_module/archive/${GEO_IP2_VERSION}.tar.gz
headers_more_nginx_module_url=https://github.com/openresty/headers-more-nginx-module/archive/v${HEADERS_MORE_VERSION}.tar.gz
maxmind_url=https://github.com/maxmind/libmaxminddb/releases/download/${MAXMIND_VERSION}/libmaxminddb-${MAXMIND_VERSION}.tar.gz
nginx_tarball_url=https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
pcre_tarball_url=https://ftp.pcre.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz
pcre_tarball_url=https://ftp.exim.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz
uuid4_url=https://github.com/cybozu/nginx-uuid4-module/archive/${UUID4_VERSION}.tar.gz
zlib_url=http://zlib.net/zlib-${ZLIB_VERSION}.tar.gz

Expand Down

0 comments on commit a50ca1e

Please sign in to comment.