Use jwilder/nginx-proxy as base image and reduce final image size

This commit is contained in:
David Parrish 2015-11-23 00:03:14 -05:00 committed by JrCs
parent 81fc692512
commit a610fb1e39
5 changed files with 34 additions and 63 deletions

View file

@ -1,6 +1,8 @@
.git
.dockerignore
circle.yml
Dockerfile
LICENSE
Makefile
README.md
test

View file

@ -1,44 +1,7 @@
FROM nginx:1.9.6
MAINTAINER Jason Wilder mail@jasonwilder.com
FROM jwilder/nginx-proxy
# Install wget and install/updates certificates
RUN apt-get update \
&& apt-get install -y -q --no-install-recommends \
ca-certificates \
wget \
git \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*
# Get Let's Encrypt simp_le client source
RUN git -C /opt clone https://github.com/kuba/simp_le.git
# Install simp_le
RUN cd /opt/simp_le && ./bootstrap.sh && ./venv.sh
# Testing directory
RUN mkdir -p /usr/share/nginx/html/.well-known \
&& touch /usr/share/nginx/html/.well-known/testing
# 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
RUN wget -P /usr/local/bin https://godist.herokuapp.com/projects/ddollar/forego/releases/current/linux-amd64/forego \
&& chmod u+x /usr/local/bin/forego
ENV DOCKER_GEN_VERSION 0.4.2
RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
&& tar -C /usr/local/bin -xvzf docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz \
&& rm /docker-gen-linux-amd64-$DOCKER_GEN_VERSION.tar.gz
MAINTAINER [ "Jason Wilder <mail@jasonwilder.com>", "Yves Blusseau <90z7oey02@sneakemail.com>" ]
COPY . /app/
WORKDIR /app/
ENV DOCKER_HOST unix:///tmp/docker.sock
VOLUME ["/etc/nginx/certs"]
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["forego", "start", "-r"]
RUN chmod +rx /app/build.sh && /app/build.sh && rm -f /app/build.sh

28
build.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
set -e
apt-get update
# Install python packages needed by simp_le
apt-get install -y -q --no-install-recommends python python-requests
# Install python packages needed to build simp_le
apt-get install -y -q --no-install-recommends git gcc libssl-dev libffi-dev python-dev python-pip
# Get Let's Encrypt simp_le client source
git -C /opt clone https://github.com/kuba/simp_le.git
cd /opt/simp_le
# Upgrade setuptools
pip install -U setuptools
# Install simp_le in /usr/local/bin
python ./setup.py install
# Make house cleaning
rm -rf /opt/simp_le
apt-get autoremove -y git gcc libssl-dev libffi-dev python-dev python-pip
apt-get clean all
rm -r /var/lib/apt/lists/*

View file

@ -1,22 +0,0 @@
#!/bin/bash
set -e
# Warn if the DOCKER_HOST socket does not exist
if [[ $DOCKER_HOST == unix://* ]]; then
socket_file=${DOCKER_HOST#unix://}
if ! [ -S $socket_file ]; then
cat >&2 <<-EOT
ERROR: you need to share your Docker host socket with a volume at $socket_file
Typically you should run your jwilder/nginx-proxy with: \`-v /var/run/docker.sock:$socket_file:ro\`
See the documentation at http://git.io/vZaGJ
EOT
socketMissing=1
fi
fi
# If the user has run the default command and the socket doesn't exist, fail
if [ "$socketMissing" = 1 -a "$1" = forego -a "$2" = start -a "$3" = '-r' ]; then
exit 1
fi
exec "$@"

View file

@ -23,7 +23,7 @@ update_certs() {
mkdir -p /etc/nginx/certs/$domain
cd /etc/nginx/certs/$domain
/opt/simp_le/venv/bin/simp_le \
/usr/local/bin/simp_le \
-d "$domain" \
-f fullchain.pem -f key.pem \
--email "${!email_varname}" \