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

Merge upstream - 21 Jun 2021 #12

Merged
merged 27 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
85af131
[changelog skip] Ensure PRs include a Changelog entry
schneems Sep 27, 2019
baddb9c
[changelog skip] Fix Escaping in Changelog Script
schneems Oct 1, 2019
9f43b72
Update check_changelog.yml
schneems May 13, 2020
bbffe64
Add missing changelog entries for v4 (#176)
edmorley Nov 6, 2020
6b08061
Bump json from 2.0.2 to 2.3.1 (#173)
dependabot[bot] Nov 7, 2020
88d1f1b
Bump rake from 10.4.0 to 12.3.3 (#158)
dependabot[bot] Nov 7, 2020
cb1270b
Bump excon from 0.54.0 to 0.78.0 (#180)
dependabot[bot] Nov 7, 2020
2c59d26
Bump rack from 1.6.11 to 1.6.13 in /spec/support/docker/proxy (#179)
dependabot[bot] Nov 7, 2020
74af0d5
Added MIT License (#117)
biw Nov 7, 2020
1cf2d91
Remove redundant `exit 0`
edmorley Nov 6, 2020
dfeb0bc
Fail the build early on unsupported stacks
edmorley Nov 6, 2020
32d0a2a
Remove unused archive caching
edmorley Nov 6, 2020
8fd6787
Switch to recommended S3 URL format
edmorley Nov 6, 2020
14aa295
Fix the printing of the installed nginx version
edmorley Nov 6, 2020
34571a6
Enable stricter bash error checking modes
edmorley Nov 6, 2020
641786a
Make curl retry in case of a failed download
edmorley Nov 6, 2020
408edd2
Exclude unnecessary files when publishing buildpack (#178)
edmorley Nov 9, 2020
e581d7b
Fix compatibility with ngx_mruby 1.18.4+ (#181)
edmorley Nov 9, 2020
c1ee75d
Add support for Heroku-20 (#182)
edmorley Nov 11, 2020
ddb62de
Release v5 (#183)
edmorley Nov 11, 2020
8abde0e
Ensure the SSL module is enabled (#186)
edmorley Nov 19, 2020
388b672
Update nginx for Heroku-16 and Heroku-18 to 1.19.0 (#190)
edmorley Dec 9, 2020
7efdfb4
Release v6 (#191)
edmorley Dec 9, 2020
d3898bc
Docs: Use the buildpack registry URL in usage example (#194)
edmorley Jan 18, 2021
b40c445
Output a helpful error message when no static.json is found (#202)
edmorley Mar 9, 2021
5fb28ee
Release v7 (#203)
edmorley Mar 9, 2021
21f1c47
README: Fix spelling of 'instead' (#213)
jsoref May 25, 2021
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
13 changes: 13 additions & 0 deletions .github/workflows/check_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Check Changelog

on:
pull_request:
types: [opened, reopened, edited, synchronize]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check that CHANGELOG is touched
run: |
cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
archives/
vendor/
.bundle/
40 changes: 37 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
## v3 (3/30/2017)
# Static Buildpack Changelog

## Unreleased


## v7 (2021-03-09)

* [#202](https://github.com/heroku/heroku-buildpack-static/pull/202) Output a helpful error message when no `static.json` is found

## v6 (2020-12-09)

* [#190](https://github.com/heroku/heroku-buildpack-static/pull/190) Update nginx for Heroku-16 and Heroku-18 to 1.19.0
* [#186](https://github.com/heroku/heroku-buildpack-static/pull/186) Ensure the SSL module is enabled

## v5 (2020-11-11)

* [#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
* [#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)

* [#136](https://github.com/heroku/heroku-buildpack-static/pull/136) Add support for canonical host
* [#45](https://github.com/heroku/heroku-buildpack-static/pull/45) Add Basic Auth Configuration
* [#78](https://github.com/heroku/heroku-buildpack-static/pull/78) Add json mime type
* [#70](https://github.com/heroku/heroku-buildpack-static/pull/70) Make config copying idempotent
* [#68](https://github.com/heroku/heroku-buildpack-static/pull/68) Disable access logs

## v3 (2017-03-30)

* [#32](https://github.com/heroku/heroku-buildpack-static/pull/32) proxies set ssl server name extension for SNI
* [#37](https://github.com/heroku/heroku-buildpack-static/pull/47) fallback proxies set ssl server name extension for SNI
* [#61](https://github.com/heroku/heroku-buildpack-static/pull/61) proxy redirects work even when the scheme does not match
* [#62](https://github.com/heroku/heroku-buildpack-static/pull/62) clean urls work even on a directory
* [#63](https://github.com/heroku/heroku-buildpack-static/pull/63) proxies respect DNS TTL
* [#65](https://github.com/heroku/heroku-buildpack-static/pull/65) https redirects happen over proxies

## v2 (7/13/2016)
## v2 (2016-07-13)

* [#36](https://github.com/heroku/heroku-buildpack-static/pull/36) env interpolation available when doing `redirects`
* [#40](https://github.com/heroku/heroku-buildpack-static/pull/40) mitigate CRLF HTTP Header Injection when using `https_only`

## v1 (3/27/2016)
## v1 (2016-03-27)

* Initial Release!
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ GEM
docker-api (1.33.1)
excon (>= 0.38.0)
json
excon (0.54.0)
json (2.0.2)
rake (10.4.0)
excon (0.78.0)
json (2.3.1)
rake (12.3.3)
ref (1.0.5)
rspec (3.2.0)
rspec-core (~> 3.2.0)
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Heroku

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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)
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ For a guide, read the [Getting Started with Single Page Apps on Heroku](https://
## Deploying
The `static.json` file is required to use this buildpack. This file handles all the configuration described below.

1. Set the app to this buildpack: `$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-static.git`.
1. Set the app to this buildpack: `$ heroku buildpacks:set heroku-community/static`.
2. Deploy: `$ git push heroku master`

### Configuration
You can configure different options for your static application by writing a `static.json` in the root folder of your application.

#### Root
This allows you to specify a different asset root for the directory of your application. For instance, if you're using ember-cli, it naturally builds a `dist/` directory, so you might want to use that intsead.
This allows you to specify a different asset root for the directory of your application. For instance, if you're using ember-cli, it naturally builds a `dist/` directory, so you might want to use that instead.

```json
{
Expand Down 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).
35 changes: 16 additions & 19 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
#!/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
heroku-16|heroku-18|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)
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
Expand All @@ -36,5 +35,3 @@ touch $build_dir/config/.htpasswd
cat $env_dir/SOURCE_MAP_HTPASSWD > $build_dir/config/.htpasswd

mkdir -p $build_dir/logs

exit 0
1 change: 1 addition & 0 deletions bin/detect
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
build_dir=$1

if [ ! -f "$build_dir/static.json" ]; then
echo "Could not find 'static.json'! Please ensure it exists and is checked into Git." >&2
exit 1
fi

Expand Down
15 changes: 15 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[buildpack]
name = "Static HTML"

[publish.Ignore]
files = [
".github/",
"spec/",
".gitignore",
".rspec",
"circle.yml",
"Gemfile",
"Gemfile.lock",
"Makefile",
"Rakefile"
]
46 changes: 46 additions & 0 deletions scripts/build_ngx_mruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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

# Taken from the defaults:
# https://github.com/matsumotory/ngx_mruby/blob/v2.2.3/build.sh#L23-L40
BUILD_OPTS="--prefix=${PWD}/build/nginx"
BUILD_OPTS+=' --with-http_stub_status_module --with-stream --without-stream_access_module --with-cc-opt=-fno-common'
# Our custom addition, to enable the SSL module.
BUILD_OPTS+=' --with-http_ssl_module'

NGINX_CONFIG_OPT_ENV="${BUILD_OPTS}" ./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

# Check that OpenSSL support was enabled
./nginx -V |& grep 'built with OpenSSL' || { echo 'Missing OpenSSL support!'; exit 1; }

NGINX_VERSION=$(./nginx -v |& cut -d '/' -f 2-)
ARCHIVE_PATH="${OUTPUT_DIR}/nginx-${NGINX_VERSION}-ngx_mruby-${NGX_MRUBY_VERSION}.tgz"

tar -czf "${ARCHIVE_PATH}" nginx

echo "Archive saved to: ${ARCHIVE_PATH}"
3 changes: 2 additions & 1 deletion scripts/config/templates/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ http {
auth_basic_user_file <%= basic_auth_htpasswd_path %>;
<% end %>

mruby_post_read_handler /app/bin/config/lib/ngx_mruby/headers.rb cache;

location / {
mruby_post_read_handler /app/bin/config/lib/ngx_mruby/headers.rb cache;
mruby_set $fallback /app/bin/config/lib/ngx_mruby/routes_fallback.rb cache;
<% if clean_urls %>
try_files $uri.html $uri $uri/ $fallback;
Expand Down
2 changes: 1 addition & 1 deletion spec/support/docker/proxy/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
rack (1.6.11)
rack (1.6.13)
rack-protection (1.5.5)
rack
sinatra (1.4.7)
Expand Down