FROM node:20-bookworm-slim
WORKDIR /usr/src/app

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        poppler-utils \
        tesseract-ocr \
        tesseract-ocr-deu \
        tesseract-ocr-eng \
    && rm -rf /var/lib/apt/lists/*

# Package-Dateien
COPY package*.json ./

# Dev + Prod Dependencies (für TS-Build nötig)
RUN npm install

# Restlicher Sourcecode
COPY . .

# TypeScript Build
RUN npm run build

# Port freigeben
EXPOSE 3100

# Migrationen ausführen und App starten
CMD ["sh", "./docker-entrypoint.sh"]
