-
Notifications
You must be signed in to change notification settings - Fork 441
feat: support dynamic modules for openresty #8644
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
Open
Snrat
wants to merge
1
commit into
1Panel-dev:dev
Choose a base branch
from
Snrat:feat/openresty-dynamic-modules
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Check OpenResty Modules | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'apps/openresty/**' | ||
| - 'scripts/check-openresty-modules.sh' | ||
| push: | ||
| branches: ['dev'] | ||
| paths: | ||
| - 'apps/openresty/**' | ||
| - 'scripts/check-openresty-modules.sh' | ||
|
|
||
| jobs: | ||
| check-openresty-modules: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Verify module.json matches module.catalog.json | ||
| run: bash scripts/check-openresty-modules.sh |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| ARG RESTY_IMAGE_BASE="ubuntu" | ||
| ARG RESTY_IMAGE_TAG="noble" | ||
| ARG PANEL_OPENRESTY_VERSION="1.31.1.1-0-noble" | ||
|
|
||
| FROM 1panel/openresty:${PANEL_OPENRESTY_VERSION} AS panel-openresty | ||
|
|
||
| FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} AS module-builder | ||
|
|
||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
|
||
| ARG RESTY_VERSION="1.31.1.1" | ||
| ARG RESTY_J="1" | ||
| ARG RESTY_ADD_PACKAGE_BUILDDEPS="" | ||
| ARG CONTAINER_PACKAGE_URL="" | ||
|
|
||
| RUN if [ -n "${CONTAINER_PACKAGE_URL}" ]; then \ | ||
| if [ -f /etc/apt/sources.list ]; then \ | ||
| sed -i "s|http://archive.ubuntu.com/ubuntu/|${CONTAINER_PACKAGE_URL}|g" /etc/apt/sources.list \ | ||
| && sed -i "s|http://security.ubuntu.com/ubuntu/|${CONTAINER_PACKAGE_URL}|g" /etc/apt/sources.list; \ | ||
| fi; \ | ||
| if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then \ | ||
| sed -i "s|http://archive.ubuntu.com/ubuntu/|${CONTAINER_PACKAGE_URL}|g" /etc/apt/sources.list.d/ubuntu.sources \ | ||
| && sed -i "s|http://security.ubuntu.com/ubuntu/|${CONTAINER_PACKAGE_URL}|g" /etc/apt/sources.list.d/ubuntu.sources; \ | ||
| fi; \ | ||
| fi | ||
|
|
||
| RUN DEBIAN_FRONTEND=noninteractive apt-get update \ | ||
| && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
| build-essential ca-certificates curl git libgd-dev libgeoip-dev libpcre2-dev \ | ||
| libreadline-dev libssl-dev libxslt1-dev make patchelf perl unzip wget zlib1g-dev \ | ||
| ${RESTY_ADD_PACKAGE_BUILDDEPS} | ||
|
|
||
| COPY tmp /tmp | ||
| COPY --from=panel-openresty /usr/local/openresty/modules/ngx_brotli /usr/local/openresty/modules/ngx_brotli | ||
|
|
||
| RUN bash /tmp/module-pre.sh \ | ||
| && cd /tmp \ | ||
| && tar xzf openresty-${RESTY_VERSION}.tar.gz \ | ||
| && cd /tmp/openresty-${RESTY_VERSION} \ | ||
| && mapfile -t MODULE_CONFIG < /tmp/module-config.args \ | ||
| && ./configure -j${RESTY_J} --with-compat --with-http_ssl_module --with-stream --with-stream_ssl_module --with-http_realip_module --with-http_dav_module "${MODULE_CONFIG[@]}" \ | ||
| && NGINX_BUILD_DIR="$(find build -mindepth 1 -maxdepth 1 -type d -name 'nginx-*' | head -n 1)" \ | ||
| && test -n "${NGINX_BUILD_DIR}" \ | ||
| && make -C "${NGINX_BUILD_DIR}" -j${RESTY_J} modules \ | ||
| && mkdir -p /out/lib \ | ||
| && find "${NGINX_BUILD_DIR}/objs" -maxdepth 1 -type f -name '*.so' -exec cp -a {} /out/ \; \ | ||
| && test -n "$(find /out -maxdepth 1 -type f -name '*.so' -print -quit)" \ | ||
| && if find /usr/local/lib -maxdepth 1 -name '*.so*' -print -quit 2>/dev/null | grep -q .; then \ | ||
| find /usr/local/lib -maxdepth 1 -name '*.so*' -exec cp -a {} /out/lib/ \; ; \ | ||
| fi \ | ||
| && find /out -maxdepth 1 -type f -name '*.so' \ | ||
| -exec patchelf --set-rpath '$ORIGIN/lib:/usr/local/openresty/1pwaf/libraries' {} \; | ||
|
|
||
| FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} AS module-output | ||
| COPY --from=module-builder /out /out | ||
| CMD ["/bin/true"] | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| [ | ||
| { | ||
| "name": "ngx_brotli", | ||
| "script": "", | ||
| "packages": [ | ||
| "libbrotli-dev" | ||
| ], | ||
| "params": "--add-module=/usr/local/openresty/modules/ngx_brotli", | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 10 | ||
| }, | ||
| { | ||
| "name": "rtmp", | ||
| "script": "unzip -o /tmp/nginx-rtmp-module.zip -d /tmp", | ||
| "packages": [], | ||
| "params": "--add-module=/tmp/nginx-rtmp-module", | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 20 | ||
| }, | ||
| { | ||
| "name": "web_dav", | ||
| "script": "unzip -o /tmp/nginx-dav-ext-module.zip -d /tmp", | ||
| "packages": [], | ||
| "params": "--with-http_dav_module --add-module=/tmp/nginx-dav-ext-module", | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 30 | ||
| }, | ||
| { | ||
| "name": "geoip2", | ||
| "script": "unzip -o /tmp/ngx_http_geoip2_module.zip -d /tmp && tar -zxvf /tmp/libmaxminddb.tar.gz -C /tmp && cd /tmp/libmaxminddb && ./configure && make && make install", | ||
| "packages": [], | ||
| "params": "--add-module=/tmp/ngx_http_geoip2_module", | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 40 | ||
| }, | ||
| { | ||
| "name": "http_substitutions_filter", | ||
| "script": "unzip -o /tmp/ngx_http_substitutions_filter_module.zip -d /tmp", | ||
| "packages": [], | ||
| "params": "--add-module=/tmp/ngx_http_substitutions_filter_module", | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 50 | ||
| } | ||
| ] |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,59 @@ | ||
| [ | ||
| { | ||
| "name":"ngx_brotli", | ||
| "script":"", | ||
| "packages":[], | ||
| "name": "ngx_brotli", | ||
| "script": "", | ||
| "packages": [ | ||
| "libbrotli-dev" | ||
| ], | ||
| "params": "--add-module=/usr/local/openresty/modules/ngx_brotli", | ||
| "enable":false | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 10 | ||
| }, | ||
| { | ||
| "name":"rtmp", | ||
| "script":"unzip -o /tmp/nginx-rtmp-module.zip -d /tmp", | ||
| "packages":[], | ||
| "name": "rtmp", | ||
| "script": "unzip -o /tmp/nginx-rtmp-module.zip -d /tmp", | ||
| "packages": [], | ||
| "params": "--add-module=/tmp/nginx-rtmp-module", | ||
| "enable":false | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 20 | ||
| }, | ||
| { | ||
| "name":"web_dav", | ||
| "script":"unzip -o /tmp/nginx-dav-ext-module.zip -d /tmp", | ||
| "packages":[], | ||
| "params": "--with-http_dav_module --add-module=/tmp/nginx-dav-ext-module", | ||
| "enable":false | ||
| "name": "web_dav", | ||
| "script": "unzip -o /tmp/nginx-dav-ext-module.zip -d /tmp", | ||
| "packages": [], | ||
| "params": "--with-http_dav_module --add-module=/tmp/nginx-dav-ext-module", | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 30 | ||
| }, | ||
| { | ||
| "name":"geoip2", | ||
| "script":"unzip -o /tmp/ngx_http_geoip2_module.zip -d /tmp && tar -zxvf /tmp/libmaxminddb.tar.gz -C /tmp && cd /tmp/libmaxminddb && ./configure && make && make install", | ||
| "packages":[], | ||
| "name": "geoip2", | ||
| "script": "unzip -o /tmp/ngx_http_geoip2_module.zip -d /tmp && tar -zxvf /tmp/libmaxminddb.tar.gz -C /tmp && cd /tmp/libmaxminddb && ./configure && make && make install", | ||
| "packages": [], | ||
| "params": "--add-module=/tmp/ngx_http_geoip2_module", | ||
| "enable":false | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 40 | ||
| }, | ||
| { | ||
| "name":"http_substitutions_filter", | ||
| "script":"unzip -o /tmp/ngx_http_substitutions_filter_module.zip -d /tmp", | ||
| "packages":[], | ||
| "name": "http_substitutions_filter", | ||
| "script": "unzip -o /tmp/ngx_http_substitutions_filter_module.zip -d /tmp", | ||
| "packages": [], | ||
| "params": "--add-module=/tmp/ngx_http_substitutions_filter_module", | ||
| "enable":false | ||
| "enable": false, | ||
| "buildMode": "dynamic", | ||
| "provider": "local", | ||
| "dynamicSupport": "unknown", | ||
| "loadOrder": 50 | ||
| } | ||
| ] | ||
| ] |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/env bash | ||
| # Verify that every OpenResty version keeps build/module.json and | ||
| # build/module.catalog.json byte-identical (the two files must stay in sync). | ||
| set -euo pipefail | ||
|
|
||
| root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| failed=0 | ||
|
|
||
| for module_json in "${root_dir}"/apps/openresty/*/build/module.json; do | ||
| [[ -f "${module_json}" ]] || continue | ||
| catalog_json="$(dirname "${module_json}")/module.catalog.json" | ||
| # Only versions carrying the dynamic-module catalog need the sync check. | ||
| [[ -f "${catalog_json}" ]] || continue | ||
| if ! diff -u "${module_json}" "${catalog_json}"; then | ||
| echo "MISMATCH: ${module_json} and ${catalog_json} differ" | ||
| failed=1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ "${failed}" -ne 0 ]]; then | ||
| echo "OpenResty module.json/module.catalog.json consistency check failed" | ||
| exit 1 | ||
| fi | ||
| echo "OpenResty module.json/module.catalog.json consistency check passed" |
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.
Uh oh!
There was an error while loading. Please reload this page.