From 0372866a9828766250e8f9b18e6b5157c17c3c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:28:00 +0200 Subject: [PATCH] wip: new Dockerfile --- Dockerfile | 66 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index cd8925f..8db9e61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,41 +2,43 @@ # build ui # ############ -FROM node:lts-alpine AS build-ui - -# some dir for our code -WORKDIR /app - -# install dependencies -COPY ui/package*.json ui/yarn*.lock ./ -RUN yarn --production=false - -# copy code -COPY ui . -RUN yarn build - - -############## -# webservice # -############## - -FROM antonapetrov/uvicorn-gunicorn:python3.9-alpine3.13 AS production - -RUN set -ex; \ - # prerequisites - apk add --no-cache \ - libmagic \ - ; +FROM node:18.16 AS build-ui # env setup -ENV \ +WORKDIR /usr/local/src/ovdashboard_ui + +# install ovdashboard_ui dependencies +COPY ui/package*.json ui/yarn*.lock ./ +RUN yarn install --production false + +# copy and build ovdashboard_ui +COPY ui ./ +RUN yarn build --dest /tmp/ovdashboard_ui/html + +########### +# web app # +########### + +FROM tiangolo/uvicorn-gunicorn:python3.12-slim AS production + +# add prepared ovdashboard_ui +COPY --from=build-ui /tmp/ovdashboard_ui /usr/local/share/ovdashboard_ui + +# env setup +WORKDIR /usr/local/src/ovdashboard_api +ENV \ PRODUCTION_MODE="true" \ - APP_MODULE="ovdashboard_api:app" + PORT="8000" \ + MODULE_NAME="ovdashboard_api.app" +EXPOSE 8000 -# install API -COPY api /usr/src/ovdashboard_api +# install ovdashboard_api +COPY api ./ RUN set -ex; \ - pip3 --no-cache-dir install /usr/src/ovdashboard_api; + # remove example app + rm -rf /app; \ + \ + python -m pip --no-cache-dir install ./ -# install UI -COPY --from=build-ui /app/dist /html \ No newline at end of file +# run as unprivileged user +USER nobody