diff --git a/Dockerfile b/Dockerfile index f1ceb6f..4ea19f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ ARG NGINX_INGRESS_VERSION=${NGINX_INGRESS_VERSION:-latest} FROM quay.io/kubernetes-ingress-controller/nginx-ingress-controller:${NGINX_INGRESS_VERSION} ARG PKGNAME=${PKGNAME:-nginx-module-sigsci-nxo} +ARG BUILD_NUMBER=146 # Change to the root user to update the container USER root @@ -9,23 +10,24 @@ USER root # NOTE: The nginx native module to be installed needs to be for # the correct version of nginx installed; this applies # to both nginx.org and openresty nginx distributions. -RUN apt-get update && apt-get install -y apt-transport-https gnupg lsb-release \ - # Figure out which debian release/codename this is - && CODENAME=$(lsb_release -c | sed 's/^Codename:\s*//') \ - # The sid (unstable) codname is not supported, but buster (previous stable) will work - && if [ "${CODENAME}" = "sid" ]; then CODENAME="buster"; fi \ +RUN apk update && apk add --no-cache gnupg wget --virtual ./build_deps \ + # Figure out which alpine release this is + && ALPINE_RELEASE=$(cat /etc/alpine-release | sed 's/\./\_/g') \ + && ALPINE_RELEASE=${ALPINE_RELEASE::-2} \ # Figure out which nginx is installed in the container && NGXVERSION=$(nginx -v 2>&1 | sed 's%^[^/]*/\([0-9]*\.[0-9]*\.[0-9]*\).*%\1%') \ - # Add the signal sciences apt repo - && (curl -s -S -L https://apt.signalsciences.net/release/gpgkey | apt-key add -) \ - && (echo "deb https://apt.signalsciences.net/release/debian/ ${CODENAME} main" > /etc/apt/sources.list.d/sigsci-release.list) \ - && apt-get update \ - # Download and force install the package as nginx was installed from source not package - && apt-get download nginx-module-sigsci-nxo=${NGXVERSION}\* \ - && (dpkg --force-all -i nginx-module-sigsci-nxo_${NGXVERSION}*.deb || true) \ - && rm -f nginx-module-sigsci-nxo_${NGXVERSION}*.deb \ - && sed -i "s@^#pid.*@&\nload_module /usr/lib/nginx/modules/ngx_http_sigsci_nxo_module-${NGXVERSION}.so;\n@" /usr/local/openresty/nginx/conf/nginx.conf \ - && rm -rf /var/lib/apt/lists/* - + # Get the latest version of the sigsci nginx native module + && MODULE_VERSION=$(wget -O- -q https://dl.signalsciences.net/sigsci-module-nginx-native/VERSION) \ + # Get the correct sigsci nginx native module based on alpine version, nginx version, and module version + && wget -O /tmp/nginx-module-sigsci-nxo_${NGXVERSION}-${BUILD_NUMBER}-alpine${ALPINE_RELEASE}.tar.gz https://dl.signalsciences.net/sigsci-module-nginx-native/${MODULE_VERSION}/alpine/alpine${ALPINE_RELEASE}/nginx-module-sigsci-nxo_${NGXVERSION}-${BUILD_NUMBER}-alpine${ALPINE_RELEASE}.tar.gz \ + # Manually install the sigsci native nginx module and update nginx.conf + && tar xvfz /tmp/nginx-module-sigsci-nxo_${NGXVERSION}-${BUILD_NUMBER}-alpine${ALPINE_RELEASE}.tar.gz -C /tmp || : \ + && mkdir -p /usr/lib/nginx/modules \ + && mv /tmp/ngx_http_sigsci_nxo_module-${NGXVERSION}.so /usr/lib/nginx/modules/ngx_http_sigsci_module.so \ + && ln -s /usr/lib/nginx/modules/ngx_http_sigsci_module.so /etc/nginx/modules/ngx_http_sigsci_module.so \ + && sed -i 's@^pid.*@&\nload_module /usr/lib/nginx/modules/ngx_http_sigsci_module.so;\n@' /etc/nginx/nginx.conf \ + # cleanup + && rm /tmp/nginx-module-sigsci-nxo_${NGXVERSION}-${BUILD_NUMBER}-alpine${ALPINE_RELEASE}.tar.gz /tmp/*.so \ + && apk del --no-cache ./build_deps # Change back to the www-data user for executing nginx at runtime USER www-data