53 lines
1.1 KiB
Docker
53 lines
1.1 KiB
Docker
############
|
|
# 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
|
|
|
|
###########
|
|
# web app #
|
|
###########
|
|
|
|
ARG PYTHON_VERSION
|
|
FROM tiangolo/uvicorn-gunicorn:python${PYTHON_VERSION} 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; \
|
|
# install libs
|
|
export DEBIAN_FRONTEND=noninteractive; \
|
|
apt-get update; apt-get install --yes --no-install-recommends \
|
|
libmagic1 \
|
|
; rm -rf /var/lib/apt/lists/*; \
|
|
\
|
|
# remove example app
|
|
rm -rf /app; \
|
|
\
|
|
# install ovdashboard_api
|
|
python -m pip --no-cache-dir install ./
|
|
|
|
# add prepared ovdashboard_ui
|
|
COPY --from=build-ui /tmp/ovdashboard_ui /usr/local/share/ovdashboard_ui
|
|
|
|
# run as unprivileged user
|
|
USER nobody
|