diff --git a/Dockerfile b/Dockerfile index 077acd8..8863e6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,12 @@ FROM jcgruenhage/baseimage-alpine MAINTAINER Jan Christian Grünhage ENV UID=192 \ - GID=192 + GID=192 \ + STAGING=1 \ + CHALLENGE="dns-01" + +# Set STAGING to false(0) by default, set to true(1) to use staging LE-Endpoint +# Set CHALLENGE to "dns-01" (DNS Challenge) by default, set to "http-01" to use the HTTP Challenge RUN apk update \ && apk add --upgrade \ @@ -14,12 +19,14 @@ RUN apk update \ bash \ su-exec \ libxml2-utils \ - && git clone https://github.com/lukas2511/dehydrated /dehydrated + && git clone https://github.com/lukas2511/dehydrated /dehydrated +# Add the files in the 'root' folder to the images filesystem ADD root / - VOLUME /etc/dehydrated VOLUME /var/www/dehydrated VOLUME /certs +# Execute the setup script +RUN bash /etc/once/setup.sh diff --git a/root/etc/once/setup.sh b/root/etc/once/setup.sh new file mode 100644 index 0000000..f17af00 --- /dev/null +++ b/root/etc/once/setup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Copy the example config file to the config location +cp /dehydrated/docs/examples/config /etc/dehydrated/config + +# Use the staging endpoint? +if [ $STAGING -ne 0 ]; then + sed -ie 's/#CA=.*$/CA="https:\/\/acme-staging.api.letsencrypt.org\/directory"/g' /etc/dehydrated/config + sed -ie 's/#CA_TERMS=.*$/CA_TERMS="https:\/\/acme-staging.api.letsencrypt.org\/terms"/g' /etc/dehydrated/config +fi + +# Set the challenge-type +case "$CHALLENGE" in + "http-01") + sed -ie 's/#CHALLENGETYPE=.*$/CHALLENGETYPE="http-01"/g' /etc/dehydrated/config + ;; + "dns-01") + sed -ie 's/#CHALLENGETYPE=.*$/CHALLENGETYPE="dns-01"/g' /etc/dehydrated/config + ;; + *) + echo "WARNING: Unknown Challenge type! Using default from dehydrated" + ;; +esac