# NeonSpace runtime: Node monitor + nginx. No npm packages; only system tools.
# ffmpeg grabs single camera frames from video streams when a camera's snapshot page is broken.
FROM node:22-slim
RUN apt-get update \
    && apt-get install -y --no-install-recommends nginx iputils-ping iproute2 ca-certificates ffmpeg \
    && rm -rf /var/lib/apt/lists/* /etc/nginx/sites-enabled/default
WORKDIR /app

COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
# Compose bind-mounts the project over /app; these copies let the image run alone too.
COPY server/ ./server/
COPY public/ ./public/

EXPOSE 8086

HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
  CMD node -e "fetch('http://127.0.0.1:8086/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"

ENTRYPOINT ["node", "/app/server/entrypoint.mjs"]
