69 lines
1.5 KiB
Docker
69 lines
1.5 KiB
Docker
############
|
|
# build ui #
|
|
############
|
|
|
|
ARG NODE_VERSION=lts
|
|
ARG PYTHON_VERSION=3.12
|
|
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 <tiangolo@gmail.com>"
|
|
WORKDIR /usr/local/share/uvicorn-gunicorn
|
|
|
|
# install uvicorn-gunicorn
|
|
COPY "./install/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; \
|
|
# install libs
|
|
export DEBIAN_FRONTEND=noninteractive; \
|
|
apt-get update; apt-get install --yes --no-install-recommends \
|
|
libmagic1 \
|
|
; rm -rf /var/lib/apt/lists/*; \
|
|
\
|
|
# install ovdashboard_api
|
|
python3 -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
|