43 lines
1.2 KiB
Docker
43 lines
1.2 KiB
Docker
# Stage 1: build the Vue frontend (frontend/dist is the only output
|
|
# carried into the final image).
|
|
FROM node:20-slim AS frontend-build
|
|
WORKDIR /frontend
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
RUN npm install
|
|
COPY frontend/ .
|
|
RUN npm run build
|
|
|
|
# Stage 2: the Python backend, serving the built frontend as static files.
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
curl \
|
|
tesseract-ocr \
|
|
libtesseract-dev \
|
|
libleptonica-dev \
|
|
pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# tesserocr doesn't reliably auto-discover Debian's tessdata location -
|
|
# confirmed for real: "Failed to init API, possibly an invalid tessdata
|
|
# path: ./" without this set explicitly.
|
|
ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Only backend/ and the built frontend are copied in - fixtures/docs/
|
|
# results/measure.py's own corpus aren't needed at runtime (measure.py
|
|
# is a dev-time verification tool, run from the repo root, not part of
|
|
# the deployed image's own behavior).
|
|
COPY backend/ backend/
|
|
COPY --from=frontend-build /frontend/dist frontend/dist
|
|
|
|
RUN mkdir -p /app/uploads
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["python", "backend/app.py"]
|