From 7b583d816bdd6b5e60a995ac257167a2a71e4573 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Tue, 11 Jan 2022 11:01:29 +1000 Subject: [PATCH] Adds better support for acme.sh install out of the box --- docker/Dockerfile.acmesh | 17 ++++++++++++++--- files/acme.sh-wrapper | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 files/acme.sh-wrapper diff --git a/docker/Dockerfile.acmesh b/docker/Dockerfile.acmesh index 51776f2..d52a4dd 100644 --- a/docker/Dockerfile.acmesh +++ b/docker/Dockerfile.acmesh @@ -9,8 +9,19 @@ ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt COPY ./files/.bashrc.acmesh /root/.bashrc # acme.sh -RUN mkdir -p /data/acme.sh \ - && curl -o /bin/acme.sh 'https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh' \ - && chmod +x /bin/acme.sh +RUN curl -o /tmp/acme.sh 'https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh' \ + && chmod +x /tmp/acme.sh + +ENV ACMESH_CONFIG_HOME=/data/.acme.sh/config \ + ACMESH_HOME=/data/.acme.sh \ + CERT_HOME=/data/.acme.sh/certs \ + LE_CONFIG_HOME=/data/.acme.sh/config \ + LE_WORKING_DIR=/data/.acme.sh + +# this wrapper handles all the setup required for acme.sh and running commands for it +COPY ./files/acme.sh-wrapper /bin/acme.sh + +# Test that the wrapper script is working +RUN /bin/acme.sh -h LABEL org.label-schema.cmd="docker run --rm -ti nginxproxymanager/nginx-full:acmesh" diff --git a/files/acme.sh-wrapper b/files/acme.sh-wrapper new file mode 100755 index 0000000..3c4b58a --- /dev/null +++ b/files/acme.sh-wrapper @@ -0,0 +1,15 @@ +#!/bin/bash -e + +# Ensure acme.sh dirs exist +mkdir -p "$ACMESH_HOME" "$ACMESH_CONFIG_HOME" "$CERT_HOME" "$LE_CONFIG_HOME" "$LE_WORKING_DIR" + +ACMESH_SCRIPT=/data/.acme.sh/acme.sh + +# Check for existence of $ACME_SH_SCRIPT +if ! [ -f "$ACMESH_SCRIPT" ]; then + echo "$ACMESH_SCRIPT does not exist, installing acme.sh ..." + cd /tmp + ./acme.sh --install --force --home "$ACMESH_HOME" --cert-home "$CERT_HOME" --config-home "$ACMESH_CONFIG_HOME" +fi + +$ACMESH_SCRIPT --config-home "$ACMESH_CONFIG_HOME" "$@"