# Repo explorer + document host for the Property Ontology.
# Build context is the repository root so the whole repo is available to browse.
FROM node:22-alpine AS deps
WORKDIR /app/explorer
COPY explorer/package.json explorer/package-lock.json* ./
RUN npm ci --omit=dev --no-audit --no-fund

FROM node:22-alpine
ENV NODE_ENV=production \
    REPO_ROOT=/repo \
    PORT=3000
WORKDIR /app/explorer
COPY --from=deps /app/explorer/node_modules ./node_modules
COPY explorer/ ./
# The browsable repository (excludes .git, .env*, node_modules via .dockerignore)
COPY . /repo
RUN rm -rf /repo/explorer/node_modules
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
  CMD wget -qO- http://127.0.0.1:${PORT}/healthz || exit 1
CMD ["node", "server.js"]
