initial commit: add dockerfile
This commit is contained in:
commit
ffa7ecb115
2 changed files with 44 additions and 0 deletions
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache nginx python3 py3-virtualenv
|
||||||
|
|
||||||
|
RUN python3 -m venv /venv
|
||||||
|
RUN /venv/bin/pip install -U pip certbot certbot-nginx
|
||||||
|
|
||||||
|
RUN apk del py3-virtualenv && rm -rf /var/cache/apk
|
||||||
|
|
||||||
|
COPY ./entrypoint.sh /
|
||||||
|
CMD ["/entrypoint.sh"]
|
33
entrypoint.sh
Normal file
33
entrypoint.sh
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/ash
|
||||||
|
|
||||||
|
if [ ! -e /etc/letsencrypt ]
|
||||||
|
then
|
||||||
|
echo "[!!] Certbot directory is not initialized"
|
||||||
|
echo "[!!] Either it's the first run or you forgot to add a volume"
|
||||||
|
|
||||||
|
# check if stdin (fd 0) is assigned to a tty
|
||||||
|
[ ! -t 0 ] && echo "Not a TTY! Exiting" && exit 1
|
||||||
|
|
||||||
|
/venv/bin/certbot certonly --nginx
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
/usr/sbin/nginx -c /etc/nginx/nginx.conf &
|
||||||
|
ngpid=$!
|
||||||
|
waitpid=""
|
||||||
|
|
||||||
|
ctrlc () {
|
||||||
|
kill -QUIT "$ngpid"
|
||||||
|
[ -n "$waitpid" ] && kill -INT "$waitpid"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap ctrlc INT
|
||||||
|
trap ctrlc TERM
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
/venv/bin/certbot renew --post-hook "kill -HUP $ngpid"
|
||||||
|
sleep 12h &
|
||||||
|
waitpid=$!
|
||||||
|
wait
|
||||||
|
done
|
Loading…
Add table
Reference in a new issue