cleaner dockerization

This commit is contained in:
Jörn-Michael Miehe 2023-09-18 18:16:34 +00:00
parent 2d864dd57f
commit 1b71aab5b6
2 changed files with 30 additions and 14 deletions

View file

@ -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"
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

View file

@ -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