From bb8c3a07ebb7476075c6f16fd686046b3efb84a7 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Mon, 12 Jun 2023 20:01:30 +0200 Subject: [PATCH] :sparkles: Added documentation about new storage and how to use it --- classquiz/config.py | 5 +- docker-compose.yml | 3 +- frontend/src/routes/docs/develop/+page.svelte | 4 ++ .../src/routes/docs/self-host/+page.svelte | 50 ++++++++++++------- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/classquiz/config.py b/classquiz/config.py index 9216f81..49a8476 100644 --- a/classquiz/config.py +++ b/classquiz/config.py @@ -53,10 +53,7 @@ class Settings(BaseSettings): free_storage_limit: int = 1074000000 # storage_backend - storage_backend: str | None = "deta" - # if storage_backend == "deta": - deta_project_key: str | None - deta_project_id: str | None + storage_backend: str | None = "local" # if storage_backend == "local": storage_path: str | None diff --git a/docker-compose.yml b/docker-compose.yml index 27acaf4..29b7ff0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: build: &build_cfg context: . dockerfile: Dockerfile - restart: always + restart: &restart always depends_on: &depends - db - redis @@ -74,6 +74,7 @@ services: build: *build_cfg environment: *env_vars depends_on: *depends + restart: *restart command: arq classquiz.worker.WorkerSettings diff --git a/frontend/src/routes/docs/develop/+page.svelte b/frontend/src/routes/docs/develop/+page.svelte index 4b3c763..59f0688 100644 --- a/frontend/src/routes/docs/develop/+page.svelte +++ b/frontend/src/routes/docs/develop/+page.svelte @@ -87,6 +87,10 @@ Start Caddy:
caddy run
+
  • + Start the background-worker: +
    arq classquiz.worker.WorkerSettings
    +
  • If you're done developing: ./run_tests.sh -

    If you want to run all the tests: ./run_tests.sh a

    diff --git a/frontend/src/routes/docs/self-host/+page.svelte b/frontend/src/routes/docs/self-host/+page.svelte index 5dd8e89..23bdbc1 100644 --- a/frontend/src/routes/docs/self-host/+page.svelte +++ b/frontend/src/routes/docs/self-host/+page.svelte @@ -96,18 +96,20 @@

    Storage Provider

    You'll have to set up a storage provider for some pictures (these getting imported from - KAHOOT!). For now, you can use Deta or the local filesystem. - Please note that I would NOT use the local file system because of - Path Traversals. I tried to - prevent these attacks, but I really wouldn't trust it, because it's a regex! You'll have to - set the - STORAGE_BACKEND-environment-variable to either deta or - local. + Kahoot!). For now, you can use Minio (S3) or + the local filesystem. Please not that I'd recommend Minio for larger instances, since it can + be scaled and the media doesn't have to streamed through the (comparatively) slow ClassQuiz + server. Now, that you've decided on a storage backend, you can set the + STORAGE_BACKEND-environment-variable to either s3 or + local. If you ask yourself what happened with deta, I've decided to remove it, + since the went all-in with their spaces and I think that hardly anyone used it anyway.

    -

    If you chose Deta...

    +

    If you chose Minio (S3)...

    - ...you'll also have to set the DETA_PROJECT_KEY and the - DETA_PROJECT_ID. + ...you'll also have to set the S3_ACCESS_KEY, S3_SECRET_KEY and + the + S3_BASE_URL. The S3_BUCKET_NAME can also be set, but defaults to + classquiz.

    If you chose the local filesystem...

    @@ -165,15 +167,15 @@ services: REDIS_URL: redis://redis:6379/0?decode_responses=True # don't change API_URL: http://api:80 # don't change api: - build: + build: &build_cfg context: . dockerfile: Dockerfile - restart: always - depends_on: + restart: &restart always + depends_on: &depends - db - redis - environment: + environment: &env_vars ROOT_ADDRESS: "https://classquiz.de" # Base-URL (change it) DB_URL: "postgresql://postgres:classquiz@db:5432/classquiz" # don't change MAIL_ADDRESS: "classquiz@mawoka.eu" # Email-Address (change it) @@ -188,11 +190,13 @@ services: MEILISEARCH_URL: "http://meilisearch:7700" # don't change ACCESS_TOKEN_EXPIRE_MINUTES: 30 # don't change HCAPTCHA_KEY: "" # Private hCaptcha key for verification (change it) - STORAGE_BACKEND: "deta" # MUST BE EITHER "deta" OR "local" + STORAGE_BACKEND: "local" # MUST BE EITHER "s3" OR "local" + FREE_STORAGE_LIMIT: "1074000000" # Free storage limit in bytes (default: 1GB) - # If STORAGE_BACKEND is "deta" - DETA_PROJECT_KEY: "YOUR_DETA_PROJECT_KEY" - DETA_PROJECT_ID: "YOUR_DETA_PROJECT_ID" + # If STORAGE_BACKEND is "s3" + S3_ACCESS_KEY=YOUR_ACCESS_KEY + S3_SECRET_KEY=YOUR_SECRET_KEY + S3_BASE_URL=YOUR_S3_BASE_URL # If STORAGE_BACKEND is "local" STORAGE_PATH: "/var/storage" @@ -205,6 +209,8 @@ services: GITHUB_CLIENT_ID: # Your GitHub-Client ID, or leave it unset if you don't want it. GITHUB_CLIENT_SECRET: # Your GitHub-Client Secret, or leave it unset if you don't want it. + volumes: # Only needed if you chose the "local" storage-backend + - ./uploads:/var/storage redis: image: redis:alpine @@ -241,6 +247,14 @@ services: MEILI_NO_ANALYTICS: true volumes: - meilisearch-data:/data.ms + worker: + build: *build_cfg + environment: *env_vars + restart: *restart + depends_on: *depends + command: arq classquiz.worker.WorkerSettings + + volumes: data: meilisearch-data: