-
Notifications
You must be signed in to change notification settings - Fork 154
feat: update nginx plus image builds to use nginx plus base images #449
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR migrates NGINX Plus container builds from using a public Debian base image to the official NGINX Plus Docker base image, improving compliance and support. It also removes legacy entrypoint scripts that are now redundant with the official base image.
- Updates both Dockerfiles to use the official NGINX Plus base image from the private registry
- Removes legacy entrypoint scripts (
10-listen-on-ipv6-by-default.sh
and20-envsubst-on-templates.sh
) - Updates environment variables and module installation logic to use explicit Plus and OSS versions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
Dockerfile.plus | Updates base image to official NGINX Plus and removes redundant user creation and container configuration |
Dockerfile.buildkit.plus | Same base image and configuration updates as standard Dockerfile |
plus/docker-entrypoint.d/10-listen-on-ipv6-by-default.sh | Removes legacy IPv6 configuration script |
plus/docker-entrypoint.d/20-envsubst-on-templates.sh | Removes legacy template substitution script |
docs/getting_started.md | Updates build instructions to clarify NGINX Plus image repository setup requirements |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Changes look good to me - the copilot suggestion around chmod commands on directories that are not explicitly copied in any long are worth looking at but perhaps we are not just dealing with those directories as they are inherited from the new base image?
3fb3c55
to
62504e6
Compare
nginx plus has entrypoint scripts copied from docker-nginx of OSS images. Are we sure we want to do any changes to entrypoint.sh? |
e928452
to
8c80096
Compare
@oxpa I've incorporated your suggestions and redone this PR. Thank you for them. It helped me clarify what was needed. |
@@ -1,9 +1,5 @@ | |||
FROM nginx:1.29.0@sha256:f5c017fb33c6db484545793ffb67db51cdd7daebee472104612f73a85063f889 | |||
|
|||
# NJS env vars |
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.
We no longer hard-code NJS versions.
COPY oss/etc /etc | ||
COPY oss/etc/nginx /etc/nginx | ||
COPY common/etc /etc | ||
COPY common/docker-entrypoint.sh /docker-entrypoint.sh |
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.
We no longer need a custom entry point script.
&& mkdir -p /var/cache/nginx/s3_proxy \ | ||
&& chown nginx:nginx /var/cache/nginx/s3_proxy \ | ||
&& chmod -R -v +x /docker-entrypoint.sh /docker-entrypoint.d/*.sh; | ||
&& find /docker-entrypoint.d -type f \( -name '*.sh' -or -name '*.envsh' \) -exec chmod -v +x {} \; |
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.
This find command ensures all the files in the entry point directory are executable.
Dockerfile.plus
Outdated
&& chmod -R -v +x /docker-entrypoint.sh /docker-entrypoint.d/*.sh; | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
RUN set -eux \ |
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.
We now append the commented out default E+V blocks into the nginx.conf, so that the entry point substitution script can replace values from it.
Dockerfile.plus
Outdated
# startup is the same. | ||
COPY --from=build /etc/nginx/modules/ngx_http_xslt_filter_module*.so /etc/nginx/modules/ | ||
COPY --from=build /etc/nginx/modules/ngx_http_js_module*.s /etc/nginx/modules/ | ||
COPY --from=build /lib/aarch64-linux-gnu/libxslt.so.1 /lib/aarch64-linux-gnu/ |
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.
It looks like I hard coded architecture here, so this will need to be fixed.
ce18e42
to
9c8763f
Compare
9c8763f
to
16aff32
Compare
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.
Pull Request Overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
test.sh
Outdated
docker build -f Dockerfile.${nginx_type} \ | ||
--tag nginx-s3-gateway --tag nginx-s3-gateway:${nginx_type} . | ||
e "Only BuildKit builds are supported with NGINX Plus image" | ||
exit ${} |
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.
Empty variable expansion in exit statement. This should be exit ${build_dep_exit_code}
to properly exit with the defined error code.
exit ${} | |
exit ${build_dep_exit_code} |
Copilot uses AI. Check for mistakes.
16aff32
to
e8138d2
Compare
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.
Pull Request Overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
👍 This looks great. One copilot comment looks like it could be legit flagging package names ending in a dash?
This change does the following: * Migrates to using the official NGINX Plus Docker images as base images * Removes the distinction between BuildKit and non-BuildKit builds for Plus images (OSS never had this) * Adds support for license validation for Plus images * Introduces a multi-stage build for Plus images Signed-off-by: Elijah Zupancic <[email protected]>
Signed-off-by: Elijah Zupancic <[email protected]>
By using the version reported by NGINX rather than the environment variable it allows for a more reliable setting and less complexity. Signed-off-by: Elijah Zupancic <[email protected]>
e8138d2
to
1207c58
Compare
I added a comment to clarify what trailing dashes are doing. |
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.
Pull Request Overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This change migrates to using the official NGINX Plus Docker images as base images.
Proposed changes
This pull request refactors and streamlines the Docker build process for both OSS and Plus variants of the NGINX S3 Gateway, improves environment variable handling, and enhances script modularity and maintainability. The changes focus on updating base images, simplifying installation and configuration steps, and improving the way environment variables are set and output. Below are the most important changes grouped by theme.
Dockerfile and Build Process Updates:
Dockerfile.oss
andDockerfile.plus
now use newer, more specialized NGINX base images, removing manual installation and configuration steps for modules and dependencies. This simplifies maintenance and ensures up-to-date security and compatibility. ([[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-27159a855b1005b6238ec88d1102a64dd367c95a56a5dd79e8fef77822da946cL1-R1)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L1-R4)
)[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L1-R4)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L29-R44)
,[[3]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-bd173a4997c5890e5dac73e8a5312c3898d8fa58212035ed6fa3ea9b59ac0b2dL1-L104)
)[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-27159a855b1005b6238ec88d1102a64dd367c95a56a5dd79e8fef77822da946cR26-R42)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L29-R44)
,[[3]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-f68090bbfca14523ecccbcb26652c72c11ee1dbfdd6484b1ee2282a421c32097R8-R13)
)Entrypoint Script Refactoring:
common/docker-entrypoint.sh
is split into modular scripts incommon/docker-entrypoint.d/
, improving maintainability and clarity. The environment variable setting logic is now handled in01-set-defaults.envsh
, and output of settings is moved to99-output-settings.sh
. ([[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L1-R1)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L18-R18)
,[[3]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L34-R32)
,[[4]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L49-R73)
,[[5]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L86-R89)
,[[6]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L98-L136)
,[[7]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-488413bc701efdbc3df0aa211eacf5a39ca2ac8754889b69a6d0c05c3807e480R1-R36)
)sh
in entrypoint scripts. ([[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L1-R1)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L18-R18)
)Environment Variable Handling Improvements:
[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L34-R32)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L49-R73)
,[[3]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L86-R89)
,[[4]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-487a3dbccd6da77b63078fcb3ad21bf549b7c6ec3ea10204c0b7624f1f26e872L98-L136)
)99-output-settings.sh
), making startup logs clearer and the code easier to maintain. ([[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-72b42db75a6916ae79a70e72a888969f2fbc322a1c32836cb64aabed185277caL133-L150)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-488413bc701efdbc3df0aa211eacf5a39ca2ac8754889b69a6d0c05c3807e480R1-R36)
)Module Installation and Configuration:
[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-27159a855b1005b6238ec88d1102a64dd367c95a56a5dd79e8fef77822da946cR26-R42)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L1-R4)
,[[3]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L29-R44)
)[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L1-R4)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L29-R44)
)Miscellaneous Improvements:
[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-27159a855b1005b6238ec88d1102a64dd367c95a56a5dd79e8fef77822da946cR26-R42)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L29-R44)
)[[1]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-27159a855b1005b6238ec88d1102a64dd367c95a56a5dd79e8fef77822da946cR26-R42)
,[[2]](https://github.com/nginx/nginx-s3-gateway/pull/449/files#diff-29fd428d7aaa2e0caf6fd3520ae4c3af291a97d312f2279cbe3d439aef7dad55L29-R44)
)These changes collectively make the build process more reliable, secure, and maintainable, and improve the clarity and modularity of the startup configuration logic.
This pull request refactors the Dockerfiles and entrypoint scripts for both the OSS and Plus NGINX S3 Gateway images. The main goals are to modernize the build process, improve maintainability, and enhance compatibility with best practices for multi-stage Docker builds. The changes include switching to official NGINX Plus base images, restructuring build steps, simplifying environment variable handling, and improving script robustness.
Dockerfile and Build Process Refactoring:
Dockerfile.oss
) and Plus (Dockerfile.plus
) images to use official NGINX and NGINX Plus base images, removing custom build logic and simplifying module installation. The Plus image now uses a multi-stage build to avoid embedding sensitive license files in the final image. [1] [2] [3]Dockerfile.buildkit.plus
as its logic is replaced by the new multi-stage approach.Entrypoint Script Improvements:
docker-entrypoint.sh
Other Notable Changes:
These changes collectively modernize the build and runtime environment for the NGINX S3 Gateway images, making them easier to maintain and more secure.
Base Image and Versioning Updates:
Dockerfile.plus
now uses the official NGINX Plus base image from the private registry instead of the public Debian image, ensuring compliance and improved support. [1] [2]Entrypoint and Startup Script Cleanup:
10-listen-on-ipv6-by-default.sh
and20-envsubst-on-templates.sh
have been removed fromplus/docker-entrypoint.d
, simplifying container startup and reducing maintenance overhead. [1] [2]Documentation Improvements:
docs/getting_started.md
have been updated to clarify the process for building the NGINX Plus image, including the need to set up access to the official Plus Docker image repository and the steps for handling repository keys.Checklist
Before creating a pull request (PR), run through this checklist and mark each as complete:
README.md
).