AYapejian
8/6/2016 - 8:51 PM

Alpine Nginx - From Source

Alpine Nginx - From Source

FROM alpine:3.3
MAINTAINER Luke Flynn <luke@lukehflynn.com>

ENV apk_list="autoconf wget ca-certificates pcre zlib zip tar openssl-dev pcre-dev zlib-dev build-base git patch bash gperf python linux-headers gcc"

RUN apk add --no-cache ${apk_list}

WORKDIR /tmp

# Download Nginx and Nginx modules source
RUN mkdir -p /usr/local/src/nginx && \
    wget http://nginx.org/download/nginx-1.10.1.tar.gz -O nginx.tar.gz && \
    tar -xzvf nginx.tar.gz -C /usr/local/src/nginx

# Build Nginx
WORKDIR /usr/local/src/nginx/nginx-1.10.1
RUN ./configure \
        --prefix=/usr/share/nginx \
        --sbin-path=/usr/sbin/nginx \
        --conf-path=/etc/nginx/nginx.conf \
        --pid-path=/run/nginx.pid \
        --lock-path=/run/lock/subsys/nginx \
        --error-log-path=/var/log/nginx/error.log \
        --http-log-path=/var/log/nginx/access.log \
        --with-http_gzip_static_module \
        --with-http_stub_status_module \
        --with-http_ssl_module \
        --with-pcre \
        --with-ipv6 \
        --with-http_dav_module \
        --with-http_v2_module \
        --with-http_gunzip_module && \
    make && \
    make install

WORKDIR /usr/local/src/nginx

RUN touch /run/nginx.pid

RUN rm -rf /etc/nginx/nginx.conf

RUN mkdir /var/pagespeed_cache

ADD ./nginx.conf /etc/nginx/nginx.conf
# Cleanup after Nginx build
#RUN apk del ${apk_list}

# PORTS
EXPOSE 80 443

ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]