# Build backend wheels FROM python:3.9 AS builder WORKDIR /wheels # Update pip & build the wheels COPY ./setup.cfg ./ RUN pip wheel -e . # Build frontend FROM node:16 AS fbuilder # Copy source code WORKDIR /usr/src/app COPY ./web ./web COPY Makefile . # Build frontend RUN make fbuild FROM python:3.9-slim # Switch to non-root user RUN groupadd -r runner && \ useradd -mrg runner runner # Install the generated wheels COPY --from=builder /wheels /wheels RUN pip install \ --no-cache-dir \ --no-warn-script-location \ -f /wheels \ -e /wheels && \ rm -rf /wheels # Switch to non-root user USER runner # Copy source files WORKDIR /usr/src/app COPY --chown=runner:runner ./app ./app COPY --chown=runner:runner setup.cfg setup.py ./ # Copy frontend build COPY \ --from=fbuilder \ --chown=runner:runner \ /usr/src/app/web/dist ./dist ENTRYPOINT ["python"] CMD ["app"]