Reafactor: Docker auto-build should be a out-of-the-box image without any extra config

This commit is contained in:
winkidney
2019-12-19 16:10:14 +08:00
parent 2a2f65c437
commit 77fca13edf
7 changed files with 59 additions and 96 deletions

29
docker/scripts/bootstrap.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
gen_key() {
echo "=================================================================================="
echo "Note: Please copy this key and keep it in a secure place."
echo "Then you should manually edit your pinry/local_settings.py"
echo "and replace SECRET_KEY with new secret-key if you had previously generated a"
echo "pinry/local_settings.py."
echo "If no previous pinry/local_settings.py generated, you can have a look and edit it."
echo "If you want to use docker-compose, just edit docker-compose.yml and use 'docker-compose up'"
SECRET_KEY=$(bash /scripts/gen_key.sh)
echo ""
echo "Your secret-key is(also saved/overwritten your docker's /data/production_secret_key.txt):"
echo ""
echo ${SECRET_KEY}
echo "=================================================================================="
}
local_settings_file="/data/local_settings.py"
# Create local_settings.py
if [ ! -f "${local_settings_file}" ];
then
cp "/srv/www/pinry/settings/local_settings.example.py" "${local_settings_file}"
gen_key
sed -i "s/secret\_key\_place\_holder/${SECRET_KEY}/" "${local_settings_file}"
ln -s "${local_settings_file}" "/srv/www/pinry/settings/local_settings.py"
fi