Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Copy to the mounted volume in python code

Daoud Clarke09de4a918ee5
diff --git a/Dockerfile b/Dockerfile
index 9feffec..41d6904 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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
diff --git a/mwmbl/apps.py b/mwmbl/apps.py
index bfc21a5..fb95732 100644
--- a/mwmbl/apps.py
+++ b/mwmbl/apps.py
@@ -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')