diff --git a/Dockerfile b/Dockerfile index d6c04a2..d51bcd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,12 +24,22 @@ FROM node:20-slim AS frontendbuild WORKDIR /build # Copy only the manifests first so `npm ci` caches on dependency changes. -COPY frontend/package*.json ./ -RUN npm ci +COPY frontend/package*.json ./frontend/ +RUN cd frontend && npm ci -COPY frontend/ ./ -RUN npm run build -# Output lands in /build/dist (Vite default), copied into the final stage below. +# The frontend keeps its repo-relative layout here, because npm prebuild runs +# `node ../scripts/stage-frontend.mjs`, which stages each plugin's frontend/ into +# the Vite tree and codegens routes.gen.js. That script resolves its repo root as +# its own directory's parent, so it needs scripts/ and plugins/ as SIBLINGS of +# frontend/. Building with frontend/ flattened to the stage root made `../scripts` +# resolve to /scripts and the build failed on a missing module. +COPY scripts/stage-frontend.mjs ./scripts/ +COPY plugins/ ./plugins/ + +COPY frontend/ ./frontend/ +RUN cd frontend && npm run build +# Output lands in /build/frontend/dist (Vite default), copied into the final +# stage below. # ---- Stage 2: Python application image ---- FROM python:3.14-slim AS base @@ -60,7 +70,7 @@ COPY scripts/ ./scripts/ COPY wsgi.py ./ # Built SPA from stage 1. Flask serves it via register_frontend_routes. -COPY --from=frontendbuild /build/dist ./frontend/dist +COPY --from=frontendbuild /build/frontend/dist ./frontend/dist RUN useradd --create-home --shell /bin/bash shopdb \ && chown -R shopdb:shopdb /app