From 19cac063284982a8ed2e61b50116e84e44362e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Brenckl=C3=A9?= Date: Tue, 21 Feb 2023 13:51:44 +0100 Subject: [PATCH] :bug: Use django collectstatic --- conf/nginx.conf | 10 +--------- scripts/_common.sh | 7 +++++++ scripts/install | 4 ++++ scripts/upgrade | 4 ++++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 168b62c..eb0909d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -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 } diff --git a/scripts/_common.sh b/scripts/_common.sh index 3b9cc22..12c5b59 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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 diff --git a/scripts/install b/scripts/install index f862915..e67d8ee 100755 --- a/scripts/install +++ b/scripts/install @@ -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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 43effd3..a13e7cc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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 #=================================================