Skip to content

Instantly share code, notes, and snippets.

@kujiy
Last active April 7, 2022 13:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kujiy/75b13e140c960afc72281a7bbf8df4f8 to your computer and use it in GitHub Desktop.
Save kujiy/75b13e140c960afc72281a7bbf8df4f8 to your computer and use it in GitHub Desktop.
Dockerfile for Nginx with custom modules
version: '3'
services:
reverseproxy:
build:
context: .
container_name: test
ports:
- 82:80
restart: always
volumes:
- ./nginx:/etc/nginx # docker cp nginx-official-image:/etc/nginx
logging:
options:
max-size: "1m"
max-file: "10"
FROM alpine:3.10.1
LABEL maintainer "Adrian B. Danieli - https://github.com/sickp"
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
ENV NGINX_VERSION 1.19.1
RUN set -ex \
&& apk add --no-cache \
ca-certificates \
libressl \
pcre \
zlib \
&& apk add --no-cache --virtual .build-deps \
build-base \
linux-headers \
libressl-dev \
pcre-dev \
wget \
zlib-dev \
&& cd /tmp \
&& wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
&& tar xzf nginx-${NGINX_VERSION}.tar.gz \
&& cd /tmp/nginx-${NGINX_VERSION} \
&& ./configure \
\
--with-debug \
\
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
\
--user=nginx \
--group=nginx \
\
--with-threads \
\
--with-file-aio \
\
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_stub_status_module \
\
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
\
--with-mail \
--with-mail_ssl_module \
\
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& sed -i -e 's/#access_log logs\/access.log main;/access_log \/dev\/stdout;/' -e 's/#error_log logs\/error.log notice;/error_log stderr notice;/' /etc/nginx/nginx.conf \
&& adduser -D nginx \
&& mkdir -p /var/cache/nginx \
&& apk del .build-deps \
&& rm -rf /tmp/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment