Skip to content

Commit 5d4df92

Browse files
committed
Adds ngx_brotli module
1 parent 78572cc commit 5d4df92

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

docker/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ARG LUAROCKS_VERSION
1111
RUN apt-get update \
1212
&& apt-get install -y \
1313
build-essential \
14+
cmake \
1415
ca-certificates \
1516
libncurses-dev \
1617
libpcre3-dev \
@@ -22,6 +23,10 @@ RUN apt-get update \
2223
git \
2324
libmaxminddb-dev
2425

26+
# brotli build
27+
COPY ./scripts/build-brotli /tmp/build-brotli
28+
RUN /tmp/build-brotli
29+
2530
# Lua build
2631
COPY ./scripts/build-lua /tmp/build-lua
2732
RUN /tmp/build-lua
@@ -70,6 +75,7 @@ COPY ./files/.bashrc /root/.bashrc
7075

7176
# Copy lua and luarocks builds from first image
7277
COPY --from=nginxbuilder /tmp/lua /tmp/lua
78+
COPY --from=nginxbuilder /tmp/ngx_brotli /tmp/ngx_brotli
7379
COPY --from=nginxbuilder /tmp/luarocks /tmp/luarocks
7480
COPY ./scripts/install-lua /tmp/install-lua
7581

scripts/build-brotli

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash -e
2+
3+
BLUE='\E[1;34m'
4+
CYAN='\E[1;36m'
5+
YELLOW='\E[1;33m'
6+
GREEN='\E[1;32m'
7+
RESET='\E[0m'
8+
9+
echo -e "${BLUE}${CYAN}Building brotli ${YELLOW}${LUA_VERSION}...${RESET}"
10+
11+
cd /tmp
12+
git clone --recurse-submodules -j8 "https://github.com/google/ngx_brotli"
13+
cd /tmp/ngx_brotli/deps/brotli
14+
15+
mkdir -p /tmp/ngx_brotli/deps/brotli/out
16+
cd /tmp/ngx_brotli/deps/brotli/out
17+
18+
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed ..
19+
cmake --build . --config Release --target brotlienc
20+
21+
echo -e "${BLUE}${GREEN}brotli build completed${RESET}"

scripts/build-openresty

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cd /tmp
1212
wget "https://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz"
1313
tar -xzf openresty-${OPENRESTY_VERSION}.tar.gz
1414
mv /tmp/openresty-${OPENRESTY_VERSION} /tmp/openresty
15+
1516
git clone https://github.com/leev/ngx_http_geoip2_module.git
1617
mv /tmp/ngx_http_geoip2_module /tmp/openresty/ngx_http_geoip2_module
1718
cd /tmp/openresty
@@ -55,7 +56,8 @@ cd /tmp/openresty
5556
--with-stream_realip_module \
5657
--with-stream_ssl_module \
5758
--with-stream_ssl_preread_module \
58-
--add-dynamic-module=/tmp/openresty/ngx_http_geoip2_module
59+
--add-dynamic-module=/tmp/openresty/ngx_http_geoip2_module \
60+
--add-module=/tmp/ngx_brotli
5961

6062
make -j2
6163

0 commit comments

Comments
 (0)