更新docker运行脚本

This commit is contained in:
zmister 2022-01-06 20:04:25 +08:00
parent a2b278599b
commit aa3c84b54b

View File

@ -1,41 +1,13 @@
#!/bin/sh
MM=`pwgen -1s`
CREATE_USER=1
CONFIG_FILE='/app/MrDoc/config/config.ini'
if [ ! -f $CONFIG_FILE ]; then
echo "#####Generating configuration file#####"
cat>"${CONFIG_FILE}"<<EOF
[site]
# True表示开启站点调试模式False表示关闭站点调试模式
debug = False
[database]
# engine指定数据库类型接受sqlite、mysql、oracle、postgresql
engine = sqlite
[selenium]
driver_path = /usr/lib/chromium/chromedriver
# 详细配置请查阅 https://www.mrdoc.fun/project-1/doc-190/
EOF
else
echo "#####Configuration file already exists#####"
fi
python /app/MrDoc/manage.py makemigrations && python /app/MrDoc/manage.py migrate && nohup echo y |python /app/MrDoc/manage.py rebuild_index &
if [ $CREATE_USER -eq 1 ]; then
if [ ! -e $CREATE_USER ]; then
touch $CREATE_USER
echo "-- First container startup --user:${USER} pwd:${MM}"
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('${USER}', 'www@mrdoc.fun', '${MM}')" | python /app/MrDoc/manage.py shell
# YOUR_JUST_ONCE_LOGIC_HERE
else
echo "-- Not first container startup --"
fi
else
echo "user switch not create"
fi
python -u /app/MrDoc/manage.py runserver --noreload 0.0.0.0:${LISTEN_PORT}
# 生成数据库迁移文件
python /app/MrDoc/manage.py makemigrations &&
# 根据数据库迁移文件执行数据库变更
python /app/MrDoc/manage.py migrate &&
# 重建全文搜索索引
nohup echo y |python /app/MrDoc/manage.py rebuild_index &&
# 启动uwsgi
uwsgi --ini /app/MrDoc/config/uwsgi.ini
# 直接 runserver 方式运行
# python -u /app/MrDoc/manage.py runserver --noreload 0.0.0.0:${LISTEN_PORT}
exec "$@"