Break into build stages - Saves 10MB in space

This commit is contained in:
Dan Schaper 2017-05-27 17:35:53 -07:00
parent 23a2c7d848
commit ab4b993644
No known key found for this signature in database
GPG key ID: 572E999E385B7BFC

View file

@ -1,25 +1,36 @@
FROM nginx:1.13.0-alpine
MAINTAINER Jason Wilder mail@jasonwilder.com
# Build stages
FROM alpine:3.5 AS build-env
ENV DOCKER_GEN_VERSION 0.7.3
# Install wget and install/updates certificates
RUN apk add --no-cache --virtual .run-deps \
ca-certificates bash wget \
RUN apk add --no-cache --virtual .build-deps \
ca-certificates wget \
&& update-ca-certificates
# Configure Nginx and apply fix for very long server names
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
&& sed -i 's/^http {/&\n server_names_hash_bucket_size 128;/g' /etc/nginx/nginx.conf
# Install Forego
ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego
RUN chmod u+x /usr/local/bin/forego
ENV DOCKER_GEN_VERSION 0.7.3
# Clone and install Docker-gen
RUN wget --quiet https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
&& tar -C /usr/local/bin -xvzf docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
&& rm /docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
# Final Stage
FROM nginx:1.13.0-alpine
MAINTAINER Jason Wilder mail@jasonwilder.com
# Configure Nginx and apply fix for very long server names
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
&& sed -i 's/^http {/&\n server_names_hash_bucket_size 128;/g' /etc/nginx/nginx.conf
# Install bash
RUN apk add --no-cache --virtual .run-deps \
bash
COPY --from=build-env /usr/local/bin/forego /usr/local/bin
COPY --from=build-env /usr/local/bin/docker-gen /usr/local/bin
COPY . /app/
WORKDIR /app/