Copy to the mounted volume in python code

This commit is contained in:
Daoud Clarke 2023-10-12 21:21:30 +01:00
parent 88c3437456
commit 09de4a918e
2 changed files with 14 additions and 1 deletions

View file

@ -47,7 +47,7 @@ RUN apt-get update && apt-get install -y postgresql-client
COPY --from=builder /venv /venv
# Copy the front end build
COPY --from=front-end /front-end/dist /app/static
COPY --from=front-end /front-end/dist /front-end-build
ADD nginx.conf.sigil /app

View file

@ -1,3 +1,5 @@
import os
import shutil
from multiprocessing import Process, Queue
from pathlib import Path
@ -33,3 +35,14 @@ class MwmblConfig(AppConfig):
Process(target=background.run, args=(settings.DATA_PATH,)).start()
Process(target=update_queue_continuously, args=(new_item_queue, queued_batches,)).start()
Process(target=update_urls_continuously, args=(settings.DATA_PATH, new_item_queue)).start()
if not settings.DEBUG:
# Remove all existing content from the static folder:
# https://stackoverflow.com/a/1073382
for root, dirs, files in os.walk('/app/static'):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
shutil.copytree('/front-end-dist', '/app/static')