-
-
Save ZIMkaRU/0c6a65b5c189f8f7020e46ce6fdcea9d to your computer and use it in GitHub Desktop.
Revisions
-
hermanbanken revised this gist
Jun 21, 2018 . No changes.There are no files selected for viewing
-
hermanbanken revised this gist
Jun 21, 2018 . 1 changed file with 2 additions and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,7 @@ This gist offers a way to build a NGINX ‘dynamic module’ against the widely used “nginx:alpine” docker image. Simply copy this Dockerfile & replace the arguments of the “wget” & “tar” & “configure” commands to include the module you want to build, then adjust the COPY command copying the module (.so file). In this example the NCHAN module is used as an example. If you found this helpful, please leave a comment / reaction here! :love: -
hermanbanken created this gist
Jun 21, 2018 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ FROM nginx:alpine AS builder # nginx:alpine contains NGINX_VERSION environment variable, like so: # ENV NGINX_VERSION 1.15.0 # Our NCHAN version ENV NCHAN_VERSION 1.1.15 # Download sources RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \ wget "https://github.com/slact/nchan/archive/v${NCHAN_VERSION}.tar.gz" -O nchan.tar.gz # For latest build deps, see https://github.com/nginxinc/docker-nginx/blob/master/mainline/alpine/Dockerfile RUN apk add --no-cache --virtual .build-deps \ gcc \ libc-dev \ make \ openssl-dev \ pcre-dev \ zlib-dev \ linux-headers \ curl \ gnupg \ libxslt-dev \ gd-dev \ geoip-dev # Reuse same cli arguments as the nginx:alpine image used to build RUN CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \ tar -zxC /usr/src -f nginx.tar.gz && \ tar -xzvf "nchan.tar.gz" && \ NCHANDIR="$(pwd)/nchan-${NCHAN_VERSION}" && \ cd /usr/src/nginx-$NGINX_VERSION && \ ./configure --with-compat $CONFARGS --add-dynamic-module=$NCHANDIR && \ make && make install FROM nginx:alpine # Extract the dynamic module NCHAN from the builder image COPY --from=builder /usr/local/nginx/modules/ngx_nchan_module.so /usr/local/nginx/modules/ngx_nchan_module.so RUN rm /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/nginx.conf COPY default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 STOPSIGNAL SIGTERM CMD ["nginx", "-g", "daemon off;"] 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ # Compiling NGINX module as dynamic module for use in docker NGINX offers some very convenient Docker containers, but it is not documented how to extend the functionality of those containers without re-compiling NGINX yourself and continuously adapting your Dockerfile to match the ones in https://github.com/nginxinc/docker-nginx/. This gist offers a way to build a NGINX ‘dynamic module’ against the widely used “nginx:alpine” docker image. Simply copy this Dockerfile & replace the arguments of the “wget” & “tar” & “configure” commands to include the module you want to build, then adjust the COPY command copying the module (.so file). If you found this helpful, please leave a comment / reaction here! :love: 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ # Addition: load NCHAN load_module /usr/local/nginx/modules/ngx_nchan_module.so; user nginx; worker_processes 5; # Addition: ultiple workers for NCHAN error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }