nginx-certbot
nginx-certbot copied to clipboard
WIP: Attempt to automate initial bootstrap without need to run `init-letsencrypt.sh` manually
In some my project I do need to fully automate SSL certificate creation without user intervention. Idea is to move init-letsencrypt.sh
and tune up scripts so initial certificates will be created automatically.
Steps:
- [x] Update
docker-compose.yml
or create aDockerfile
so certbot service won't start without "healthy" nginx service; - [x] Create a
Dockerfile
for nginx service, add adocker-entrypoint.sh
, that replicate most of theinit-letsencrypt.sh
logic:- [x] Create new SSL for first run (by checking for a files presence in the certain folder);
- [x] Start
nginx
linux service and remove created SSL certificate right after that; - [x] Wait for
certbot
docker service and request certificate first time; - [x] domain, email and other user-data should be available through environment variable (introduce
.env
file;
- [ ] Update
README.md
.
Is there a plan to accept this pull request?
if domains were an array, the init-letsencrypt.sh will failed, it just handled the first domain in array.
### no for loop here.
echo "### Creating dummy certificate for $domains ..."
path="/etc/letsencrypt/live/$domains"
mkdir -p "$data_path/conf/live/$domains"
docker-compose run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\
-keyout '$path/privkey.pem' \
-out '$path/fullchain.pem' \
-subj '/CN=localhost'" certbot
echo
Also need to update README.md