From e1f58e17285f2b19f52a0241362605b9088e5669 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Mon, 12 Jun 2023 18:14:01 +0200 Subject: [PATCH] :sparkles: Fixed Docker --- Dockerfile | 11 ++++++----- Pipfile | 3 +-- Pipfile.lock | 32 ++++---------------------------- docker-compose.yml | 16 +++++++++++++--- frontend/Dockerfile | 4 ++-- 5 files changed, 26 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index b35191d..062cdeb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ -FROM python:3.10-slim +FROM python:3.11-slim COPY Pipfile* /app/ WORKDIR /app/ RUN apt update && \ -apt install -y jq gcc libpq5 libpq-dev && \ -jq -r '.default | to_entries[] | .key + .value.version' Pipfile.lock > requirements.txt && \ -sed -i "s/psycopg2-binary/psycopg2/g" requirements.txt + apt install -y jq gcc libpq5 libpq-dev libmagic1 && \ + jq -r '.default | to_entries[] | .key + .value.version' Pipfile.lock > requirements.txt && \ + sed -i "s/psycopg2-binary/psycopg2/g" requirements.txt -RUN pip install -r requirements.txt +RUN pip install -r requirements.txt && \ + apt remove -y jq gcc COPY classquiz/ /app/classquiz/ COPY image_cleanup.py /app/image_cleanup.py diff --git a/Pipfile b/Pipfile index b047ea9..f010ccd 100644 --- a/Pipfile +++ b/Pipfile @@ -30,10 +30,8 @@ pillow = ">=9.1.1" authlib = "*" httpx = "*" itsdangerous = "*" -puremagic = "*" py-avataaars-no-png = "*" cryptography = "*" -scheduler = "*" webauthn = "*" pyotp = "*" minio = "*" @@ -60,3 +58,4 @@ python_version = "3.11" format = "black ." lint = "flake8 classquiz" test = "coverage run -m pytest --lf -v --asyncio-mode=strict classquiz/tests" +worker = "arq classquiz.worker.WorkerSettings" diff --git a/Pipfile.lock b/Pipfile.lock index 313ab50..ada2f3d 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "14b53f70a0556b62779c7f2a76c7850c0e5477005a0e462c587b30a8eecbe4fb" + "sha256": "f10247b4d32925c62f8f9c99a6b3d3bf0073f630d09cf15a7df884f86b78b0a2" }, "pipfile-spec": 6, "requires": { @@ -564,11 +564,11 @@ }, "fastapi": { "hashes": [ - "sha256:22d773ce95f14f04f8f37a0c8998fc163e67af83b65510d2879de6cbaaa10215", - "sha256:5c1d243030e63089ccfc0aec69c2da6d619943917727e8e82ee502358d5119bf" + "sha256:95d757511c596409930bd20673358d4a4d709004edb85c5d24d6ffc48fabcbf2", + "sha256:b53248ee45f64f19bb7600953696e3edf94b0f7de94df1e5433fc5c6136fa986" ], "index": "pypi", - "version": "==0.96.1" + "version": "==0.97.0" }, "frozenlist": { "hashes": [ @@ -1230,14 +1230,6 @@ ], "version": "==2.9.6" }, - "puremagic": { - "hashes": [ - "sha256:349e179f04bcc14eb0e2c3941cd9ee4ea74881ab6ccac63ea0c37c98f7a80b22", - "sha256:6e46aa78113a466abc9f69e6e8a4ce90eb57d908dafb809597012621061462bd" - ], - "index": "pypi", - "version": "==1.15" - }, "py-avataaars-no-png": { "hashes": [ "sha256:9cd593fe93d6e223626903da7310ad53e857b3fd856ce7e7f2b1faa401740054", @@ -1465,14 +1457,6 @@ "markers": "python_version >= '3.6' and python_version < '4'", "version": "==4.9" }, - "scheduler": { - "hashes": [ - "sha256:48e8fe16f4a0cbd24f169a2ed4f65b99fb0c3a7f4a28f4dfbf26cc901ab4112b", - "sha256:5ae5181d8462d89307bdae588b47f290a2fb7e3fa1073650354e01eb87a265f4" - ], - "index": "pypi", - "version": "==0.8.4" - }, "sentry-sdk": { "hashes": [ "sha256:79afb7c896014038e358401ad1d36889f97a129dfa8031c49b3f238cd1aa3935", @@ -1575,14 +1559,6 @@ "index": "pypi", "version": "==1.0.0" }, - "typeguard": { - "hashes": [ - "sha256:194fb3dbcb06ea9caf7088f3befee014de57961689f9c859ac5239b1ef61d987", - "sha256:c4a40af0ba8a41077221271b46d0a6d8d46045443e4d887887c69254ca861952" - ], - "markers": "python_full_version >= '3.7.4'", - "version": "==4.0.0" - }, "typer": { "extras": [ "all" diff --git a/docker-compose.yml b/docker-compose.yml index 6ebbab4..27acaf4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,16 +13,17 @@ services: REDIS_URL: redis://redis:6379/0?decode_responses=True API_URL: http://api:80 api: - build: + build: &build_cfg context: . dockerfile: Dockerfile restart: always - depends_on: + depends_on: &depends - db - redis - environment: + environment: &env_vars DB_URL: "postgresql://postgres:classquiz@db:5432/classquiz" + REDIS: "redis://redis:6379/0?decode_responses=True" MAIL_ADDRESS: "email@email@email.email" MAIL_PASSWORD: "PASSWORT" MAIL_USERNAME: "email@email@email.email" @@ -34,6 +35,8 @@ services: SKIP_EMAIL_VERIFICATION: True HCAPTCHA_KEY: "HCAPTCHA_PRIVATE_KEY" MEILISEARCH_URL: "http://meilisearch:7700" + STORAGE_BACKEND: "local" + STORAGE_PATH: "/app/data" redis: image: redis:alpine restart: always @@ -67,6 +70,13 @@ services: MEILI_NO_ANALYTICS: true volumes: - meilisearch-data:/data.ms + worker: + build: *build_cfg + environment: *env_vars + depends_on: *depends + command: arq classquiz.worker.WorkerSettings + + volumes: data: meilisearch-data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 9c5fbb9..ad25ef4 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -22,7 +22,7 @@ COPY package*.json ./ COPY pnpm-lock.yaml ./ # run npm install in our local machine -RUN corepack enable && corepack prepare pnpm@7.26.2 --activate && pnpm i +RUN corepack enable && corepack prepare pnpm@8.6.1 --activate && pnpm i # copy the generated modules and all other files to the container COPY . . @@ -38,7 +38,7 @@ FROM node:19-bullseye-slim WORKDIR /app COPY --from=builder /usr/src/app/package.json . COPY --from=builder /usr/src/app/pnpm-lock.yaml . -RUN corepack enable && corepack prepare pnpm@7.26.2 --activate && pnpm i +RUN corepack enable && corepack prepare pnpm@8.6.1 --activate && pnpm i # copy files from previous step COPY --from=builder /usr/src/app/build . COPY --from=builder /usr/src/app/node_modules ./node_modules