FROM node:20-alpine
LABEL org.opencontainers.image.title="Homestead Free"
LABEL org.opencontainers.image.version="0.6.8.31"

RUN apk add --no-cache \
    ffmpeg \
    libheif-tools \
    tesseract-ocr \
    tesseract-ocr-data-eng \
    unzip

WORKDIR /app

COPY package*.json ./

RUN npm ci

COPY . .

RUN npm run build

EXPOSE 7312

HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
  CMD node -e "fetch('http://127.0.0.1:7312/api/platform').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"

CMD ["node", "server.cjs"]
