aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Dockerfile7
-rwxr-xr-xmanage.py11
2 files changed, 16 insertions, 2 deletions
diff --git a/Dockerfile b/Dockerfile
index 5594b458..c07fc2e2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -24,6 +24,13 @@ ENV GIT_SHA=$git_sha
# Copy the source code in last to optimize rebuilding the image
COPY . .
+# Set dummy variables so collectstatic can load settings.py
+RUN \
+ SECRET_KEY=dummy_value \
+ DATABASE_URL=postgres://localhost \
+ METRICITY_DB_URL=postgres://localhost \
+ python manage.py collectstatic --noinput --clear
+
# Run web server through custom manager
ENTRYPOINT ["python", "manage.py"]
CMD ["run"]
diff --git a/manage.py b/manage.py
index d21546e1..8bb5ae0d 100755
--- a/manage.py
+++ b/manage.py
@@ -138,10 +138,17 @@ class SiteManager:
print("Applying migrations.")
call_command("migrate", verbosity=self.verbosity)
- print("Collecting static files.")
- call_command("collectstatic", interactive=False, clear=True, verbosity=self.verbosity)
if self.debug:
+ # In Production, collectstatic is ran in the Docker image
+ print("Collecting static files.")
+ call_command(
+ "collectstatic",
+ interactive=False,
+ clear=True,
+ verbosity=self.verbosity - 1
+ )
+
self.set_dev_site_name()
self.create_superuser()