Make container use nginx

This commit is contained in:
Nico Schottelius 2021-10-10 16:05:51 +09:00
parent 854790f366
commit 9bc4351c9f
3 changed files with 27 additions and 1 deletions

View file

@ -1,4 +1,4 @@
FROM alpine:3.14
FROM nginx:1.21.3-alpine
RUN apk update
RUN apk add certbot

View file

@ -21,6 +21,8 @@ services**.
certificates, so that non-root users can access the certificates.
Set the LEAVE_PERMISSIONS_AS_IS environment variable to instruct the
container not to change permissions
* If you setup the variable NGINX to any value, the container will
start nginx and reload after trying to renew the certificate
```
docker run -e DOMAIN=example.com \
@ -28,6 +30,21 @@ docker run -e DOMAIN=example.com \
ungleich/ungleich-certbot
```
### Nginx support
Using
```
docker run -e DOMAIN=example.com \
-e EMAIL=root@example.com \
-e NGINX=yes \
-e STAGING=no \
ungleich/ungleich-certbot
```
you will get a proper, real world usable nginx server. Inject the
nginx configuration by meains of a volume to /etc/nginx/conf.d
### Exiting after getting the certificate
By default, the container will stay alive and try to renew the

View file

@ -33,6 +33,12 @@ if [ "$ONLYGETCERT" ]; then
exit 0
fi
# Still there? Start nginx if requested
if [ "$NGINX" ]; then
nginx
fi
# Try to renew once per day
while true; do
/usr/bin/certbot renew
@ -46,5 +52,8 @@ while true; do
[ "$ONLYRENEWCERTSONCE" ] && exit 0
# reload nginx if we are running it
[ "$NGINX" ] && pkill -1 nginx
sleep 86400
done