# One process, one owner. Node runs the TypeScript directly; there is no build step.
FROM node:24-slim
WORKDIR /app
ENV NODE_ENV=production
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
COPY src ./src
COPY web ./web
RUN mkdir -p /data && chown node:node /data
USER node
# Inside the container it listens on every interface; publish the port to 127.0.0.1 only (see compose.yaml).
ENV HOST=0.0.0.0 PORT=4747 RESOLUTION_DATA=/data
VOLUME ["/data"]
EXPOSE 4747
HEALTHCHECK --interval=30s --timeout=5s CMD node -e "fetch('http://127.0.0.1:4747/healthz').then(r=>process.exit(r.status<500?0:1)).catch(()=>process.exit(1))"
CMD ["node", "src/main.ts"]
