Skip to content
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

unable to build nginx image with dynamic modules #1328

Open
ihola777 opened this issue Feb 21, 2025 · 2 comments
Open

unable to build nginx image with dynamic modules #1328

ihola777 opened this issue Feb 21, 2025 · 2 comments

Comments

@ihola777
Copy link

i am trying to build nginx with some dynamic modules and i got two major issues here.
the one is can't input multiple words in double quote string, something like "headers-more rtmp encrypted-session", the action seems like can't recognize the string properly.
ant another is even i input only one word, the action still can't implement properly.

user test input: headers-more
dockerfile: https://raw.githubusercontent.com/nginxinc/docker-nginx/master/modules/Dockerfile.alpine

failed code:

- name: Build and export to Docker
        uses: docker/build-push-action@v6
        with:
          context: "{{defaultContext}}:nginx-builder"
          file: Dockerfile.alpine
          build-args: |
            ENABLED_MODULES="${{ github.event.inputs.modules }}"
          load: true
          tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE }}:test

      - name: Test
        run: |
          docker run --rm ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE }}:test

error:

::error::buildx failed with: ERROR: failed to solve: process "/bin/ash -exo pipefail -c apk update     && apk add linux-headers openssl-dev pcre2-dev zlib-dev openssl abuild                musl-dev libxslt libxml2-utils make gcc unzip git                xz g++ coreutils curl     && printf \"#!/bin/sh\\\\nSETFATTR=true /usr/bin/abuild -F \\\"\\$@\\\"\\\\n\" > /usr/local/bin/abuild     && chmod +x /usr/local/bin/abuild     && git clone -b ${NGINX_VERSION}-${PKG_RELEASE} https://github.com/nginx/pkg-oss/     && cd pkg-oss     && mkdir /tmp/packages     && for module in $ENABLED_MODULES; do         echo \"Building $module for nginx-$NGINX_VERSION\";         if [ -d /modules/$module ]; then             echo \"Building $module from user-supplied sources\";             if [ ! -s /modules/$module/source ]; then                 echo \"No source file for $module in modules/$module/source, exiting\";                 exit 1;             fi;             if [ -f /modules/$module/build-deps ]; then                 echo \"Installing $module build dependencies\";                 apk update && apk add $(cat /modules/$module/build-deps | xargs);             fi;             if [ -x /modules/$module/prebuild ]; then                 echo \"Running prebuild script for $module\";                 /modules/$module/prebuild;             fi;             /pkg-oss/build_module.sh -v $NGINX_VERSION -f -y -o /tmp/packages -n $module $(cat /modules/$module/source);             BUILT_MODULES=\"$BUILT_MODULES $(echo $module | tr '[A-Z]' '[a-z]' | tr -d '[/_\\-\\.\\t ]')\";         elif make -C /pkg-oss/alpine list | grep -E \"^$module\\s+\\d+\" > /dev/null; then             echo \"Building $module from pkg-oss sources\";             cd /pkg-oss/alpine;             make abuild-module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION;             apk add $(. ./abuild-module-$module/APKBUILD; echo $makedepends;);             make module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION;             find ~/packages -type f -name \"*.apk\" -exec mv -v {} /tmp/packages/ \\;;             BUILT_MODULES=\"$BUILT_MODULES $module\";         else             echo \"Don't know how to build $module module, exiting\";             exit 1;         fi;     done     && echo \"BUILT_MODULES=\\\"$BUILT_MODULES\\\"\" > /tmp/packages/modules.env" did not complete successfully: exit code: 1

sucessed code:

- name: build and push
        run: | 
          cd nginx-builder
          docker build -f Dockerfile.alpine --build-arg ENABLED_MODULES="${{ github.event.inputs.modules }}"  -t ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE }}:latest .
          docker push ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE }}:latest

log:

#8 165.9 Configuration summary
#8 165.9   + using threads
#8 165.9   + using system PCRE2 library
#8 165.9   + using system OpenSSL library
#8 165.9   + using system zlib library
#8 165.9 
#8 165.9   nginx path prefix: "/etc/nginx"
#8 165.9   nginx binary file: "/usr/sbin/nginx"
#8 165.9   nginx modules path: "/usr/lib/nginx/modules"
#8 165.9   nginx configuration prefix: "/etc/nginx"
#8 165.9   nginx configuration file: "/etc/nginx/nginx.conf"
#8 165.9   nginx pid file: "/var/run/nginx.pid"
#8 165.9   nginx error log file: "/var/log/nginx/error.log"
#8 165.9   nginx http access log file: "/var/log/nginx/access.log"
#8 165.9   nginx http client request body temporary files: "/var/cache/nginx/client_temp"
#8 165.9   nginx http proxy temporary files: "/var/cache/nginx/proxy_temp"
#8 165.9   nginx http fastcgi temporary files: "/var/cache/nginx/fastcgi_temp"
#8 165.9   nginx http uwsgi temporary files: "/var/cache/nginx/uwsgi_temp"
#8 165.9   nginx http scgi temporary files: "/var/cache/nginx/scgi_temp"
#8 165.9 
#8 165.9 make[1]: Entering directory '/pkg-oss/alpine/abuild-module-headers-more/src/nginx-1.27.4'
#8 165.9 make -f objs/Makefile modules
#8 166.0 make[2]: Entering directory '/pkg-oss/alpine/abuild-module-headers-more/src/nginx-1.27.4'
#8 166.0 gcc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g  -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/http/v3 -I src/mail -I src/stream \
#8 166.0 	-o objs/addon/src/ngx_http_headers_more_filter_module.o \
#8 166.0 	../headers-more-nginx-module-f8f80997f19a41dc4181987544b9f3570cc3d6da/src/ngx_http_headers_more_filter_module.c
#8 166.0 gcc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g  -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/http/v3 -I src/mail -I src/stream \
#8 166.0 	-o objs/addon/src/ngx_http_headers_more_headers_out.o \
#8 166.0 	../headers-more-nginx-module-f8f80997f19a41dc4181987544b9f3570cc3d6da/src/ngx_http_headers_more_headers_out.c
#8 168.9 gcc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g  -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/http/v3 -I src/mail -I src/stream \
#8 168.9 	-o objs/addon/src/ngx_http_headers_more_headers_in.o \
#8 168.9 	../headers-more-nginx-module-f8f80997f19a41dc4181987544b9f3570cc3d6da/src/ngx_http_headers_more_headers_in.c
#8 169.8 gcc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g  -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/http/v3 -I src/mail -I src/stream \
#8 169.8 	-o objs/addon/src/ngx_http_headers_more_util.o \
#8 169.8 	../headers-more-nginx-module-f8f80997f19a41dc4181987544b9f3570cc3d6da/src/ngx_http_headers_more_util.c
#8 171.8 gcc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g  -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/http/v3 -I src/mail -I src/stream \
#8 171.8 	-o objs/ngx_http_headers_more_filter_module_modules.o \
#8 171.8 	objs/ngx_http_headers_more_filter_module_modules.c
#8 173.0 gcc -o objs/ngx_http_headers_more_filter_module.so \
#8 173.0 objs/addon/src/ngx_http_headers_more_filter_module.o \
#8 173.0 objs/addon/src/ngx_http_headers_more_headers_out.o \
#8 173.0 objs/addon/src/ngx_http_headers_more_headers_in.o \
#8 173.0 objs/addon/src/ngx_http_headers_more_util.o \
#8 173.0 objs/ngx_http_headers_more_filter_module_modules.o \
#8 173.0 -Wl,--as-needed,-O1,--sort-common -Wl,-z,pack-relative-relocs \
#8 173.0 -shared
#8 173.1 make[2]: Leaving directory '/pkg-oss/alpine/abuild-module-headers-more/src/nginx-1.27.4'
#8 173.1 make[1]: Leaving directory '/pkg-oss/alpine/abuild-module-headers-more/src/nginx-1.27.4'
#8 173.6 >>> nginx-module-headers-more-dbg: Running split function dbg...
#8 173.8 >>> nginx-module-headers-more-dbg: Preparing subpackage nginx-module-headers-more-dbg...
#8 173.9 fatal: not a git repository (or any of the parent directories): .git
#8 173.9 fatal: not a git repository (or any of the parent directories): .git
#8 174.0 >>> nginx-module-headers-more-dbg: Running postcheck for nginx-module-headers-more-dbg
#8 174.1 >>> nginx-module-headers-more: Running postcheck for nginx-module-headers-more
#8 174.1 >>> nginx-module-headers-more: Preparing package nginx-module-headers-more...
#8 174.2 >>> nginx-module-headers-more: Script found. /bin/sh added as a dependency for nginx-module-headers-more-1.27.4.0.37-r1.apk
#8 174.2 fatal: not a git repository (or any of the parent directories): .git
#8 174.2 fatal: not a git repository (or any of the parent directories): .git
#8 174.2 >>> nginx-module-headers-more: Adding .post-install
#8 174.3 >>> nginx-module-headers-more-dbg: Scanning shared objects
#8 174.4 >>> nginx-module-headers-more: Scanning shared objects
#8 174.4 >>> nginx-module-headers-more-dbg: Tracing dependencies...
#8 174.5 	nginx~1.27.4
#8 174.5 	nginx-r1.27.4
#8 174.5 >>> nginx-module-headers-more-dbg: Package size: 347.3 KB
#8 174.5 >>> nginx-module-headers-more-dbg: Compressing data...
#8 174.7 >>> nginx-module-headers-more-dbg: Create checksum...
#8 174.9 >>> nginx-module-headers-more-dbg: Create nginx-module-headers-more-dbg-1.27.4.0.37-r1.apk
#8 174.9 >>> nginx-module-headers-more: Tracing dependencies...
#8 175.0 	nginx~1.27.4
#8 175.0 	nginx-r1.27.4
#8 175.0 	/bin/sh
#8 175.0 	so:libc.musl-x86_64.so.1
#8 175.1 >>> nginx-module-headers-more: Package size: 52.7 KB
#8 175.1 >>> nginx-module-headers-more: Compressing data...
#8 175.1 >>> nginx-module-headers-more: Create checksum...
#8 175.3 >>> nginx-module-headers-more: Create nginx-module-headers-more-1.27.4.0.37-r1.apk
#8 175.3 real 71.09
#8 175.3 user 36.84
#8 175.3 sys 39.62
#8 175.3 + find /root/packages -type f -name '*.apk' -exec mv -v '{}' /tmp/packages/ ';'
#8 175.3 renamed '/root/packages/alpine/x86_64/nginx-module-headers-more-1.27.4.0.37-r1.apk' -> '/tmp/packages/nginx-module-headers-more-1.27.4.0.37-r1.apk'
#8 175.4 renamed '/root/packages/alpine/x86_64/nginx-module-headers-more-dbg-1.27.4.0.37-r1.apk' -> '/tmp/packages/nginx-module-headers-more-dbg-1.27.4.0.37-r1.apk'
#8 175.4 + BUILT_MODULES=' headers-more'
#8 175.4 + echo 'BUILT_MODULES=" headers-more"'
#8 DONE 175.9s
#9 [stage-1 2/2] RUN --mount=type=bind,target=/tmp/packages/,source=/tmp/packages/,from=builder     . /tmp/packages/modules.env     && for module in $BUILT_MODULES; do            apk add --no-cache --allow-untrusted /tmp/packages/nginx-module-${module}-1.27.4*.apk;        done
#9 1.126 fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
#9 1.332 fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
#9 2.324 (1/1) Installing nginx-module-headers-more (1.27.4.0.37-r1)
#9 2.389 Executing nginx-module-headers-more-1.27.4.0.37-r1.post-install
#9 2.396 ----------------------------------------------------------------------
#9 2.396 
#9 2.396 The 3rd-party headers-more dynamic module for nginx has been installed.
#9 2.396 To enable this module, add the following to /etc/nginx/nginx.conf
#9 2.396 and reload nginx:
#9 2.396 
#9 2.396     load_module modules/ngx_http_headers_more_filter_module.so;
#9 2.396 
#9 2.396 Please refer to the module documentation for further details:
#9 2.396 https://github.com/openresty/headers-more-nginx-module
#9 2.396 
#9 2.396 ----------------------------------------------------------------------
#9 2.399 OK: 45 MiB in 68 packages
#9 DONE 3.1s
@crazy-max
Copy link
Member

crazy-max commented Feb 25, 2025

error:

::error::buildx failed with: ERROR: failed to solve: process "/bin/ash -exo pipefail -c apk update     && apk add linux-headers openssl-dev pcre2-dev zlib-dev openssl abuild                musl-dev libxslt libxml2-utils make gcc unzip git                xz g++ coreutils curl     && printf \"#!/bin/sh\\\\nSETFATTR=true /usr/bin/abuild -F \\\"\\$@\\\"\\\\n\" > /usr/local/bin/abuild     && chmod +x /usr/local/bin/abuild     && git clone -b ${NGINX_VERSION}-${PKG_RELEASE} https://github.com/nginx/pkg-oss/     && cd pkg-oss     && mkdir /tmp/packages     && for module in $ENABLED_MODULES; do         echo \"Building $module for nginx-$NGINX_VERSION\";         if [ -d /modules/$module ]; then             echo \"Building $module from user-supplied sources\";             if [ ! -s /modules/$module/source ]; then                 echo \"No source file for $module in modules/$module/source, exiting\";                 exit 1;             fi;             if [ -f /modules/$module/build-deps ]; then                 echo \"Installing $module build dependencies\";                 apk update && apk add $(cat /modules/$module/build-deps | xargs);             fi;             if [ -x /modules/$module/prebuild ]; then                 echo \"Running prebuild script for $module\";                 /modules/$module/prebuild;             fi;             /pkg-oss/build_module.sh -v $NGINX_VERSION -f -y -o /tmp/packages -n $module $(cat /modules/$module/source);             BUILT_MODULES=\"$BUILT_MODULES $(echo $module | tr '[A-Z]' '[a-z]' | tr -d '[/_\\-\\.\\t ]')\";         elif make -C /pkg-oss/alpine list | grep -E \"^$module\\s+\\d+\" > /dev/null; then             echo \"Building $module from pkg-oss sources\";             cd /pkg-oss/alpine;             make abuild-module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION;             apk add $(. ./abuild-module-$module/APKBUILD; echo $makedepends;);             make module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION;             find ~/packages -type f -name \"*.apk\" -exec mv -v {} /tmp/packages/ \\;;             BUILT_MODULES=\"$BUILT_MODULES $module\";         else             echo \"Don't know how to build $module module, exiting\";             exit 1;         fi;     done     && echo \"BUILT_MODULES=\\\"$BUILT_MODULES\\\"\" > /tmp/packages/modules.env" did not complete successfully: exit code: 1

Can you show the full logs of Build and export to Docker step or link to your repo please?

@JiyongShi
Copy link

same issue with permission error:

#9 93.09 >>> nginx-module-davextmodule: Checking sha512sums...
#9 93.09 nginx-module-davextmodule-1.27.4.tar.gz: OK
#9 93.10 davextmodule-1.27.4.tar.gz: OK
#9 93.10 COPYRIGHT: OK
#9 93.10 >>> nginx-module-davextmodule: Unpacking /tmp/build_module.sh.35/pkg-oss/alpine/abuild-module-davextmodule/nginx-module-davextmodule-1.27.4.tar.gz...
#9 93.11 tar: nginx-1.27.4/man: Cannot change mode to rwxr-xr-x: Bad address
#9 93.11 tar: nginx-1.27.4/auto: Cannot change mode to rwxr-xr-x: Bad address
#9 93.12 tar: nginx-1.27.4/html: Cannot change mode to rwxr-xr-x: Bad address

can use https://raw.githubusercontent.com/nginxinc/docker-nginx/master/modules/Dockerfile.alpine test this action.
https://github.com/nginxinc/docker-nginx/blob/master/modules/README.md Requirements show NEED BuildKit, maybe this problem?
direct run docker build is success, use this action always fail with above error, even change tar destination folder to 777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants