Skip to content

Instantly share code, notes, and snippets.

@mehyedes
Last active April 8, 2024 14:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mehyedes/bf5e3870907ddb9c9d3c3fe45d68c43d to your computer and use it in GitHub Desktop.
Save mehyedes/bf5e3870907ddb9c9d3c3fe45d68c43d to your computer and use it in GitHub Desktop.
Compiling NGINX module as dynamic module for use in docker
FROM nginx:1.14.2 AS builder
LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
ENV NGINX_VERSION 1.14.2
ENV VTS_VERSION 0.1.18
COPY ./badproxy /etc/apt/apt.conf.d/99fixbadproxy
RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y \
gnupg1 \
ca-certificates \
gcc \
libc-dev \
make \
openssl\
curl \
gnupg \
wget \
libpcre3 libpcre3-dev \
libghc-zlib-dev
RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \
wget "https://github.com/vozlt/nginx-module-vts/archive/v${VTS_VERSION}.tar.gz" -O vts.tar.gz
# Reuse same cli arguments as the nginx:1.14.2 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 "vts.tar.gz" && \
VTS_DIR="$(pwd)/nginx-module-vts-${VTS_VERSION}/" && \
cd /usr/src/nginx-$NGINX_VERSION && \
./configure --with-compat $CONFARGS --add-dynamic-module=$VTS_DIR && \
make && make install
FROM nginx:1.14.2
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
# Copy compiled static module
COPY --from=builder /usr/local/nginx/modules/ngx_http_vhost_traffic_status_module.so /usr/local/nginx/modules/ngx_http_vhost_traffic_status_module.so
COPY ./ssl/* /etc/nginx/ssl/cert/
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./default.conf /etc/nginx/conf.d/default.conf
COPY ./*.template /etc/nginx/conf.d/
COPY ./server/* /etc/nginx/conf.d/server/
COPY ./map/* /etc/nginx/conf.d/map/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment