diff --git a/docker/Dockerfile b/docker/Dockerfile index 882d97e..0bf64a6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,6 +11,7 @@ ARG LUAROCKS_VERSION RUN apt-get update \ && apt-get install -y \ build-essential \ + cmake \ ca-certificates \ libncurses-dev \ libpcre3-dev \ @@ -22,6 +23,10 @@ RUN apt-get update \ git \ libmaxminddb-dev +# brotli build +COPY ./scripts/build-brotli /tmp/build-brotli +RUN /tmp/build-brotli + # Lua build COPY ./scripts/build-lua /tmp/build-lua RUN /tmp/build-lua @@ -70,6 +75,7 @@ COPY ./files/.bashrc /root/.bashrc # Copy lua and luarocks builds from first image COPY --from=nginxbuilder /tmp/lua /tmp/lua +COPY --from=nginxbuilder /tmp/ngx_brotli /tmp/ngx_brotli COPY --from=nginxbuilder /tmp/luarocks /tmp/luarocks COPY ./scripts/install-lua /tmp/install-lua diff --git a/scripts/build-brotli b/scripts/build-brotli new file mode 100755 index 0000000..86be383 --- /dev/null +++ b/scripts/build-brotli @@ -0,0 +1,21 @@ +#!/bin/bash -e + +BLUE='\E[1;34m' +CYAN='\E[1;36m' +YELLOW='\E[1;33m' +GREEN='\E[1;32m' +RESET='\E[0m' + +echo -e "${BLUE}❯ ${CYAN}Building brotli ${YELLOW}${LUA_VERSION}...${RESET}" + +cd /tmp +git clone --recurse-submodules -j8 "https://github.com/google/ngx_brotli" +cd /tmp/ngx_brotli/deps/brotli + +mkdir -p /tmp/ngx_brotli/deps/brotli/out +cd /tmp/ngx_brotli/deps/brotli/out + +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 .. +cmake --build . --config Release --target brotlienc + +echo -e "${BLUE}❯ ${GREEN}brotli build completed${RESET}" diff --git a/scripts/build-openresty b/scripts/build-openresty index 9f3a1bb..8b309ff 100755 --- a/scripts/build-openresty +++ b/scripts/build-openresty @@ -12,6 +12,7 @@ cd /tmp wget "https://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz" tar -xzf openresty-${OPENRESTY_VERSION}.tar.gz mv /tmp/openresty-${OPENRESTY_VERSION} /tmp/openresty + git clone https://github.com/leev/ngx_http_geoip2_module.git mv /tmp/ngx_http_geoip2_module /tmp/openresty/ngx_http_geoip2_module cd /tmp/openresty @@ -55,7 +56,8 @@ cd /tmp/openresty --with-stream_realip_module \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ - --add-dynamic-module=/tmp/openresty/ngx_http_geoip2_module + --add-dynamic-module=/tmp/openresty/ngx_http_geoip2_module \ + --add-module=/tmp/ngx_brotli make -j2