From fbecae5d5342512ee6796cb43e76f88bf2f7d91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 26 Nov 2024 14:44:18 +0100 Subject: [PATCH 1/3] fix: explicitly serve dev UI on 0.0.0.0:8080 --- ui/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/package.json b/ui/package.json index 8486253..0e92cae 100644 --- a/ui/package.json +++ b/ui/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "serve": "vue-cli-service serve", + "serve": "vue-cli-service serve --host 0.0.0.0 --port 8080", "build": "vue-cli-service build", "test:unit": "vue-cli-service test:unit", "test:unit-watch": "vue-cli-service test:unit --watch", From 5cf1c8b7ee5a7d6cb56c69e0fada2d27429cbc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 26 Nov 2024 14:44:47 +0100 Subject: [PATCH 2/3] fix: better use of images_manual --- api/advent22_api/core/depends.py | 33 ++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/api/advent22_api/core/depends.py b/api/advent22_api/core/depends.py index dd28a8b..7566644 100644 --- a/api/advent22_api/core/depends.py +++ b/api/advent22_api/core/depends.py @@ -100,21 +100,33 @@ async def get_all_auto_image_names( return dict(zip(days, rnd.shuffled(ls))) +async def get_all_manual_image_names( + manual_image_names: list[str] = Depends(list_images_manual), +) -> dict[int, str]: + """ + Bilder: "manual" zuordnen + """ + + num_re = re.compile(r"/(\d+)\.", flags=re.IGNORECASE) + return { + int(num_match.group(1)): name + for name in manual_image_names + if (num_match := num_re.search(name)) is not None + } + + async def get_all_image_names( auto_image_names: dict[int, str] = Depends(get_all_auto_image_names), - manual_image_names: list[str] = Depends(list_images_manual), + manual_image_names: dict[int, str] = Depends(get_all_manual_image_names), ) -> dict[int, str]: """ Bilder "auto" und "manual" zu Tagen zuordnen """ - num_re = re.compile(r"/(\d+)\.", flags=re.IGNORECASE) + result = auto_image_names.copy() + result.update(manual_image_names) - for name in manual_image_names: - assert (num_match := num_re.search(name)) is not None - auto_image_names[int(num_match.group(1))] = name - - return auto_image_names + return result @dataclass(slots=True, frozen=True) @@ -184,6 +196,7 @@ async def get_day_image( day: int, days: list[int] = Depends(get_all_sorted_days), cfg: Config = Depends(get_config), + manual_image_names: dict[int, str] = Depends(get_all_manual_image_names), auto_image_names: dict[int, str] = Depends(get_all_auto_image_names), day_parts: dict[int, str] = Depends(get_all_parts), ttfonts: list[TTFont] = Depends(get_all_ttfonts), @@ -196,14 +209,14 @@ async def get_day_image( return None try: - # Versuche, aus "manual"-Ordner zu laden - img = await load_image(f"images_manual/{day}.jpg") + # Versuche "manual"-Bild zu laden + img = await load_image(manual_image_names[day]) # Als AdventImage verarbeiten image = await AdventImage.from_img(img, cfg) return image.img - except RuntimeError: + except (KeyError, RuntimeError): # Erstelle automatisch generiertes Bild return await gen_day_auto_image( day=day, From 4a7e49471015c47a2dec19587309690a2072798d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 26 Nov 2024 14:58:02 +0100 Subject: [PATCH 3/3] build NODE_VERSION --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 73a52dd..1e22375 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # build ui # ############ -ARG NODE_VERSION=18.16 +ARG NODE_VERSION=18.18 ARG PYTHON_VERSION=3.11-slim FROM node:${NODE_VERSION} AS build-ui