Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx docker alpine image #89

Closed
WangHansen opened this issue Nov 28, 2019 · 8 comments
Closed

Nginx docker alpine image #89

WangHansen opened this issue Nov 28, 2019 · 8 comments

Comments

@WangHansen
Copy link

Hi, thanks for all the hard work, I was wondering what is the proper way to include this module within official the Nginx:apline image. I searched online but couldn't find anything, mostly just talk about how to use it on a local linux system. An official example would be really appreciated!
Here is my Dockerfile:

FROM nginx:alpine
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/nginx/nginx.conf **/etc/nginx/**
CMD ["nginx", "-g", "daemon off;"]
@dptole
Copy link

dptole commented Nov 29, 2019

@WangHansen
Copy link
Author

@dptole Thanks for the response, I saw it early, but this one starts from the Alpine image instead of the Nginx alpine which is not really compatible with what I wanted.

@dptole
Copy link

dptole commented Nov 29, 2019

@WangHansen oh, so we are basically trying to do the same thing from different places lol. I already have a running container and wanted to install the module on it. Sorry I couldn't help :/

@dptole
Copy link

dptole commented Nov 29, 2019

@WangHansen well, the only solutions I find gives essentially the same instructions as the Dockerfile I sent you: Install the brotli module together with the binaries for nginx

I'm gonna give up. Good luck for you, I'll keep subscribed for updates on this issue

@WangHansen
Copy link
Author

@dptole I really appreciate the help, this is awesome, thanks again!

@eustas
Copy link
Collaborator

eustas commented Mar 11, 2020

Hi. Not sure about Alpine, here is how I tested brotli module in Busty Nginx Docker image:

docker run -it -p 8443:8443 -v `pwd`:/home/ngx_brotli nginx:perl /bin/bash

# Now we are inside container.

apt-get update
apt-get install gcc git libpcre3-dev libssl-dev make zlib1g-dev -y

cd /home
git clone https://github.com/google/ngx_brotli.git --recurse-submodules
git clone https://github.com/nginx/nginx.git

cd /home/nginx
git checkout release-1.17.8
./auto/configure \
  --add-dynamic-module=/home/ngx_brotli \
  --with-debug \
  --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.17.8/debian/debuild-base/nginx-1.17.8=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
make modules

# Never used Docker as it was meant to. Basically, you need to export this file and
# add it to clean docker container. 
cp objs/ngx_http_brotli_filter_module.so /usr/lib/nginx/modules/

In a Docker container with a module library you just have to add a line to conf file: load_module modules/ngx_http_brotli_filter_module.so;

@eustas eustas closed this as completed Mar 11, 2020
@paskal
Copy link

paskal commented Jan 18, 2021

@eustas thanks a lot for your message! Here is working Dockerfile based on it:

# Build
FROM nginx:1.19.6 as build

WORKDIR /build

# install brotli build dependencies
RUN \
    apt-get update > /dev/null \
    && apt-get install gcc git libpcre3-dev libssl-dev make zlib1g-dev -y

# build brotli
RUN git clone https://github.com/google/ngx_brotli.git --recurse-submodules
RUN git clone https://github.com/nginx/nginx.git

WORKDIR /build/nginx

RUN git checkout release-1.19.6
RUN ./auto/configure \
  --add-dynamic-module=/build/ngx_brotli \
  --with-debug \
  --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.19.6/debian/debuild-base/nginx-1.19.6=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
RUN make modules

# Run
FROM nginx:1.19.6

# add compiled brotli module
COPY --from=build /build/nginx/objs/ngx_http_brotli_filter_module.so /usr/lib/nginx/modules/
COPY --from=build /build/nginx/objs/ngx_http_brotli_static_module.so /usr/lib/nginx/modules/

# run nginx with configuration reload once in every 6 hours
CMD /bin/sh -c 'while :; do /bin/sleep 6h & wait ${!}; /usr/sbin/nginx -s reload; done & /usr/sbin/nginx -g "daemon off;"'

@georg-jung
Copy link

I put something very similar together and published it on docker hub. It is built as recommended on the official docker-nginx repo. It is also auto-updating daily without any human input required. You can find it here if that might be helpful: https://hub.docker.com/r/georgjung/nginx-brotli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants