mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-11 12:17:37 +03:00
b766b7c4bc
Added new replacement variable for nginx-secure: ___NAMESERVER___. This is parsed out from the system resolv.conf and used to resolve the ip's of the containers dynamically Modified nginx-secure.conf to resolve certbot dynamically NOTE: if using `docker-compose run certbot ...`, set `--name certbot` so it can be resolved properly Added CMD /start.sh back in, guessing it was removed by accident
63 lines
1.8 KiB
Bash
Executable File
63 lines
1.8 KiB
Bash
Executable File
echo sleep 5
|
|
sleep 5
|
|
|
|
echo build starting nginx config
|
|
|
|
|
|
echo replacing ___my.example.com___/$MY_DOMAIN_NAME
|
|
|
|
# Put your domain name into the nginx reverse proxy config.
|
|
sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx.conf
|
|
|
|
cat /etc/nginx/nginx.conf
|
|
echo .
|
|
echo Firing up nginx in the background.
|
|
nginx
|
|
|
|
# # Check user has specified domain name
|
|
if [ -z "$MY_DOMAIN_NAME" ]; then
|
|
echo "Need to set MY_DOMAIN_NAME (to a letsencrypt-registered name)."
|
|
exit 1
|
|
fi
|
|
|
|
# This bit waits until the letsencrypt container has done its thing.
|
|
# We see the changes here bceause there's a docker volume mapped.
|
|
echo Waiting for folder /etc/letsencrypt/live/$MY_DOMAIN_NAME to exist
|
|
while [ ! -d /etc/letsencrypt/live/$MY_DOMAIN_NAME ] ;
|
|
do
|
|
sleep 2
|
|
done
|
|
|
|
while [ ! -f /etc/letsencrypt/live/$MY_DOMAIN_NAME/fullchain.pem ] ;
|
|
do
|
|
echo Waiting for file fullchain.pem to exist
|
|
sleep 2
|
|
done
|
|
|
|
while [ ! -f /etc/letsencrypt/live/$MY_DOMAIN_NAME/privkey.pem ] ;
|
|
do
|
|
echo Waiting for file privkey.pem to exist
|
|
sleep 2
|
|
done
|
|
|
|
# This is added so that when the certificate is being renewed or is already in place, nginx waits for everything to be good.
|
|
sleep 15
|
|
|
|
echo replacing ___my.example.com___/$MY_DOMAIN_NAME
|
|
|
|
|
|
# Put your domain name into the nginx reverse proxy config.
|
|
sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx-secure.conf
|
|
|
|
# Add the system's nameserver (the docker network dns) so we can resolve container names in nginx
|
|
NAMESERVER=`cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}' | tr '\n' ' '`
|
|
echo replacing ___NAMESERVER___/$NAMESERVER
|
|
sed -i "s/___NAMESERVER___/$NAMESERVER/g" /etc/nginx/nginx-secure.conf
|
|
|
|
|
|
#go!
|
|
kill $(ps aux | grep 'nginx' | grep -v 'grep' | awk '{print $2}')
|
|
cp /etc/nginx/nginx-secure.conf /etc/nginx/nginx.conf
|
|
|
|
nginx -g 'daemon off;'
|