ovdashboard/Dockerfile

45 lines
857 B
Docker
Raw Normal View History

2022-09-19 22:55:52 +00:00
############
# build ui #
############
2023-10-26 22:46:43 +00:00
FROM node:20.8 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
2023-10-26 16:28:00 +00:00
###########
# web app #
###########
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
FROM tiangolo/uvicorn-gunicorn:python3.12-slim AS production
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
# add prepared ovdashboard_ui
COPY --from=build-ui /tmp/ovdashboard_ui /usr/local/share/ovdashboard_ui
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
# install ovdashboard_api
COPY api ./
2022-09-19 22:55:52 +00:00
RUN set -ex; \
2023-10-26 16:28:00 +00:00
# remove example app
rm -rf /app; \
\
python -m pip --no-cache-dir install ./
2022-09-19 22:55:52 +00:00
2023-10-26 16:28:00 +00:00
# run as unprivileged user
USER nobody