ovdashboard/Dockerfile

73 lines
1.5 KiB
Docker
Raw Normal View History

2022-09-19 22:55:52 +00:00
############
# build ui #
############
2023-11-09 11:40:10 +00:00
ARG NODE_VERSION=lts
ARG PYTHON_VERSION=3.12-slim
2023-11-09 11:40:10 +00:00
FROM node:${NODE_VERSION} AS build-ui
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
# env setup
WORKDIR /usr/local/src/ovdashboard_ui
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
# install ovdashboard_ui dependencies
2022-09-19 22:55:52 +00:00
COPY ui/package*.json ui/yarn*.lock ./
2023-10-26 16:28:00 +00:00
RUN yarn install --production false
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
# copy and build ovdashboard_ui
COPY ui ./
RUN yarn build --dest /tmp/ovdashboard_ui/html
2022-09-19 22:55:52 +00:00
######################
# 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
2023-11-15 14:15:31 +00:00
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"]
2023-10-26 16:28:00 +00:00
###########
# web app #
###########
2022-09-19 22:55:52 +00:00
FROM uvicorn-gunicorn AS production
2022-09-19 22:55:52 +00:00
# env setup
2023-10-26 16:28:00 +00:00
WORKDIR /usr/local/src/ovdashboard_api
ENV \
2022-09-19 22:55:52 +00:00
PRODUCTION_MODE="true" \
2023-10-26 16:28:00 +00:00
PORT="8000" \
MODULE_NAME="ovdashboard_api.app"
EXPOSE 8000
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
COPY api ./
2022-09-19 22:55:52 +00:00
RUN set -ex; \
# install libs
export DEBIAN_FRONTEND=noninteractive; \
apt-get update; apt-get install --yes --no-install-recommends \
libmagic1 \
# need to build hiredis
gcc \
libc-dev \
; rm -rf /var/lib/apt/lists/*; \
\
# install ovdashboard_api
python3 -m pip --no-cache-dir install ./
2022-09-19 22:55:52 +00:00
2023-11-09 11:40:10 +00:00
# add prepared ovdashboard_ui
COPY --from=build-ui /tmp/ovdashboard_ui /usr/local/share/ovdashboard_ui
2023-10-26 16:28:00 +00:00
# run as unprivileged user
USER nobody