############ # build ui # ############ ARG NODE_VERSION=lts ARG PYTHON_VERSION=3.12-slim FROM node:${NODE_VERSION} AS build-ui # env setup 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 ###################### # python preparation # ###################### ARG PYTHON_VERSION FROM python:${PYTHON_VERSION} as uvicorn-gunicorn # where credit is due ... LABEL maintainer="Sebastian Ramirez " WORKDIR /usr/local/share/uvicorn-gunicorn # install uvicorn-gunicorn COPY ./deploy/mini-tiangolo ./ RUN set -ex; \ chmod +x start.sh; \ python3 -m pip --no-cache-dir install gunicorn; CMD "/usr/local/share/uvicorn-gunicorn/start.sh" ########### # web app # ########### FROM uvicorn-gunicorn AS production # env setup WORKDIR /usr/local/src/ovdashboard_api ENV \ PRODUCTION_MODE="true" \ PORT="8000" \ MODULE_NAME="ovdashboard_api.app" EXPOSE 8000 COPY api ./ RUN set -ex; \ # building hiredis BUILD_DEPS="${BUILD_DEPS:-} gcc libc6-dev"; \ \ # install dependencies export DEBIAN_FRONTEND=noninteractive; \ apt-get update; apt-get install --yes --no-install-recommends \ libmagic1 \ ${BUILD_DEPS:-} \ ; rm -rf /var/lib/apt/lists/*; \ \ # install ovdashboard_api python3 -m pip --no-cache-dir install ./; \ \ # remove buildtime dependencies apt-get autoremove --yes --purge ${BUILD_DEPS:-}; # add prepared ovdashboard_ui COPY --from=build-ui /tmp/ovdashboard_ui /usr/local/share/ovdashboard_ui # run as unprivileged user USER nobody