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

Official docker image #83

Open
MrTomRod opened this issue May 19, 2021 · 2 comments
Open

Official docker image #83

MrTomRod opened this issue May 19, 2021 · 2 comments

Comments

@MrTomRod
Copy link

MrTomRod commented May 19, 2021

Hi!

I would like to use your mod, but I could not find a (current) docker image for it.

Would it be possible for you to provide an official docker image and update it somewhat regularly?

I would have used the current official nginx dockerfile as a template, but they don't actually compile nginx, they just download the latest package from the repo.

Instead, the dockerfile would have to be based on Compiling and Installing from Source, I guess...

Or on of the old mod_zip dockerfiles.

Best, MrTomRod

@ombr
Copy link

ombr commented Jun 14, 2021

Hi @MrTomRod,

I've found this: https://gist.github.com/muuvmuuv/f1a0e7b6a6a02c2253dc92350eab7607

and used it to create this docker file:

FROM debian:stable AS builder

ARG version='1.21.0'
ARG modules_dir="/nginx_modules/"
ARG build_dir="/usr/share/tmp"

# Setup
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
  ca-certificates \
  wget \
  git \
  build-essential \
  libpcre3-dev \
  zlib1g-dev \
  libzstd-dev
RUN mkdir -p ${build_dir}
RUN mkdir -p ${modules_dir}

# Download NGINX
RUN cd ${build_dir} \
  && wget https://nginx.org/download/nginx-${version}.tar.gz \
  && tar zxf nginx-${version}.tar.gz \
  && rm nginx-${version}.tar.gz

# Download Modules
RUN cd ${build_dir} \
  && git clone --recursive https://github.com/evanmiller/mod_zip mod_zip

# Install modules
RUN cd ${build_dir}/nginx-${version} \
  && ./configure --with-compat \
  --add-dynamic-module=../mod_zip \
  && make && make install

# Move compiled modules
RUN ls ${build_dir}/nginx-${version}/objs
RUN cd ${build_dir}/nginx-${version}/objs \
  && cp ngx_http_zip_module.so ${modules_dir} \
  && chmod -R 644 ${modules_dir}

FROM nginx:1.21.0
ARG modules_dir="/nginx_modules/"
COPY --from=builder ${modules_dir}/ngx_http_zip_module.so ${modules_dir}/

I think it does what you want, but it would be great to have a official image for this.

Thanks.

Luc

@serut
Copy link

serut commented Feb 3, 2022

Small changes as it failed to build on my side (and I use nginxinc/nginx-unprivileged):

FROM debian:stable AS builder

ARG version='1.21.6'
ARG build_dir="/usr/share/tmp"
ARG nginx_module_dir="/usr/local/nginx/modules/"

# Setup
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
  ca-certificates \
  wget \
  git \
  build-essential \
  libpcre3-dev \
  zlib1g-dev \
  libzstd-dev
RUN mkdir -p ${build_dir}

# Download NGINX
RUN cd ${build_dir} \
  && wget https://nginx.org/download/nginx-${version}.tar.gz \
  && tar zxf nginx-${version}.tar.gz \
  && rm nginx-${version}.tar.gz

# Download Modules
RUN cd ${build_dir} \
  && git clone --recursive https://github.com/evanmiller/mod_zip mod_zip

# Install modules
RUN cd ${build_dir}/nginx-${version} \
  && ./configure --with-compat \
  --add-dynamic-module=../mod_zip \
  && make && make install

# Move compiled modules
RUN chmod -R 644 ${nginx_module_dir}

FROM nginxinc/nginx-unprivileged:1.21.6
ARG nginx_module_dir="/usr/local/nginx/modules/"
COPY --from=builder ${nginx_module_dir}/ngx_http_zip_module.so /etc/nginx/modules/

USER root

RUN chmod 0777 /var/cache/nginx/

USER 101

d-c file :

version: "3.7"
services:
  nginx-zip:
    image: "nginx-nginx"
    hostname: nginx-zip
    user: "3050:1050"
    read_only: true
    build:
      context: ..
    ports:
        - "8080:80"
    volumes: 
        - "./www:/var/www/html:ro"
        - "./nginx.conf:/etc/nginx/nginx.conf:ro"
        - type: tmpfs
          target: /var/cache/nginx/
        - type: tmpfs
          target: /tmp

And inside nginx.conf : load_module "modules/ngx_http_zip_module.so";

Is that possible to do it on Alpine ?

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

3 participants