Files
sales-trainer/Dockerfile
Macky bdd7c44dbe fix(Dockerfile): build frontend without NODE_ENV=production (npm skips devDeps like vite -> 'vite: not found')
Root cause of EasyPanel build failure: ENV NODE_ENV=production was set before 'npm install',
so npm skipped devDependencies (vite, @vitejs/plugin-vue) and 'npm run build' had no vite.
Fix: remove the early NODE_ENV=production (devDeps install for the build), use 'npm ci'
(deterministic, falls back to npm install). NODE_ENV only matters for Flask runtime which is set
at the CMD stage.
2026-08-07 19:27:36 +07:00

32 lines
981 B
Docker

# Sales Trainer — single-container build (Vue frontend built + served by Flask)
FROM python:3.11-slim AS backend
# Node 20 for building the Vue frontend
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/*
WORKDIR /app
# 1) Build frontend (devDeps incl. vite are required to build;
# NODE_ENV must NOT be production yet or npm skips devDependencies)
COPY frontend/package.json frontend/package-lock.json* ./frontend/
RUN cd frontend && npm ci || npm install
COPY frontend/ ./frontend/
RUN cd frontend && npm run build
# 2) Install backend deps
COPY backend/requirements.txt ./backend/
RUN pip install --no-cache-dir -r backend/requirements.txt
# 3) Copy backend source
COPY backend/ ./backend/
# Run
WORKDIR /app/backend
ENV FLASK_DEBUG=0
EXPOSE 5001
CMD ["python", "run.py"]