2023-09-18 18:16:34 +00:00
|
|
|
############
|
|
|
|
# build ui #
|
|
|
|
############
|
2023-09-16 21:57:19 +00:00
|
|
|
|
2024-11-26 13:58:02 +00:00
|
|
|
ARG NODE_VERSION=18.18
|
2023-10-27 15:42:11 +00:00
|
|
|
ARG PYTHON_VERSION=3.11-slim
|
2023-10-27 15:10:25 +00:00
|
|
|
FROM node:${NODE_VERSION} AS build-ui
|
2023-09-19 16:00:31 +00:00
|
|
|
|
|
|
|
# env setup
|
2023-09-18 18:16:34 +00:00
|
|
|
WORKDIR /usr/local/src/advent22_ui
|
2023-09-16 21:57:19 +00:00
|
|
|
|
2023-09-19 16:00:31 +00:00
|
|
|
# install advent22_ui dependencies
|
2023-09-18 19:03:38 +00:00
|
|
|
COPY ui/package*.json ui/yarn*.lock ./
|
2023-09-18 18:16:34 +00:00
|
|
|
RUN yarn install --production false
|
|
|
|
|
2023-09-19 16:00:31 +00:00
|
|
|
# copy and build advent22_ui
|
2023-09-18 19:03:38 +00:00
|
|
|
COPY ui ./
|
2023-09-18 18:16:34 +00:00
|
|
|
RUN yarn build --dest /tmp/advent22_ui/html
|
|
|
|
|
|
|
|
###########
|
|
|
|
# web app #
|
|
|
|
###########
|
|
|
|
|
2023-10-27 15:42:11 +00:00
|
|
|
ARG PYTHON_VERSION
|
|
|
|
FROM tiangolo/uvicorn-gunicorn:python${PYTHON_VERSION} AS production
|
2023-09-18 18:16:34 +00:00
|
|
|
|
|
|
|
# env setup
|
2023-09-19 16:00:31 +00:00
|
|
|
WORKDIR /usr/local/src/advent22_api
|
2023-09-16 21:57:19 +00:00
|
|
|
ENV \
|
2023-09-18 18:16:34 +00:00
|
|
|
PRODUCTION_MODE="true" \
|
2023-09-19 16:00:31 +00:00
|
|
|
PORT="8000" \
|
2023-09-18 19:03:38 +00:00
|
|
|
MODULE_NAME="advent22_api.app"
|
2023-09-19 16:00:31 +00:00
|
|
|
EXPOSE 8000
|
2023-09-18 18:16:34 +00:00
|
|
|
|
2023-09-19 16:00:31 +00:00
|
|
|
# install advent22_api
|
2023-09-18 19:03:38 +00:00
|
|
|
COPY api ./
|
|
|
|
RUN set -ex; \
|
2023-09-19 16:00:31 +00:00
|
|
|
# remove example app
|
2023-09-18 19:03:38 +00:00
|
|
|
rm -rf /app; \
|
|
|
|
\
|
|
|
|
python -m pip --no-cache-dir install ./
|
2023-09-16 21:57:19 +00:00
|
|
|
|
2023-10-29 16:28:34 +00:00
|
|
|
# add prepared advent22_ui
|
|
|
|
COPY --from=build-ui /tmp/advent22_ui /usr/local/share/advent22_ui
|
|
|
|
|
2023-09-18 19:03:38 +00:00
|
|
|
# run as unprivileged user
|
|
|
|
USER nobody
|