-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile-deb
77 lines (62 loc) · 2.98 KB
/
Dockerfile-deb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Dockerfile for building libnginx-mod-brotli for Debian / Ubuntu
#
# Usage :
#
# docker build -t build-nginx-brotli -f Dockerfile-deb \
# --build-arg DISTRIB=debian --build-arg RELEASE=bullseye \
# --build-arg NGINX_VERSION=1.18.0 .
#
# Or Ubuntu :
#
# docker build -t build-nginx-brotli -f Dockerfile-deb \
# --build-arg DISTRIB=ubuntu --build-arg RELEASE=noble \
# --build-arg NGINX_VERSION=1.18.0 .
#
# Then :
#
# docker run build-nginx-brotli
# docker cp $(docker ps -l -q):/src ~/Downloads/
# And once you don't need it anymore :
# docker rm $(docker ps -l -q)
#
# Latest ngx_brotli version : https://github.com/google/ngx_brotli
#
# Latest nginx version : https://nginx.org/en/download.html
# Or :
# curl -s https://nginx.org/packages/debian/pool/nginx/n/nginx/ |grep '"nginx_' | sed -n "s/^.*\">nginx_\(.*\)\~.*$/\1/p" |sort -Vr |head -1| cut -d'-' -f1
ARG DISTRIB=debian
ARG RELEASE=bullseye
FROM ${DISTRIB}:${RELEASE}
LABEL org.opencontainers.image.authors="Cyril Aknine <[email protected]>"
ARG DISTRIB
ARG RELEASE
#ARG CHANGELOG_MSG
ARG DEBIAN_FRONTEND="noninteractive"
ENV TZ=Europe/Paris
RUN apt-get update && apt-get --no-install-recommends --no-install-suggests -y install \
git wget ca-certificates curl openssl gnupg2 apt-transport-https \
unzip make libbrotli-dev libpcre3-dev zlib1g-dev build-essential devscripts \
debhelper quilt lsb-release libssl-dev lintian uuid-dev
ARG NGINX_VERSION=1.26.0
ARG NGINX_DEB_RELEASE=1
ARG BROTLI_VERSION=1.1.0
WORKDIR /root
RUN git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli.git && cd ngx_brotli
RUN wget -qO - https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar zxvf -
COPY debian nginx-${NGINX_VERSION}/debian
RUN sed -i "s/bullseye; urgency/${RELEASE}; urgency/g" nginx-${NGINX_VERSION}/debian/changelog
RUN sed -i "s/~bullseye)/~${RELEASE})/g" nginx-${NGINX_VERSION}/debian/changelog
RUN sed -i "s/{NGINX_VERSION}/${NGINX_VERSION}-${NGINX_DEB_RELEASE}~${RELEASE}/g" nginx-${NGINX_VERSION}/debian/control
RUN cd nginx-${NGINX_VERSION} && dpkg-buildpackage
RUN mkdir /src && mv libnginx-mod-brotli* /src/ && cp nginx-${NGINX_VERSION}/debian/changelog /src/
RUN dpkg -c /src/libnginx-mod-brotli_*.deb
RUN curl -L https://nginx.org/keys/nginx_signing.key | apt-key add -
RUN echo "deb https://nginx.org/packages/${DISTRIB}/ ${RELEASE} nginx" >> /etc/apt/sources.list.d/nginx.list
RUN apt-get update && apt-get -V --no-install-recommends --no-install-suggests -y install nginx=${NGINX_VERSION}-${NGINX_DEB_RELEASE}~${RELEASE}
RUN dpkg -i /src/libnginx-mod-brotli_*.deb && \
sed -i '1iload_module modules/ngx_http_brotli_filter_module.so;' /etc/nginx/nginx.conf && \
sed -i '1 abrotli on;' /etc/nginx/conf.d/default.conf && \
nginx -t && /etc/init.d/nginx start && echo "Testing NGiNX headers for Brotli presence : " && \
curl -s -I -H 'Accept-Encoding: br,gzip,deflate' http://localhost/ |grep 'Content-Encoding: br'
RUN dpkg -r libnginx-mod-brotli
RUN dpkg -P libnginx-mod-brotli