advent22/Dockerfile

40 lines
738 B
Docker
Raw Normal View History

2023-09-18 18:16:34 +00:00
############
# build ui #
############
2023-09-16 21:57:19 +00:00
2023-09-18 18:16:34 +00:00
FROM node:lts AS build-ui
WORKDIR /usr/local/src/advent22_ui
2023-09-16 21:57:19 +00:00
2023-09-18 18:16:34 +00:00
# install 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
# copy and build full 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
WORKDIR /usr/local/src/advent22_api
# env setup
2023-09-16 21:57:19 +00:00
ENV \
2023-09-18 18:16:34 +00:00
PRODUCTION_MODE="true" \
2023-09-18 19:03:38 +00:00
MODULE_NAME="advent22_api.app"
2023-09-18 18:16:34 +00:00
# install api
2023-09-18 19:03:38 +00:00
COPY api ./
RUN set -ex; \
rm -rf /app; \
\
python -m pip --no-cache-dir install ./
2023-09-16 21:57:19 +00:00
2023-09-18 18:16:34 +00:00
# add prebuilt ui
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