From 1b71aab5b6944c711b473f665f3d153cc2643fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 18 Sep 2023 18:16:34 +0000 Subject: [PATCH] cleaner dockerization --- Dockerfile | 42 +++++++++++++++++++++---------- api/advent22_api/core/settings.py | 2 +- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index fbd4b79..c9f481b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,34 @@ -FROM node:lts AS uibuild -WORKDIR /usr/src/app -COPY ui/package*.json ui/yarn*.lock ./ -RUN yarn --production=false -COPY ui ./ -RUN yarn build +############ +# build ui # +############ -FROM tiangolo/uvicorn-gunicorn:python3.11-slim -WORKDIR /usr/src/app +FROM node:lts AS build-ui +WORKDIR /usr/local/src/advent22_ui +# install dependencies +COPY ui/package*.json ui/yarn*.lock . +RUN yarn install --production false + +# copy and build full ui +COPY ui . +RUN yarn build --dest /tmp/advent22_ui/html + +########### +# web app # +########### + +FROM tiangolo/uvicorn-gunicorn:python3.11-slim AS production +WORKDIR /usr/local/src/advent22_api + +# env setup ENV \ -PRODUCTION_MODE="true" \ -APP_MODULE="advent22_api.app:app" + PRODUCTION_MODE="true" \ + APP_MODULE="advent22_api.app:app" -COPY api ./ -RUN python -m pip --no-cache-dir install ./ -COPY --from=uibuild /usr/src/app/dist /html +# install api +COPY api . +RUN python -m pip --no-cache-dir install . + +# add prebuilt ui +COPY --from=build-ui /tmp/advent22_ui /usr/local/share/advent22_ui diff --git a/api/advent22_api/core/settings.py b/api/advent22_api/core/settings.py index 7a1fe75..65737f4 100644 --- a/api/advent22_api/core/settings.py +++ b/api/advent22_api/core/settings.py @@ -43,7 +43,7 @@ class Settings(BaseSettings): ##### production_mode: bool = False - ui_directory: str = "/html" + ui_directory: str = "/usr/local/share/advent22_ui/html" ##### # openapi settings