Dockerfile best practices

This commit is contained in:
Jörn-Michael Miehe 2023-09-18 21:03:38 +02:00
parent 126feaacdd
commit 411d1492f4

View file

@ -6,11 +6,11 @@ FROM node:lts AS build-ui
WORKDIR /usr/local/src/advent22_ui
# install dependencies
COPY ui/package*.json ui/yarn*.lock .
COPY ui/package*.json ui/yarn*.lock ./
RUN yarn install --production false
# copy and build full ui
COPY ui .
COPY ui ./
RUN yarn build --dest /tmp/advent22_ui/html
###########
@ -23,12 +23,17 @@ WORKDIR /usr/local/src/advent22_api
# env setup
ENV \
PRODUCTION_MODE="true" \
APP_MODULE="advent22_api.app:app"
MODULE_NAME="advent22_api.app"
# install api
COPY api .
RUN python -m pip --no-cache-dir install .
COPY api ./
RUN set -ex; \
rm -rf /app; \
\
python -m pip --no-cache-dir install ./
# add prebuilt ui
COPY --from=build-ui /tmp/advent22_ui /usr/local/share/advent22_ui
# run as unprivileged user
USER nobody