From 91762f58b72bc92c82d243d53cd6e85749fbb1ed Mon Sep 17 00:00:00 2001 From: Lilia Kai Date: Tue, 5 Sep 2023 16:10:37 +0200 Subject: [PATCH 1/2] Add option to serve local archive files Set an environment variable in the docker compose file, then reference that variable in main.py to mount the local archive so that the links generated by auto-archiver will work correctly. Fixes #8 --- docker-compose.yml | 1 + src/main.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9115d7b..730279a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: environment: - CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:6379/0 - CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:6379/0 + - SERVE_LOCAL_ARCHIVE=/app/local_archive # See orchestration.yaml local_storage.save_to depends_on: - redis diff --git a/src/main.py b/src/main.py index 2344664..f879961 100644 --- a/src/main.py +++ b/src/main.py @@ -44,6 +44,11 @@ Instrumentator().instrument(app).expose(app, dependencies=[Depends(get_basic_aut app.mount("/static", StaticFiles(directory="static"), name="static") +SERVE_LOCAL_ARCHIVE = os.environ.get("SERVE_LOCAL_ARCHIVE", "") +if len(SERVE_LOCAL_ARCHIVE) > 1 and os.path.isdir(SERVE_LOCAL_ARCHIVE): + logger.info(f"mounting local archive {SERVE_LOCAL_ARCHIVE}") + app.mount(SERVE_LOCAL_ARCHIVE, StaticFiles(directory=SERVE_LOCAL_ARCHIVE), name=SERVE_LOCAL_ARCHIVE) + def get_db(): session = SessionLocal() try: yield session @@ -186,4 +191,4 @@ async def on_startup(): @repeat_every(seconds=60 * 60) # 1 hour async def on_startup(): db: Session = next(get_db()) - crud.upsert_user_groups(db) \ No newline at end of file + crud.upsert_user_groups(db) From 43144330a7e2f3dee37373158e05b9204fe2b03f Mon Sep 17 00:00:00 2001 From: Lilia Kai Date: Wed, 6 Sep 2023 14:53:36 +0200 Subject: [PATCH 2/2] Move dev configs to their own file --- docker-compose.dev.yml | 11 +++++++++++ docker-compose.yml | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..3dfa717 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,11 @@ +version: '3.8' + +services: + web: + environment: + - SERVE_LOCAL_ARCHIVE=/app/local_archive # See orchestration.yaml local_storage.save_to + - ALLOWED_ORIGINS=http://localhost:8004 + redis: + command: redis-server /conf/redis.conf + ports: + - 6379:6379 diff --git a/docker-compose.yml b/docker-compose.yml index 730279a..fa99160 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,6 @@ services: environment: - CELERY_BROKER_URL=redis://:${REDIS_PASSWORD}@redis:6379/0 - CELERY_RESULT_BACKEND=redis://:${REDIS_PASSWORD}@redis:6379/0 - - SERVE_LOCAL_ARCHIVE=/app/local_archive # See orchestration.yaml local_storage.save_to depends_on: - redis @@ -34,15 +33,11 @@ services: redis: image: redis:6-alpine - # command: redis-server /conf/redis.conf # DEV ONLY command: redis-server /conf/redis.conf --requirepass ${REDIS_PASSWORD} volumes: - "./redis/data:/data" - "./redis/config:/conf" restart: always - # DEV ONLY - # ports: - # - 6379:6379 dashboard: build: ./src