-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to Nginx 1.26, link against system libraries, strip nginx binary #122
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Absolutely no need to compile this ourselves. Because we have always built a custom libpcre3 (v8.x) and not the more modern PCRE2 (v10.x), we are enforcing usage of the old version for now. This is to ensure that existing configs with regexes continue to work, as PCRE2 is more aggressive in its pattern validation. To give a simple example, `/[\w-.]+/` now throws "Compilation failed: invalid range in character class at offset 3", and the `-` needs to be escaped, or moved to the end of the character class.
We only need debug symbols in the nginx-debug variant. Together with the slight improvement from the now system-linked PCRE and zlib, this helps a lot with overall size. Before: % ls -la nginx-heroku-2*.tgz -rw-r--r-- 1 dzuelke staff 5638356 May 17 13:50 nginx-heroku-20.tgz -rw-r--r-- 1 dzuelke staff 4559004 May 17 13:50 nginx-heroku-22.tgz % tar tzvf nginx-heroku-20.tgz -rw-r--r-- 0 root root 5349 Feb 21 01:58 ./mime.types -rwxr-xr-x 0 root root 6705408 Feb 21 01:58 ./nginx -rwxr-xr-x 0 root root 6870296 Feb 21 01:58 ./nginx-debug % tar tzvf nginx-heroku-22.tgz -rw-r--r-- 0 root root 5349 Feb 21 02:00 ./mime.types -rwxr-xr-x 0 root root 4937400 Feb 21 02:00 ./nginx -rwxr-xr-x 0 root root 5094584 Feb 21 02:00 ./nginx-debug After: % ls -la nginx-heroku-2*.tgz -rw-r--r-- 1 dzuelke staff 3181649 May 17 13:51 nginx-heroku-20.tgz -rw-r--r-- 1 dzuelke staff 2638964 May 17 13:51 nginx-heroku-22.tgz % tar tzvf nginx-heroku-20.tgz -rw-r--r-- 0 root root 5349 May 17 13:30 ./mime.types -rwxr-xr-x 0 root root 973624 May 17 13:30 ./nginx -rwxr-xr-x 0 root root 6746392 May 17 13:30 ./nginx-debug % tar tzvf nginx-heroku-22.tgz -rw-r--r-- 0 root root 5349 May 17 13:30 ./mime.types -rwxr-xr-x 0 root root 973592 May 17 13:30 ./nginx -rwxr-xr-x 0 root root 4974032 May 17 13:30 ./nginx-debug
Also update headers-more-nginx-module to the latest 0.37 and pin nginx-uuid4-module to specific commit SHA
edmorley
approved these changes
May 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on the size reduction!
dzuelke
changed the title
Update to Nginx 1.26, link against system images, strip nginx binary.
Update to Nginx 1.26, link against system libraries, strip nginx binary
May 29, 2024
targess
pushed a commit
to kelkoo-services/heroku-buildpack-nginx
that referenced
this pull request
Jan 7, 2025
…heroku#122) * clean up configure options list handling * Link against system PCRE Absolutely no need to compile this ourselves. Because we have always built a custom libpcre3 (v8.x) and not the more modern PCRE2 (v10.x), we are enforcing usage of the old version for now. This is to ensure that existing configs with regexes continue to work, as PCRE2 is more aggressive in its pattern validation. To give a simple example, `/[\w-.]+/` now throws "Compilation failed: invalid range in character class at offset 3", and the `-` needs to be escaped, or moved to the end of the character class. * Link against system zlib * various little bash hardenings * Strip nginx binary We only need debug symbols in the nginx-debug variant. Together with the slight improvement from the now system-linked PCRE and zlib, this helps a lot with overall size. Before: % ls -la nginx-heroku-2*.tgz -rw-r--r-- 1 dzuelke staff 5638356 May 17 13:50 nginx-heroku-20.tgz -rw-r--r-- 1 dzuelke staff 4559004 May 17 13:50 nginx-heroku-22.tgz % tar tzvf nginx-heroku-20.tgz -rw-r--r-- 0 root root 5349 Feb 21 01:58 ./mime.types -rwxr-xr-x 0 root root 6705408 Feb 21 01:58 ./nginx -rwxr-xr-x 0 root root 6870296 Feb 21 01:58 ./nginx-debug % tar tzvf nginx-heroku-22.tgz -rw-r--r-- 0 root root 5349 Feb 21 02:00 ./mime.types -rwxr-xr-x 0 root root 4937400 Feb 21 02:00 ./nginx -rwxr-xr-x 0 root root 5094584 Feb 21 02:00 ./nginx-debug After: % ls -la nginx-heroku-2*.tgz -rw-r--r-- 1 dzuelke staff 3181649 May 17 13:51 nginx-heroku-20.tgz -rw-r--r-- 1 dzuelke staff 2638964 May 17 13:51 nginx-heroku-22.tgz % tar tzvf nginx-heroku-20.tgz -rw-r--r-- 0 root root 5349 May 17 13:30 ./mime.types -rwxr-xr-x 0 root root 973624 May 17 13:30 ./nginx -rwxr-xr-x 0 root root 6746392 May 17 13:30 ./nginx-debug % tar tzvf nginx-heroku-22.tgz -rw-r--r-- 0 root root 5349 May 17 13:30 ./mime.types -rwxr-xr-x 0 root root 973592 May 17 13:30 ./nginx -rwxr-xr-x 0 root root 4974032 May 17 13:30 ./nginx-debug * Update nginx to 1.26.0 (latest stable) Also update headers-more-nginx-module to the latest 0.37 and pin nginx-uuid4-module to specific commit SHA
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We should have started linking against base image versions of zlib and PCRE long ago. We are specifically linking against
libpcre3
(8.x), because some regex rules have changed in the newerlibpcre2
(10.x).Also now stripping the
nginx
binary (but obviously notnginx-debug
).In total, we get a reasonable size reduction:
Before:
After:
GUS-W-15794944