Files
ssl-nginx/certbot/Dockerfile
kanootoko 16bc1c0db7 update 2024-04-22
Changes:
- add jinja2 template engine instead of string-replacing
- fix certbot cron usage
- replace json servers configuration with yaml
2024-04-22 21:53:47 +03:00

32 lines
1.3 KiB
Docker

# Uses /ssl volume to store certificates and read domains.txt on run_once
# Uses /etc/letsencrypt volume to store letsencrypt data
FROM alpine
ARG EMAIL
RUN apk add certbot bash
RUN mkdir -p /etc/letsencrypt /etc/letsencrypt.bak /ssl/.well-known && \
\
echo "webroot-path = /ssl/" > /etc/letsencrypt.bak/cli.ini && \
\
echo '15 2 */7 * * /run_once' > /etc/crontabs/root && \
\
echo "echo 'running with cron'" > /run_with_cron && \
echo "cp /etc/letsencrypt.bak/cli.ini /etc/letsencrypt/cli.ini" >> /run_with_cron && \
echo "crond -f" >> /run_with_cron && \
\
echo "echo 'running once'" > /run_once && \
echo "mv /etc/letsencrypt.bak/cli.ini /etc/letsencrypt/cli.ini" >> /run_once && \
echo "if [ ! -f /ssl/domains.txt ]; then echo 'No domains.txt file found in /ssl, exiting' && exit 1; fi" >> /run_once && \
echo 'for domain in $(cat /ssl/domains.txt); do case $domain in "#"*) :; ;; *) certbot certonly -n --authenticator webroot -d $domain; ;; esac; done' >> /run_once && \
echo "cp -rL /etc/letsencrypt/live/* /ssl/" >> /run_once && \
chmod +x /run_once
RUN certbot register --email $EMAIL --non-interactive --agree-tos
RUN cp -r /etc/letsencrypt /etc/letsencrypt.bak
ENTRYPOINT ["/bin/sh"]
CMD ["/run_with_cron"]