From bdcb1036953f6c56e305bc3b123f9c3fa21e3bf3 Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Mon, 22 Mar 2021 20:45:36 +0100
Subject: [PATCH] Run `collectstatic` at build time

Advances #403
---
 Dockerfile        | 4 +++-
 docker-startup.sh | 8 --------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index fb54a4503..1f756dfc9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -61,7 +61,9 @@ CMD ["/usr/local/bin/aleksis-docker-startup"]
 
 # Install assets
 FROM core as assets
-RUN eatmydata aleksis-admin yarn install
+RUN eatmydata aleksis-admin yarn install; \
+    eatmydata aleksis-admin collectstatic; \
+    rm -rf /usr/local/share/.cache
 
 # Clean up build dependencies
 FROM assets AS clean
diff --git a/docker-startup.sh b/docker-startup.sh
index 98705fb16..b73e6a710 100755
--- a/docker-startup.sh
+++ b/docker-startup.sh
@@ -46,12 +46,6 @@ wait_database() {
 	echo
 }
 
-prepare_static() {
-	# Prepare static files; should only be run in app container or job
-	aleksis-admin compilescss
-	aleksis-admin collectstatic --no-input --clear
-}
-
 prepare_database() {
 	# Migrate database; should only be run in app container or job
 	aleksis-admin migrate
@@ -79,7 +73,6 @@ uwsgi)
 	if [ $PREPARE = 1 ]; then
 		# Responsible for running migratiosn and preparing staticfiles
 		prepare_database
-		prepare_static
 	else
 		# Wait for migrations to be applied elsewhere
 		wait_migrations
@@ -103,7 +96,6 @@ celery-*)
 prepare)
 	# Preparation only mode
 	prepare_database
-	prepare_static
 	;;
 *)
 	# Run arguments as command verbatim
-- 
GitLab