# The CameraRisk monitor in a container: Node.js 22 on Alpine, running as the unprivileged "node"
# user. The config (this monitor's pairing and your cameras, passwords included) lives in the
# /config volume, never in the image.
#
#   docker build -f camerarisk-agent.Dockerfile -t camerarisk-agent .
#   docker run --rm -it -v camerarisk-agent:/config camerarisk-agent pair ABCD-EFGH
#   docker run --rm -it -v camerarisk-agent:/config camerarisk-agent add
#   docker run -d --name camerarisk-agent --restart unless-stopped -v camerarisk-agent:/config camerarisk-agent
#
# Cameras with .local names: mDNS does not reach Docker's default network. Use the camera's IP
# address, or add --network host to the docker run commands.
FROM node:22-alpine
WORKDIR /app
COPY camerarisk-agent.mjs /app/camerarisk-agent.mjs
RUN mkdir -p /config && chown node:node /config && chmod 700 /config
USER node
ENV CAMERARISK_CONFIG=/config/agent.json
VOLUME /config
ENTRYPOINT ["node", "/app/camerarisk-agent.mjs"]
CMD ["run"]
