Merge pull request #12 from ds17f/easy-user-config
Allow user configs without custom image
This commit is contained in:
commit
4cedfe2a4d
11
README.md
11
README.md
|
@ -11,13 +11,12 @@ This repository was originally forked from `@henridwyer`, many thanks to him for
|
|||
|
||||
# Usage
|
||||
|
||||
Use this image with a `Dockerfile` such as:
|
||||
```Dockerfile
|
||||
FROM staticfloat/nginx-certbot
|
||||
COPY *.conf /etc/nginx/conf.d/
|
||||
Create a config directory for your custom configs:
|
||||
```
|
||||
mkdir conf.d
|
||||
```
|
||||
|
||||
And a `.conf` file such as:
|
||||
And a `.conf` in that directory:
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
@ -43,6 +42,8 @@ services:
|
|||
- 443:443/tcp
|
||||
environment:
|
||||
- CERTBOT_EMAIL=owner@company.com
|
||||
volumes:
|
||||
- ./conf.d:/etc/nginx/user.conf.d :ro
|
||||
...
|
||||
```
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
FROM staticfloat/nginx-certbot
|
||||
COPY *.conf /etc/nginx/conf.d/
|
|
@ -2,10 +2,13 @@ version: '3'
|
|||
|
||||
services:
|
||||
proxy:
|
||||
build: .
|
||||
image: staticfloat/nginx-certbot
|
||||
restart: always
|
||||
environment:
|
||||
CERTBOT_EMAIL: "your.email@example.com"
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./conf.d:/etc/nginx/user.conf.d :ro
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ trap "kill 0" EXIT
|
|||
# Source in util.sh so we can have our nice tools
|
||||
. $(cd $(dirname $0); pwd)/util.sh
|
||||
|
||||
# first include any user configs if they've been mounted
|
||||
link_user_configs
|
||||
|
||||
# Immediately run auto_enable_configs so that nginx is in a runnable state
|
||||
auto_enable_configs
|
||||
|
||||
|
|
|
@ -92,3 +92,21 @@ is_renewal_required() {
|
|||
is_finshed_week_sec=$(( ($one_week_sec - $last_renewal_delta_sec) ))
|
||||
[ $is_finshed_week_sec -lt 0 ]
|
||||
}
|
||||
|
||||
# symlinks any *.conf files in /etc/nginx/user.conf.d
|
||||
# to /etc/nginx/conf.d so they are included as configs
|
||||
# this allows a user to easily mount their own configs
|
||||
link_user_configs() {
|
||||
SOURCE_DIR="${1-/etc/nginx/user.conf.d}"
|
||||
TARGET_DIR="${2-/etc/nginx/conf.d}"
|
||||
|
||||
echo "symlinking scripts from ${SOURCE_DIR} to ${TARGET_DIR}"
|
||||
|
||||
if [ ! -d "$SOURCE_DIR" ]; then
|
||||
echo "no ${SOURCE_DIR}, nothing to do."
|
||||
else
|
||||
for conf in ${SOURCE_DIR}/*.conf; do
|
||||
ln -sv "${conf}" "${TARGET_DIR}/$(basename ${conf})"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue