1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mygpo_ynh.git synced 2024-09-03 19:55:52 +02:00

🐛 Use django collectstatic

This commit is contained in:
Olivier Brencklé 2023-02-21 13:51:44 +01:00 committed by Félix Piédallu
parent e970cb554b
commit 19cac06328
4 changed files with 16 additions and 9 deletions

View file

@ -7,7 +7,7 @@ location /media {
}
location /static/ {
alias __INSTALL_DIR__/static/;
alias __INSTALL_DIR__/staticfiles/;
}
location /logo {
@ -45,14 +45,6 @@ location @proxy_to_app {
proxy_set_header Connection "upgrade";
}
location /media/admin/ {
alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin/;
}
location /static/admin/ {
alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin/;
}
location ~ /(favicon.ico|favicon.png|robots.txt|clientconfig.json) {
expires 336h; # 2 weeks
}

View file

@ -32,6 +32,13 @@ function set_up_virtualenv {
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt"
}
function collect_static {
pushd "$install_dir"
chown -R "$app:$app" "$install_dir"
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" collectstatic --noinput
popd
}
function initialize_db {
perform_db_migrations
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0

View file

@ -54,6 +54,10 @@ ynh_script_progression --message="Initializing Python virtualenv..." --weight=20
set_up_virtualenv
ynh_script_progression --message="Collecting static..."
collect_static
#=================================================
# INITIALIZE DATABASE
#=================================================

View file

@ -87,6 +87,10 @@ ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2
set_up_virtualenv
ynh_script_progression --message="Collecting static..."
collect_static
#=================================================
# PERFORM DATABASE MIGRATIONS
#=================================================