Add support for environment variables which control wether to use staging or not and which type of challenge is used

This commit is contained in:
jreichmann 2017-11-30 21:48:31 +01:00
parent adadb253ab
commit 6b5c016334
2 changed files with 33 additions and 3 deletions

View file

@ -2,7 +2,12 @@ FROM jcgruenhage/baseimage-alpine
MAINTAINER Jan Christian Grünhage <jan.christian@gruenhage.xyz>
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

23
root/etc/once/setup.sh Normal file
View file

@ -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