# Gitea Code Review service.
#
# OCR is invoked as a subprocess from the app container, so the image ships
# Node.js, git (>= 2.41, required by OpenCodeReview) and the ocr CLI itself.
FROM node:22-trixie-slim

ARG OCR_VERSION=1.12.7

ENV DEBIAN_FRONTEND=noninteractive \
    NODE_ENV=production \
    CR_DATA_DIR=/data \
    CR_HOST=0.0.0.0 \
    CR_PORT=8090

RUN apt-get update \
 && apt-get install -y --no-install-recommends git ca-certificates tini \
 && rm -rf /var/lib/apt/lists/* \
 && git --version \
 && npm install -g "@alibaba-group/open-code-review@${OCR_VERSION}" \
 && ocr version

WORKDIR /app
COPY package.json ./
COPY app ./app

RUN mkdir -p /data

EXPOSE 8090
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["node", "app/server.js"]