Skip to content

Instantly share code, notes, and snippets.

@antonioabelgc
Last active April 15, 2024 11:29
Show Gist options
  • Save antonioabelgc/e008b532a7ee58d56ebb682d88981eb0 to your computer and use it in GitHub Desktop.
Save antonioabelgc/e008b532a7ee58d56ebb682d88981eb0 to your computer and use it in GitHub Desktop.
Dockerfile that builds an Alpine-based Nginx image with the Brotli compression module
ARG NGINX_VERSION=1.25.4
FROM alpine:3.18 as builder
ARG NGINX_VERSION
WORKDIR /build
RUN apk update && apk upgrade
RUN apk add pcre pcre-dev zlib zlib-dev openssl libressl-dev wget git gcc brotli-dev g++ make
RUN wget https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && tar -zxf nginx-$NGINX_VERSION.tar.gz
RUN git clone https://github.com/google/ngx_brotli && cd ngx_brotli && git submodule update --init --recursive
RUN cd nginx-$NGINX_VERSION && ./configure --with-compat --add-dynamic-module=../ngx_brotli && make modules
FROM nginx:$NGINX_VERSION-alpine
ARG NGINX_VERSION
COPY --from=builder /build/nginx-$NGINX_VERSION/objs/ngx_http_brotli_static_module.so /etc/nginx/modules/
COPY --from=builder /build/nginx-$NGINX_VERSION/objs/ngx_http_brotli_filter_module.so /etc/nginx/modules/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment