Skip to content

Commit 20093a1

Browse files
committed
Merge pull request nginx-proxy#52 from thaJeztah/optimize-dockerfile
Optimize Dockerfile.
2 parents 1a03ac3 + d68be71 commit 20093a1

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
README.md

Dockerfile

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@ FROM ubuntu:14.04
22
MAINTAINER Jason Wilder [email protected]
33

44
# Install Nginx.
5-
RUN echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu trusty main" > /etc/apt/sources.list.d/nginx-stable-trusty.list
6-
RUN echo "deb-src http://ppa.launchpad.net/nginx/stable/ubuntu trusty main" >> /etc/apt/sources.list.d/nginx-stable-trusty.list
7-
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
8-
RUN apt-get update
9-
RUN apt-get install --only-upgrade bash
10-
RUN apt-get install -y wget nginx
5+
RUN echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu trusty main" > /etc/apt/sources.list.d/nginx-stable-trusty.list \
6+
&& echo "deb-src http://ppa.launchpad.net/nginx/stable/ubuntu trusty main" >> /etc/apt/sources.list.d/nginx-stable-trusty.list \
7+
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C \
8+
&& apt-get update \
9+
&& apt-get install -y -q --no-install-recommends \
10+
ca-certificates \
11+
nginx \
12+
wget \
13+
&& apt-get clean \
14+
&& rm -r /var/lib/apt/lists/*
15+
16+
# Configure Nginx and apply fix for long server names
17+
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
18+
&& sed -i 's/# server_names_hash_bucket/server_names_hash_bucket/g' /etc/nginx/nginx.conf
19+
20+
# Install Forego
21+
RUN wget -P /usr/local/bin https://godist.herokuapp.com/projects/ddollar/forego/releases/current/linux-amd64/forego \
22+
&& chmod u+x /usr/local/bin/forego
1123

12-
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
13-
14-
#fix for long server names
15-
RUN sed -i 's/# server_names_hash_bucket/server_names_hash_bucket/g' /etc/nginx/nginx.conf
24+
ENV DOCKER_GEN_VERSION 0.3.4
1625

17-
RUN wget -P /usr/local/bin https://godist.herokuapp.com/projects/ddollar/forego/releases/current/linux-amd64/forego
18-
RUN chmod u+x /usr/local/bin/forego
26+
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
27+
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
28+
&& rm /docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
1929

20-
ENV DOCKER_GEN_VERSION 0.3.4
21-
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
22-
RUN tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
30+
COPY . /app/
31+
WORKDIR /app/
2332

24-
RUN mkdir /app
25-
WORKDIR /app
26-
ADD . /app
2733

2834
EXPOSE 80
2935
ENV DOCKER_HOST unix:///tmp/docker.sock

0 commit comments

Comments
 (0)