Giter VIP home page Giter VIP logo

Comments (5)

neomantra avatar neomantra commented on September 25, 2024

I see what you are saying. Besides the http section, the main stanza is currently:

pcre_jit on;
events {
    worker_connections  1024;
}

You would like to inject some other text there, like a load_module line. We do let you alter the build process with Docker build arguments, like RESTY_EVAL_POST_MAKE. So you could use that arg to do something like:

docker build --build-arg RESTY_EVAL_POST_MAKE="echo 'load_module /etc/nginx/ngx_http_brotli_filter_module.so; load_module /etc/nginx/ngx_http_brotli_static_module.so;' >> /usr/local/openresty/nginx/conf/nginx.conf" -f focal/Dockerfile .

I didn't actually test that, but it's the idea.


You can also bind-mount your own nginx.conf to /usr/local/openresty/nginx/conf/nginx.conf. You are also bind-mounting the shared-objects or building it in a derived image?

from docker-openresty.

mpv945 avatar mpv945 commented on September 25, 2024

Can docker-openresty support brotli compression?

from docker-openresty.

neomantra avatar neomantra commented on September 25, 2024

I see the module ngx_brotli. Is there any reason this isn't already in Nginx or OpenResty already? I generally don't add modules, but maybe we can add it to the -fat images?

from docker-openresty.

dixyes avatar dixyes commented on September 25, 2024

Offical docker image of PHP provides ENV like "PHPIZE_DEPS" and configured php sources, this make user build modules after base built possible:

  1. base image provides ENV like configure arguments, build deps
  2. base image provides configured sources and tar it, save it to /usr/src
  3. when use FROM that base image, user can use distro_pm_like_apk add $BUILD_DEPS install build deps, then tar -xf /usr/src/configured.tar.zst -C /usr/src/openresty and cd into it, make their own modules ./configure $CONFIG_THINGS --add-dynamic-module=/path/to/whatever
  4. after that, user can copy modules from that stage or distro_pm_like_apk del $BUILD_DEPS
  5. at last, user install running deps like libbrotlidec for ngx-brotli

from docker-openresty.

dixyes avatar dixyes commented on September 25, 2024

Here's my demo Dockerfile for that

Since we donot have DEPS and CONFIG env, so this is rather fragile:

FROM openresty/openresty:1.21.4.1-4-rocky AS module-builder

# DONOT USE THIS IN PRODUCT!

WORKDIR /usr/src

RUN set -xeo pipefail ; \
    dnf install -y git && \
    wget https://openresty.org/download/openresty-1.21.4.1.tar.gz && \
    mkdir openresty && \
    tar --strip-components=1 -xf openresty-1.21.4.1.tar.gz -C openresty && \
    git clone https://github.com/google/ngx_brotli /usr/src/ngx_brotli && \
    git clone https://github.com/tokers/zstd-nginx-module /usr/src/zstd-nginx-module && \
    :

RUN dnf install -yy epel-release && \
    dnf install -yy ccache gcc make brotli-devel libzstd-devel \
        # here we donot know which packages is used in building openresty
        # so we have to dnf search and append "-devel" here
        openresty-openssl111-devel openresty-pcre-devel openresty-zlib-devel

RUN set -xeo pipefail ; \
    cd /usr/src/openresty/bundle/nginx-1.21.4 && \
    # here we cannot get real configure args so we have to use nginx -V
    # futhermore, --add-modules things make configure fail because wo donot have a "configurable" source for them
    RESTY_CONFIG_OPTIONS="$(nginx -V 2>&1 | grep 'configure arguments:' | sed 's/^configure arguments://g' | sed -E 's/--add-module=[^ ]+ //g')" && \
    eval "./configure $RESTY_CONFIG_OPTIONS --add-dynamic-module=/usr/src/ngx_brotli --add-dynamic-module=/usr/src/zstd-nginx-module" && \
    make -j `nproc` modules && \
    :

FROM openresty/openresty:1.21.4.1-4-rocky

RUN dnf install -yy brotli libzstd && \
    dnf clean all

COPY --from=module-builder \
    /usr/src/openresty/bundle/nginx-1.21.4/objs/ngx_http_brotli_filter_module.so \
    /usr/src/openresty/bundle/nginx-1.21.4/objs/ngx_http_brotli_static_module.so \
    /usr/src/openresty/bundle/nginx-1.21.4/objs/ngx_http_zstd_filter_module.so \
    /usr/src/openresty/bundle/nginx-1.21.4/objs/ngx_http_zstd_static_module.so \
    /usr/local/openresty/nginx/modules/

from docker-openresty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.