diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ee5a250fa91c8dcd99ffa93da4d0cef0c9ad8f28..10eef2eb6b9c17e9d515b176b0a909dd265928cc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,7 @@ before_script:
   - apk add git bash
   - git clone https://baltig.infn.it/mw-devel/helper-scripts.git helper-scripts
   - cp helper-scripts/scripts/* /usr/local/bin
+  - ls -al /usr/local/bin
   - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
   - export DOCKER_REGISTRY_HOST=${CI_REGISTRY}
   - export DOCKER_REGISTRY_NAMESPACE=${CI_PROJECT_PATH}
@@ -18,6 +19,8 @@ build:
   stage: build
   script:
     - env | sort
+    - ls -al /usr/local/bin
+    - ls -l `which sh`
     - cd docker && sh build-images.sh && sh push-images.sh
 
 push-to-dockerhub:
diff --git a/docker/build-images.sh b/docker/build-images.sh
index bd9ecc1116664076f882ccb1b5811eda1c4bfc4b..acbd55f5541ef73ae2928f3b52c8c520586a47d0 100644
--- a/docker/build-images.sh
+++ b/docker/build-images.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 set -e
 
 S2_IMAGES=${S2_IMAGES:-"base build clients ngx-voms-build ts"}
diff --git a/docker/ngx-voms-build/assets/build-install-ngx-voms.sh b/docker/ngx-voms-build/assets/build-install-ngx-voms.sh
index becfdf1ab8c42396d212f55200ee367dbc265e42..93d7da8acbb6f95d57e1666158a6be6bf6475502 100755
--- a/docker/ngx-voms-build/assets/build-install-ngx-voms.sh
+++ b/docker/ngx-voms-build/assets/build-install-ngx-voms.sh
@@ -39,6 +39,7 @@ usage()
     echo "OPTIONS"
     echo ""
     echo "-h|--help"
+    echo "-o|--opt-log to enable the --with-debug option and the optimization level -O2"
     echo "-d|--debug to enable the --with-debug option and the optimization level -O0"
     echo "-c|--coverage to add the --coverage option to the --with-{ld|cc}-opt option and enable the debug options"
     echo ""
@@ -50,12 +51,17 @@ usage()
 cc1=-g
 debug=""
 cc3=""
-cc2=-O3
+cc2=-O2
 ld=""
 
 while [ "$1" != "" ]; do
   option=`echo $1 | awk -F= '{print $1}'`
   case $option in
+    -o|--opt-log)
+      debug='--with-debug'
+      cc2=-O2
+      echo Enabled the debug option $debug and the optimization level $cc2
+      ;;
     -d|--debug)
       debug='--with-debug'
       cc2=-O0
@@ -73,7 +79,7 @@ while [ "$1" != "" ]; do
     *)
       debug=""
       cc3=""
-      cc2=-O3
+      cc2=-O2
       ld=""
       ;;
   esac
@@ -108,13 +114,22 @@ if [ ! -d "${module_root}" ]; then
     exit 1
 fi
 
+RESTY_PACKAGES_PREFIX=/usr/local/openresty
+ZLIB_PREFIX=/usr
+OPENSSL_PREFIX=/usr
+PCRE_PREFIX=/usr
 
 cd ${openresty_root}
-./configure ${RESTY_CONFIG_OPTIONS} \
-            ${debug} \
-            --with-cc-opt="${cc1} ${cc2} ${cc3}" \
-            ${ld} \
-            --add-module=${module_root}
+./configure \
+	--with-cc="ccache gcc -fdiagnostics-color=always" \
+	--with-cc-opt="-DNGX_LUA_ABORT_AT_PANIC -I${ZLIB_PREFIX}/include -I${PCRE_PREFIX}/include -I${OPENSSL_PREFIX}/include" \
+        --with-ld-opt="-L${ZLIB_PREFIX}/lib -L${PCRE_PREFIX}/lib -L${OPENSSL_PREFIX}/lib -Wl,-rpath,${ZLIB_PREFIX}/lib:${PCRE_PREFIX}/lib:${OPENSSL_PREFIX}/lib" \
+        --with-luajit-xcflags="-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT" \
+        ${RESTY_CONFIG_OPTIONS} \
+        ${debug} \
+        --with-cc-opt="${cc1} ${cc2} ${cc3}" \
+         ${ld} \
+        --add-module=${module_root}
 
 nginx_version=$(find build -name nginx.h | xargs awk '/define NGINX_VERSION/ {print $3}' | tr -d '"')
 cd build/nginx-${nginx_version}
diff --git a/docker/ngx-voms-build/assets/setup.sh b/docker/ngx-voms-build/assets/setup.sh
index aee7e11bce4a6336b42187a0acc464e62cc7410a..5eae38c4840958b77778cb9e7f7f4168a3a518a6 100644
--- a/docker/ngx-voms-build/assets/setup.sh
+++ b/docker/ngx-voms-build/assets/setup.sh
@@ -4,37 +4,34 @@ set -ex
 # adapted from https://github.com/openresty/docker-openresty
 
 # Docker Build Arguments
-RESTY_VERSION=${RESTY_VERSION:-"1.13.6.1"}
+RESTY_VERSION=${RESTY_VERSION:-"1.15.8.1"}
 RESTY_PREFIX=${HOME}/local/openresty
 RESTY_CONFIG_OPTIONS="\
-    --with-file-aio \
+    --with-pcre-jit \
+    --without-http_rds_json_module \
+    --without-http_rds_csv_module \
+    --without-lua_rds_parser \
+    --with-stream \
+    --with-stream_ssl_module \
+    --with-stream_ssl_preread_module \
+    --with-http_v2_module \
+    --without-mail_pop3_module \
+    --without-mail_imap_module \
+    --without-mail_smtp_module \
+    --with-http_stub_status_module \
+    --with-http_realip_module \
     --with-http_addition_module \
     --with-http_auth_request_module \
+    --with-http_secure_link_module \
+    --with-http_random_index_module \
+    --with-http_gzip_static_module \
+    --with-http_sub_module \
     --with-http_dav_module \
     --with-http_flv_module \
-    --with-http_geoip_module=dynamic \
-    --with-http_gunzip_module \
-    --with-http_gzip_static_module \
-    --with-http_image_filter_module=dynamic \
     --with-http_mp4_module \
-    --with-http_random_index_module \
-    --with-http_realip_module \
-    --with-http_secure_link_module \
-    --with-http_slice_module \
-    --with-http_ssl_module \
-    --with-http_stub_status_module \
-    --with-http_sub_module \
-    --with-http_v2_module \
-    --with-http_xslt_module=dynamic \
-    --with-ipv6 \
-    --with-mail \
-    --with-mail_ssl_module \
-    --with-md5-asm \
-    --with-pcre-jit \
-    --with-sha1-asm \
-    --with-stream \
-    --with-stream_ssl_module \
+    --with-http_gunzip_module \
     --with-threads \
+    --with-dtrace-probes \
     --prefix=${RESTY_PREFIX} \
     "
 
@@ -44,19 +41,19 @@ RESTY_CONFIG_OPTIONS="\
 
 sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
 
+# get zlib, openssl and pcre from the openresty repository
+
 sudo yum -y install \
     GeoIP-devel \
     gd-devel \
     gettext \
+    ccache \
     libxslt-devel \
     lcov \
-    openssl-devel \
     perl-ExtUtils-Embed \
     perl-Test-Nginx \
-    pcre-devel \
     readline-devel \
-    voms-devel \
-    zlib-devel
+    voms-devel 
 
 # 2) Download, unpack, configure, build and install OpenResty
 
@@ -66,10 +63,23 @@ sudo yum -y install \
 # configuring has the benefit that it builds and installs luajit, which
 # can then be reused during development (see the additions to .bashrc)
 
+RESTY_PACKAGES_PREFIX=/usr/local/openresty
+ZLIB_PREFIX=/usr
+OPENSSL_PREFIX=/usr
+PCRE_PREFIX=/usr
+#ZLIB_PREFIX=${RESTY_PACKAGES_PREFIX}/zlib
+#OPENSSL_PREFIX=${RESTY_PACKAGES_PREFIX}/openssl
+#PCRE_PREFIX=${RESTY_PACKAGES_PREFIX}/pcre
+
 wget https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz
 tar zxf openresty-${RESTY_VERSION}.tar.gz
 cd openresty-${RESTY_VERSION}
-./configure ${RESTY_CONFIG_OPTIONS}
+./configure \
+	--with-cc="ccache gcc -fdiagnostics-color=always" \
+	--with-cc-opt="-DNGX_LUA_ABORT_AT_PANIC -I${ZLIB_PREFIX}/include -I${PCRE_PREFIX}/include -I${OPENSSL_PREFIX}/include" \
+        --with-ld-opt="-L${ZLIB_PREFIX}/lib -L${PCRE_PREFIX}/lib -L${OPENSSL_PREFIX}/lib -Wl,-rpath,${ZLIB_PREFIX}/lib:${PCRE_PREFIX}/lib:${OPENSSL_PREFIX}/lib" \
+	--with-luajit-xcflags="-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT" \
+	${RESTY_CONFIG_OPTIONS}
 make
 make install
 cd -
@@ -80,6 +90,12 @@ cd -
 cat << EOF >> ${HOME}/openresty-env
 PATH="${RESTY_PREFIX}/luajit/bin:${RESTY_PREFIX}/nginx/sbin:${RESTY_PREFIX}/bin:\${PATH}"
 
+RESTY_PACKAGES_PREFIX=/usr/local/openresty
+
+ZLIB_PREFIX=/usr
+OPENSSL_PREFIX=/usr
+PCRE_PREFIX=/usr
+
 export RESTY_CONFIG_OPTIONS="${RESTY_CONFIG_OPTIONS} --with-luajit=${RESTY_PREFIX}/luajit"
 EOF