Skip to content

Instantly share code, notes, and snippets.

@rhrn
Created May 11, 2018 12:56
Show Gist options
  • Save rhrn/974df2dc8d49b3ec2c262998b1105f31 to your computer and use it in GitHub Desktop.
Save rhrn/974df2dc8d49b3ec2c262998b1105f31 to your computer and use it in GitHub Desktop.
## Setup
STACK=my
WEBROOT=${STACK}_letsencrypt_webroot_data:/etc/letsencrypt_webroot
DATA=${STACK}_letsencrypt_data:/etc/letsencrypt
SERVICE=${STACK}_nginx-front
## Request renew
docker run --rm -v $WEBROOT -v $DATA certbot/certbot renew
## Update all certificates in nginx service or you can use grep `$(ls /etc/letsencrypt/live/ | grep some-domain)`
for i in $(ls /etc/letsencrypt/live/); do ### grep for filter
docker service update $SERVICE --secret-rm $i.cert --secret-rm $i.privkey --secret-rm $i.chain --secret-rm $i.fullchain
docker secret rm $i.cert $i.privkey $i.chain $i.fullchain
for a in cert privkey chain fullchain; do docker secret create $i.$a /etc/letsencrypt/live/$i/$a.pem; done;
docker service update $SERVICE --secret-add $i.cert --secret-add $i.privkey --secret-add $i.chain --secret-add $i.fullchain
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment