diff --git a/.dockerignore b/.dockerignore index 8fafbb0..ded9598 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,8 @@ .git .dockerignore circle.yml +Dockerfile +LICENSE Makefile README.md test diff --git a/Dockerfile b/Dockerfile index de9c7f0..b4c1c2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 ", "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 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..194e16f --- /dev/null +++ b/build.sh @@ -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/* diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100755 index 6353314..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -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 "$@" diff --git a/letsencrypt_service b/letsencrypt_service index b0f240b..f02339a 100755 --- a/letsencrypt_service +++ b/letsencrypt_service @@ -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}" \