diff options
author | 2021-08-25 22:34:14 +0000 | |
---|---|---|
committer | 2021-08-25 22:34:14 +0000 | |
commit | ed15b2c737bffc83008c694f01ad693ddbdd974a (patch) | |
tree | e2a86033ac099a20f87c869a305ae0420f9b7ed9 | |
parent | Merge pull request #565 from ethansocal/main (diff) |
Run collectstatic in the image build process, disable in prod startup
-rw-r--r-- | Dockerfile | 7 | ||||
-rwxr-xr-x | manage.py | 6 |
2 files changed, 11 insertions, 2 deletions
@@ -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 + # Run web server through custom manager ENTRYPOINT ["python", "manage.py"] CMD ["run"] @@ -138,10 +138,12 @@ 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) + self.set_dev_site_name() self.create_superuser() |