Skip to content

Commit 277ccf2

Browse files
authored
Support heroku-24 (#123)
* fix Nginx versions in readme * Update Ruby to 3.2.4 * cut down on some of the unnecessary copying of files * Support heroku-24 Both amd64 and arm64. Finally also moves Nginx to PCRE2. GUS-W-14674582
1 parent ac4cabb commit 277ccf2

File tree

7 files changed

+42
-19
lines changed

7 files changed

+42
-19
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
build: build-heroku-20 build-heroku-22
1+
build: build-heroku-20 build-heroku-22 build-heroku-24
22

33
build-heroku-20:
44
@echo "Building nginx in Docker for heroku-20..."
@@ -8,6 +8,12 @@ build-heroku-22:
88
@echo "Building nginx in Docker for heroku-22..."
99
@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
1010

11+
build-heroku-24:
12+
@echo "Building nginx in Docker for heroku-24 (amd64)..."
13+
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-24" -w /buildpack --platform linux/amd64 heroku/heroku:24-build scripts/build_nginx /buildpack/nginx-heroku-24-amd64.tgz
14+
@echo "Building nginx in Docker for heroku-24 (arm64)..."
15+
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-24" -w /buildpack --platform linux/arm64 heroku/heroku:24-build scripts/build_nginx /buildpack/nginx-heroku-24-arm64.tgz
16+
1117
shell:
1218
@echo "Opening heroku-22 shell..."
1319
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-22" -e "PORT=5000" -w /buildpack heroku/heroku:22-build bash

bin/compile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ BUILD_DIR=$1
1010
CACHE_DIR=$2
1111
BUILDPACK_DIR="$(dirname "$(dirname "$0")")"
1212

13+
ruby_version="3.2.4"
14+
if [[ $STACK == heroku-2[02] ]]; then
15+
nginx_tarball=nginx-${STACK}.tgz
16+
ruby_tarball=${STACK}/ruby-${ruby_version}.tgz
17+
else
18+
nginx_tarball=nginx-$STACK-$(dpkg --print-architecture).tgz
19+
ruby_tarball=${STACK}/$(dpkg --print-architecture)/ruby-${ruby_version}.tgz
20+
fi
21+
1322
mkdir -p "$BUILD_DIR/bin/"
14-
mkdir -p "$BUILD_DIR/nginx"
15-
tar -zxvf "nginx-$STACK".tgz -C "$BUILD_DIR/nginx"
23+
nginx_tmp=$(mktemp -d -t nginx.XXXXXXXXXX)
24+
tar -zxvf "${nginx_tarball}" -C "$nginx_tmp"
1625

17-
cp "$BUILD_DIR/nginx/nginx" "$BUILD_DIR/bin/nginx"
18-
cp "$BUILD_DIR/nginx/nginx-debug" "$BUILD_DIR/bin/nginx-debug"
26+
mv "$nginx_tmp/nginx" "$BUILD_DIR/bin/nginx"
27+
mv "$nginx_tmp/nginx-debug" "$BUILD_DIR/bin/nginx-debug"
1928

2029
nginx_version=$($BUILD_DIR/bin/nginx -V 2>&1 | head -1 | awk '{ print $NF }')
2130
echo "-----> nginx-buildpack: Installed ${nginx_version} to app/bin"
@@ -26,8 +35,7 @@ echo "-----> nginx-buildpack: Installed ${nginx_version} to app/bin"
2635
# our own copy of Ruby and ensure it's on PATH at runtime.
2736
if ! command -v erb &> /dev/null; then
2837
echo "-----> nginx-buildpack: An existing Ruby installation was not found (required for erb template support)"
29-
ruby_version="3.2.2"
30-
ruby_url="https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/${STACK}/ruby-${ruby_version}.tgz"
38+
ruby_url="https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/${ruby_tarball}"
3139
vendored_ruby_dir=".heroku-buildpack-nginx/ruby"
3240
mkdir -p "${BUILD_DIR}/${vendored_ruby_dir}"
3341

@@ -56,7 +64,7 @@ echo '-----> nginx-buildpack: Added start-nginx-static to app/bin'
5664
mkdir -p "$BUILD_DIR/config"
5765

5866
if [[ ! -f $BUILD_DIR/config/mime.types ]]; then
59-
cp "$BUILD_DIR/nginx/mime.types" "$BUILD_DIR/config/"
67+
mv "$nginx_tmp/mime.types" "$BUILD_DIR/config/"
6068
echo '-----> nginx-buildpack: Default mime.types copied to app/config/'
6169
else
6270
echo '-----> nginx-buildpack: Custom mime.types found in app/config.'
@@ -70,6 +78,6 @@ else
7078
fi
7179

7280
# cleanup
73-
rm -r "$BUILD_DIR/nginx"
81+
rm -r "$nginx_tmp"
7482

7583
exit 0

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Link against system zlib
1313
- Update nginx to 1.26.0
1414
- Update headers-more-nginx-module to 0.37
15+
- Update ruby to 3.2.4
16+
- Support heroku-24
17+
- Use PCRE2 on heroku-24 and newer
1518

1619
## [1.10] - 2023-06-13
1720
### Changes

nginx-heroku-24-amd64.tgz

2.46 MB
Binary file not shown.

nginx-heroku-24-arm64.tgz

2.47 MB
Binary file not shown.

readme.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ Nginx-buildpack installs & runs the [Nginx web server](https://nginx.org/) insid
1717

1818
These are auto-selected based on the app's stack at build time.
1919

20-
| Heroku Stack | Nginx Version |
21-
|--------------|--------------:|
22-
| `Heroku-20` | `1.25.1` |
23-
| `Heroku-22` | `1.25.1` |
20+
| Heroku Stack | Nginx Version | PCRE version |
21+
|--------------|--------------:|-------------:|
22+
| `Heroku-20` | `1.26.0` | PCRE1 (8.x) |
23+
| `Heroku-22` | `1.26.0` | PCRE1 (8.x) |
24+
| `Heroku-24` | `1.26.0` | PCRE2 (10.x) |
2425

2526
## Presets
2627

scripts/build_nginx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ curl -sSL "$uuid4_url" | tar xvz -C "nginx-${NGINX_VERSION}"
3333

3434
configure_opts=(
3535
--with-pcre
36-
--without-pcre2
3736
--with-http_gzip_static_module
3837
--with-http_realip_module
3938
--with-http_ssl_module
4039
--add-module="${temp_dir}/nginx-${NGINX_VERSION}/headers-more-nginx-module-${HEADERS_MORE_VERSION}"
4140
--add-module="${temp_dir}/nginx-${NGINX_VERSION}/nginx-uuid4-module-${UUID4_VERSION}"
4241
)
42+
if [[ $STACK == heroku-2[02] ]]; then
43+
# we used to build our own PCRE 8.x, and when moving to dynamic linking, we had to ensure all existing regexes in config files continued to work, so we enforced libpcre3 (8.x) usage instead of the newer PCRE2 (10.x), which has stricter validation for certain patterns (example: /[\w-.]/ is not allowed in PCRE2)
44+
# but for any newer stacks, we can use the more modern PCRE2
45+
configure_opts+=(
46+
--without-pcre2
47+
)
48+
fi
4349

4450
# This will build `nginx`
4551
(
@@ -64,8 +70,7 @@ configure_opts=(
6470

6571
release_dir=$(mktemp -d /tmp/nginx.XXXXXXXXXX)
6672

67-
cp /tmp/nginx/sbin/nginx "$release_dir/nginx"
68-
cp /tmp/nginx-debug/sbin/nginx "$release_dir/nginx-debug"
69-
cp /tmp/nginx/conf/mime.types "$release_dir/mime.types"
70-
tar -zcvf /tmp/nginx-"${STACK}".tgz -C "$release_dir" .
71-
cp /tmp/nginx-"${STACK}".tgz "$1"
73+
mv /tmp/nginx/sbin/nginx "$release_dir/nginx"
74+
mv /tmp/nginx-debug/sbin/nginx "$release_dir/nginx-debug"
75+
mv /tmp/nginx/conf/mime.types "$release_dir/mime.types"
76+
tar -zcvf "$1" -C "$release_dir" .

0 commit comments

Comments
 (0)