fix(Docker): ship prebuilt frontend/dist, drop npm from image (removes 'vite not found')
The Vue SPA is now built locally and its frontend/dist/ committed (force-added). Dockerfile is a single-stage runtime: copy prebuilt dist + python:3.11 + Flask. No node/npm inside the image -> deterministic, no npm/esbuild postinstall flakiness. To update UI: edit src, npm run build, commit frontend/dist/.
This commit is contained in:
26
Dockerfile
26
Dockerfile
@@ -1,27 +1,29 @@
|
||||
# Sales Trainer — single-container build (Vue frontend built + served by Flask)
|
||||
FROM python:3.11-slim AS backend
|
||||
# Sales Trainer — single-container runtime (Python 3.11 + Flask)
|
||||
#
|
||||
# The Vue frontend is BUILT LOCALLY (`cd frontend && npm run build`) and the
|
||||
# resulting `frontend/dist/` is committed to the repo. This image does NOT run
|
||||
# npm/node at all — it just copies the prebuilt SPA and serves it via Flask.
|
||||
# This eliminates `vite: not found` / npm postinstall flakiness from the build.
|
||||
#
|
||||
# To update the UI: edit frontend/src, run `npm run build` locally, commit dist/.
|
||||
|
||||
# Node 20 for building the Vue frontend
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Runtime deps (none required beyond Python + pip packages; curl for healthcheck)
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
|
||||
# 1) Build frontend
|
||||
COPY frontend/package.json frontend/package-lock.json* ./frontend/
|
||||
RUN cd frontend && npm install
|
||||
COPY frontend/ ./frontend/
|
||||
RUN cd frontend && npm run build
|
||||
# 1) Copy prebuilt frontend SPA (built locally, committed to repo)
|
||||
COPY frontend/dist/ ./frontend/dist/
|
||||
|
||||
# 2) Install backend deps
|
||||
COPY backend/requirements.txt ./backend/
|
||||
RUN pip install --no-cache-dir -r backend/requirements.txt
|
||||
|
||||
# 3) Copy backend source
|
||||
# 3) Copy backend source (and stub frontend dir so static serving finds dist)
|
||||
COPY backend/ ./backend/
|
||||
|
||||
# Run
|
||||
|
||||
Reference in New Issue
Block a user