From e449f8ed5b3a3997ead9a47b837cbdbddbe80589 Mon Sep 17 00:00:00 2001 From: Walter Oggioni Date: Tue, 23 Dec 2025 20:51:16 +0800 Subject: [PATCH] added rtmp module to nginx image --- .gitea/workflows/build-nginx.yaml | 12 ++++-------- nginx/Dockerfile | 9 ++++++++- nginx/build-rtmp.sh | 30 ++++++++++++++++++++++++++++++ nginx/build.sh | 7 +++++-- nginx/conf/nginx.conf | 11 +---------- 5 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 nginx/build-rtmp.sh diff --git a/.gitea/workflows/build-nginx.yaml b/.gitea/workflows/build-nginx.yaml index cc35bd0..3854612 100644 --- a/.gitea/workflows/build-nginx.yaml +++ b/.gitea/workflows/build-nginx.yaml @@ -9,14 +9,6 @@ jobs: "Build nginx docker images": runs-on: woryzen steps: - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.4.0 - with: - driver: docker-container - platforms: | - linux/amd64 - linux/arm64 - name: Login to Gitea container registry uses: docker/login-action@v3 @@ -28,10 +20,12 @@ jobs: name: Build and push nginx vanilla images uses: docker/build-push-action@v6 with: + builder: multiplatform-builder context: "{{defaultContext}}:nginx" platforms: | linux/amd64 linux/arm64 + linux/arm32v7 push: true pull: true ssh: default=/home/luser/.ssh/id_ed25519 @@ -50,10 +44,12 @@ jobs: name: Build and push nginx custom images uses: docker/build-push-action@v6 with: + builder: multiplatform-builder context: "{{defaultContext}}:nginx" platforms: | linux/amd64 linux/arm64 + linux/arm32v7 push: true pull: true ssh: default=/home/luser/.ssh/id_ed25519 diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 7b37eb1..5865316 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -65,6 +65,7 @@ ADD --chown=luser:luser git@github.com:woggioni/nginx.git#release-${NGINX_VERSIO FROM build_stage_2_${NGINX_BRANCH} AS build ADD --chown=luser:luser https://github.com/openresty/headers-more-nginx-module.git /ngx_headers_more ADD --chown=luser:luser https://github.com/google/ngx_brotli.git /ngx_brotli + USER root WORKDIR / RUN hg clone http://hg.nginx.org/njs /njs @@ -74,6 +75,12 @@ WORKDIR /home/luser ADD --chown=luser:luser --chmod=755 ./build.sh ./build.sh RUN ./build.sh +FROM build_stage_2_${NGINX_BRANCH} AS build-rtmp +ADD --chown=luser:luser https://github.com/arut/nginx-rtmp-module.git /ngx-rtmp-module +USER luser +WORKDIR /home/luser +ADD --chown=luser:luser --chmod=755 ./build-rtmp.sh ./build-rtmp.sh +RUN ./build-rtmp.sh FROM base AS release ARG VERSION @@ -91,7 +98,7 @@ RUN --mount=type=cache,target=/var/cache/apk \ --mount=type=bind,source=install.sh,target=/install.sh \ (cd nginx && sh /install.sh) RUN --mount=type=cache,target=/var/cache/apk apk del .install_deps - +COPY --from=build-rtmp --chown=root:root /nginx/objs/ngx_rtmp_module.so /usr/lib/nginx/modules/ COPY --from=build /home/luser/libressl/openssl.cnf /etc/ssl/openssl.cnf COPY conf/nginx.conf /etc/nginx/nginx.conf COPY conf/dhparam /etc/nginx/dhparam diff --git a/nginx/build-rtmp.sh b/nginx/build-rtmp.sh new file mode 100644 index 0000000..be236d6 --- /dev/null +++ b/nginx/build-rtmp.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +set -e + +CONFIG=' + --prefix=/etc/nginx + --sbin-path=/usr/sbin/nginx + --modules-path=/usr/lib/nginx/modules + --conf-path=/etc/nginx/nginx.conf + --error-log-path=/var/log/nginx/error.log + --http-log-path=/var/log/nginx/access.log + --pid-path=/var/run/nginx.pid + --lock-path=/var/run/nginx.lock + --http-client-body-temp-path=/var/cache/nginx/client_temp + --http-proxy-temp-path=/var/cache/nginx/proxy_temp + --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp + --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp + --http-scgi-temp-path=/var/cache/nginx/scgi_temp + --user=nginx + --group=nginx + --with-http_ssl_module + --add-dynamic-module=/ngx-rtmp-module +' + +cd /nginx + +auto/configure $CONFIG \ + --with-cc-opt="-I/home/luser/libressl/build/include" \ + --with-ld-opt="-lstdc++ -L/home/luser/libressl/build/ssl -L/home/luser/libressl/build/crypto" +make -j$(nproc) diff --git a/nginx/build.sh b/nginx/build.sh index d584fe3..c6c07bf 100644 --- a/nginx/build.sh +++ b/nginx/build.sh @@ -18,6 +18,7 @@ CONFIG=' --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx + --with-pcre --with-http_ssl_module --with-http_realip_module --with-http_addition_module @@ -25,6 +26,8 @@ CONFIG=' --with-http_dav_module --with-http_flv_module --with-http_mp4_module + --with-http_degradation_module + --with-http_slice_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module @@ -40,14 +43,14 @@ CONFIG=' --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module - --with-mail + --with-mail=dynamic --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module --with-http_v3_module --add-dynamic-module=/ngx_headers_more - --add-dynamic-module=/ngx_brotli + --add-module=/ngx_brotli --add-dynamic-module=/njs/nginx ' diff --git a/nginx/conf/nginx.conf b/nginx/conf/nginx.conf index 6596981..afd23ca 100644 --- a/nginx/conf/nginx.conf +++ b/nginx/conf/nginx.conf @@ -1,13 +1,4 @@ - -load_module modules/ngx_http_xslt_filter_module.so; -#load_module modules/ngx_http_image_filter_module.so; -load_module modules/ngx_http_geoip_module.so; -#load_module modules/ngx_http_perl_module.so; -load_module modules/ngx_stream_geoip_module.so; -load_module modules/ngx_http_headers_more_filter_module.so; -load_module modules/ngx_http_brotli_static_module.so; -load_module modules/ngx_http_brotli_filter_module.so; -#load_module modules/ngx_http_js_module.so; +include /etc/nginx/conf.d/modules/*.conf; user nginx; worker_processes 1;