Skip to content

Instantly share code, notes, and snippets.

@isapir
Created December 28, 2022 06:16
Show Gist options
  • Save isapir/087a4894ae09ffaf938fee1630f2b7d9 to your computer and use it in GitHub Desktop.
Save isapir/087a4894ae09ffaf938fee1630f2b7d9 to your computer and use it in GitHub Desktop.
## image size 1.36GB
FROM alpine AS nginx-builder
ARG NGINX_VERSION=1.23.1
ARG OPENSSL_VERSION=3.0.7
ARG ZLIB_VERSION=1.2.13
ARG NGINX_DIR=/usr/local/nginx
RUN apk --update add bash curl perl vim pcre-dev build-base linux-headers \
&& mkdir -p /usr/local/src && cd /usr/local/src \
&& curl -sL https://github.com/openssl/openssl/archive/refs/tags/openssl-${OPENSSL_VERSION}.tar.gz | tar xvz -C . \
&& curl -sL https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz | tar xvz -C . \
&& curl -sL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar xvz -C . \
&& cd nginx-${NGINX_VERSION} \
&& ./configure --with-pcre --with-http_ssl_module \
--with-openssl=../openssl-openssl-${OPENSSL_VERSION} \
--with-zlib=../zlib-${ZLIB_VERSION} \
--with-http_realip_module --with-http_sub_module --modules-path=/etc/nginx/modules \
--with-http_v2_module --with-stream --with-http_addition_module --with-http_mp4_module \
--with-cc-opt="-static" --with-ld-opt="-static" \
&& make \
&& make install
## image size 18.8MB
FROM alpine AS nginx
ARG CHOWN=0:1000
COPY --chown=${CHOWN} --from=nginx-builder /usr/local/nginx /usr/local/nginx
EXPOSE 80 443
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment