2023-09-18 18:16:34 +00:00
|
|
|
############
|
|
|
|
# build ui #
|
|
|
|
############
|
2023-09-16 21:57:19 +00:00
|
|
|
|
2023-09-20 17:03:24 +00:00
|
|
|
FROM node:18.16 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 #
|
|
|
|
###########
|
|
|
|
|
|
|
|
FROM tiangolo/uvicorn-gunicorn:python3.11-slim AS production
|
|
|
|
|
|
|
|
# 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-09-19 16:00:31 +00:00
|
|
|
# add prepared advent22_ui
|
2023-09-18 18:16:34 +00:00
|
|
|
COPY --from=build-ui /tmp/advent22_ui /usr/local/share/advent22_ui
|
2023-09-16 21:57:19 +00:00
|
|
|
|
2023-09-18 19:03:38 +00:00
|
|
|
# run as unprivileged user
|
|
|
|
USER nobody
|