Skip to content

Commit ee0fcd3

Browse files
authored
Merge pull request #568 from python-discord/jb3/collectstatic-build
2 parents cc9ae18 + fa25dc9 commit ee0fcd3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ ENV GIT_SHA=$git_sha
2424
# Copy the source code in last to optimize rebuilding the image
2525
COPY . .
2626

27+
# Set dummy variables so collectstatic can load settings.py
28+
RUN \
29+
SECRET_KEY=dummy_value \
30+
DATABASE_URL=postgres://localhost \
31+
METRICITY_DB_URL=postgres://localhost \
32+
python manage.py collectstatic --noinput --clear
33+
2734
# Run web server through custom manager
2835
ENTRYPOINT ["python", "manage.py"]
2936
CMD ["run"]

manage.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,17 @@ def prepare_server(self) -> None:
138138

139139
print("Applying migrations.")
140140
call_command("migrate", verbosity=self.verbosity)
141-
print("Collecting static files.")
142-
call_command("collectstatic", interactive=False, clear=True, verbosity=self.verbosity)
143141

144142
if self.debug:
143+
# In Production, collectstatic is ran in the Docker image
144+
print("Collecting static files.")
145+
call_command(
146+
"collectstatic",
147+
interactive=False,
148+
clear=True,
149+
verbosity=self.verbosity - 1
150+
)
151+
145152
self.set_dev_site_name()
146153
self.create_superuser()
147154

0 commit comments

Comments
 (0)