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

Add support for Heroku-20 #182

Merged
merged 1 commit into from
Nov 11, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
archives/
vendor/
.bundle/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

* [#182](https://github.com/heroku/heroku-buildpack-static/pull/182) Add support for Heroku-20
* [#181](https://github.com/heroku/heroku-buildpack-static/pull/181) Fix compatibility with ngx_mruby 1.18.4+
* [#178](https://github.com/heroku/heroku-buildpack-static/pull/178) Exclude unnecessary files when publishing the buildpack
* [#177](https://github.com/heroku/heroku-buildpack-static/pull/177) Make curl retry in case of a failed download
Expand Down
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
S3_BUCKET ?= heroku-buildpack-static

.PHONY: build build-heroku-16 build-heroku-18 build-heroku-20 sync

build: build-heroku-16 build-heroku-18 build-heroku-20

build-heroku-16:
@docker pull heroku/heroku:16-build
@docker run -v "$(shell pwd)":/buildpack --rm -it -e "STACK=heroku-16" heroku/heroku:16-build /buildpack/scripts/build_ngx_mruby.sh

build-heroku-18:
@docker pull heroku/heroku:18-build
@docker run -v "$(shell pwd)":/buildpack --rm -it -e "STACK=heroku-18" heroku/heroku:18-build /buildpack/scripts/build_ngx_mruby.sh

build-heroku-20:
@docker pull heroku/heroku:20-build
@docker run -v "$(shell pwd)":/buildpack --rm -it -e "STACK=heroku-20" heroku/heroku:20-build /buildpack/scripts/build_ngx_mruby.sh

sync:
@echo "Performing dry run of sync to $(S3_BUCKET)..."
@echo
@aws s3 sync archives/ s3://$(S3_BUCKET) --dryrun
@echo
@read -p "Continue with sync? [y/N]? " answer && [ "$$answer" = "y" ]
@echo
@aws s3 sync archives/ s3://$(S3_BUCKET)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,17 @@ You need to forward the docker's port 3000 to the virtual machine's port though.
```
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port3000,tcp,,3000,,3000";
```

## Releasing new binaries

The steps buildpack maintainers need to perform when releasing new nginx
binaries (either for a new stack or `ngx_mruby` version), are:

1. Update the stacks list in `Makefile` and/or the ngx_mruby version
in `scripts/build_ngx_mruby.sh`.
2. Run `make build` to build all stacks or `make build-heroku-NN` to build just one stack.
3. Ensure the AWS CLI is installed (eg `brew install awscli`).
4. Authenticate with the relevant AWS account (typically by setting the environment variables from PCSK).
5. Run `make sync` (or if using a custom S3 bucket, `S3_BUCKET=... make sync`).
6. Update `bin/compile` to reference the new stacks and/or nginx version URLs.
7. Open a PR with the changes from (1) and (6).
3 changes: 3 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ env_dir=$3
bp_dir=$(dirname $(dirname $0))

case "${STACK}" in
heroku-20)
nginx_archive_url="https://heroku-buildpack-static.s3.amazonaws.com/${STACK}/nginx-1.19.0-ngx_mruby-2.2.3.tgz"
;;
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.
Expand Down
36 changes: 36 additions & 0 deletions scripts/build_ngx_mruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -euo pipefail

NGX_MRUBY_VERSION='2.2.3'
NGX_MRUBY_URL="https://github.com/matsumotory/ngx_mruby/archive/v${NGX_MRUBY_VERSION}.tar.gz"

echo "Building ngx_mruby v${NGX_MRUBY_VERSION} for ${STACK}"

BUILD_DIR=$(mktemp -d /tmp/ngx_mruby.XXXX)
SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OUTPUT_DIR="$(dirname "${SCRIPTS_DIR}")/archives/${STACK}"

mkdir -p "${OUTPUT_DIR}"
cd "${BUILD_DIR}"

echo "Downloading ngx_mruby from ${NGX_MRUBY_URL}"
curl -sSfL "${NGX_MRUBY_URL}" | tar -xz --strip-components 1

./build.sh
make install

echo 'nginx build complete!'

NGINX_BIN_DIR="${BUILD_DIR}/build/nginx/sbin"
cd "${NGINX_BIN_DIR}"

# Check that nginx can start
./nginx -v

NGINX_VERSION=$(./nginx -v |& cut -d '/' -f 2-)
Copy link
Member

@hone hone Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we don't control version of nginx anymore? It's possible to build ngx_mruby in context of the nginx source.

Copy link
Member Author

@edmorley edmorley Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hone Yeah that's correct - ngx_mruby has a default nginx version that they bump periodically (there's a newer version on their master for example). At least until there is a time where we need a specific nginx it seemed simpler to use the default given that's the version they test against.

To override this in the future we could either modify the constants here post download, or pass in the source dir as an arg:
https://github.com/matsumotory/ngx_mruby/blob/v2.2.3/nginx_version
https://github.com/matsumotory/ngx_mruby/blob/v2.2.3/build.sh#L57-L58

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure I was building nginx independent of it so we can update nginx in theory outside of being tied to ngx_mruby.

ARCHIVE_PATH="${OUTPUT_DIR}/nginx-${NGINX_VERSION}-ngx_mruby-${NGX_MRUBY_VERSION}.tgz"

tar -czf "${ARCHIVE_PATH}" nginx

echo "Archive saved to: ${ARCHIVE_PATH}"