Created
February 21, 2018 17:01
-
-
Save proxium/5398ad1327c07208e0974d41ae57a9ea to your computer and use it in GitHub Desktop.
Dockerfile for nginx compiled from source on debian jessie image with lua-nginx-module and echo-nginx-module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM buildpack-deps:jessie | |
RUN curl -L -o /tmp/nginx_signing.key http://nginx.org/keys/nginx_signing.key && \ | |
apt-key add /tmp/nginx_signing.key && \ | |
echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list && \ | |
echo "deb-src http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list | |
# lua-nginx-module only supports nginx <=1.11.2 | |
ENV NGINX_VERSION 1.11.2 | |
ENV NGINX_FULL_VERSION ${NGINX_VERSION}-1~jessie | |
ENV ECHO_VERSION 0.61 | |
ENV LUA_VERSION 0.10.10 | |
RUN mkdir -p /usr/src/nginx | |
WORKDIR /usr/src/nginx | |
# Download nginx source | |
RUN apt-get update && \ | |
apt-get install -y libluajit-5.1-dev && \ | |
apt-get source nginx=${NGINX_FULL_VERSION} && \ | |
apt-get build-dep -y nginx=${NGINX_FULL_VERSION} && \ | |
rm -rf /var/lib/apt/lists/* | |
WORKDIR /usr/src/nginx/nginx-${NGINX_VERSION}/debian/modules/ | |
# Download ECHO module | |
RUN curl -L https://github.com/openresty/echo-nginx-module/archive/v${ECHO_VERSION}.tar.gz | tar xz && \ | |
ln -s echo-nginx-module-${ECHO_VERSION} nginx-echo-module | |
# Download LUA module | |
RUN curl -L https://github.com/openresty/lua-nginx-module/archive/v${LUA_VERSION}.tar.gz | tar xz && \ | |
ln -s lua-nginx-module-${LUA_VERSION} lua-nginx-module | |
# Add modules to build nginx debian rules | |
ENV ECHO_MODULE_SOURCE "\\\/usr\\\/src\\\/nginx\\\/nginx-${NGINX_VERSION}\\\/debian\\\/modules\\\/nginx-echo-module" | |
ENV LUA_MODULE_SOURCE "\\\/usr\\\/src\\\/nginx\\\/nginx-${NGINX_VERSION}\\\/debian\\\/modules\\\/lua-nginx-module" | |
RUN sed -i "s#--with-ipv6#--with-ipv6 --add-module=${ECHO_MODULE_SOURCE} --add-module=${LUA_MODULE_SOURCE}#g" /usr/src/nginx/nginx-${NGINX_VERSION}/debian/rules | |
# Build nginx debian package | |
WORKDIR /usr/src/nginx/nginx-${NGINX_VERSION} | |
RUN dpkg-buildpackage -b | |
# Install nginx | |
WORKDIR /usr/src/nginx | |
RUN dpkg -i nginx_${NGINX_FULL_VERSION}_amd64.deb | |
# Make snakeoil certificates available | |
RUN apt-get update && \ | |
apt-get install -qy ssl-cert && \ | |
apt-get autoremove -yqq && \ | |
apt-get clean -yqq && \ | |
rm -rf /usr/src/nginx | |
# Forward request and error logs to docker log collector | |
RUN ln -sf /dev/stdout /var/log/nginx/access.log | |
RUN ln -sf /dev/stderr /var/log/nginx/error.log | |
WORKDIR /etc/nginx | |
EXPOSE 80 443 | |
CMD ["nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment