Skip to content

Commit

Permalink
fix: add nginx dynamic modules as variable
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Zipitria <[email protected]>
  • Loading branch information
fzipi committed Jan 5, 2025
1 parent b93c6ff commit fbf5a0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
6 changes: 4 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ target "nginx" {
inherits = ["platforms-base"]
dockerfile="nginx/Dockerfile"
args = {
NGINX_VERSION = "${nginx-version}"
LUA_MODULES = join(" ", lua-modules-debian)
NGINX_VERSION = "${nginx-version}"
NGINX_DYNAMIC_MODULES = join(" ", nginx-dynamic-modules)
}
tags = concat(tag("nginx"),
vtag("${crs-version}", "nginx")
Expand All @@ -159,8 +160,9 @@ target "nginx-alpine" {
inherits = ["platforms-base"]
dockerfile="nginx/Dockerfile-alpine"
args = {
NGINX_VERSION = "${nginx-version}"
LUA_MODULES = join(" ", lua-modules-alpine)
NGINX_DYNAMIC_MODULES = join(" ", nginx-dynamic-modules)
NGINX_VERSION = "${nginx-version}"
}
tags = concat(tag("nginx-alpine"),
vtag("${crs-version}", "nginx-alpine")
Expand Down
13 changes: 7 additions & 6 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ RUN set -eux; \
make -C lmdb/libraries/liblmdb install; \
strip /usr/local/lib/liblmdb*.so*


RUN set -eux; \
git clone https://github.com/owasp-modsecurity/ModSecurity --branch "v${MODSEC3_VERSION}" --depth 1 --recursive; \
cd ModSecurity; \
Expand All @@ -57,17 +58,17 @@ RUN set -eux; \

# Build modules
RUN set -eux; \
declare -a modules; \
modules=""; \
for module in ${NGINX_DYNAMIC_MODULES}; \
do \
repo=$(awk -F'/' '{print $2}' <<< "${module}"); \
git clone -b master --depth 1 https://github.com/${module}.git; \
modules+=("--add-dynamic-module=../${repo}"); \
repo=$(echo "${module}" | awk -F'/' '{print $2}'); \
git clone -b master --depth 1 "https://github.com/${module}.git" ; \
modules="${modules} --add-dynamic-module=../${repo}"; \
done; \
curl -sSL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -o nginx-${NGINX_VERSION}.tar.gz; \
curl -sSL "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx-${NGINX_VERSION}.tar.gz; \
tar -xzf nginx-${NGINX_VERSION}.tar.gz; \
cd ./nginx-${NGINX_VERSION}; \
./configure --with-compat ${modules[@]}; \
./configure --with-compat ${modules}; \
make modules; \
strip objs/*.so; \
cp objs/*.so /etc/nginx/modules/; \
Expand Down
11 changes: 6 additions & 5 deletions nginx/Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM nginxinc/nginx-unprivileged:${NGINX_VERSION}-alpine AS build

ARG MODSEC3_VERSION="n/a"
ARG LUA_VERSION="n/a"
ARG NGINX_DYNAMIC_MODULES="n/a"

USER root

Expand Down Expand Up @@ -53,17 +54,17 @@ RUN set -eux; \

# Build modules
RUN set -eux; \
declare -a modules; \
modules=""; \
for module in ${NGINX_DYNAMIC_MODULES}; \
do \
repo=$(awk -F'/' '{print $2}' <<< "${module}"); \
git clone -b master --depth 1 https://github.com/${module}.git; \
modules+=("--add-dynamic-module=../${repo}"); \
repo=$(echo "${module}" | awk -F'/' '{print $2}'); \
git clone -b master --depth 1 "https://github.com/${module}.git" ; \
modules="${modules} --add-dynamic-module=../${repo}"; \
done; \
curl -sSL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -o nginx-${NGINX_VERSION}.tar.gz; \
tar -xzf nginx-${NGINX_VERSION}.tar.gz; \
cd ./nginx-${NGINX_VERSION}; \
./configure --with-compat ${modules[@]};\
./configure --with-compat ${modules}; \
make modules; \
strip objs/*.so; \
cp objs/*.so /etc/nginx/modules/; \
Expand Down

0 comments on commit fbf5a0b

Please sign in to comment.