# Development only. Not for production use.
FROM node:24-slim

# slim carries no trust store and workerd reads the system one
RUN apt-get update \
  && apt-get install -y --no-install-recommends ca-certificates \
  && rm -rf /var/lib/apt/lists/*

COPY <<'EOF' /usr/local/bin/camo-entrypoint.sh
#!/bin/sh
set -eu
if [ -f /caddy-ca/root.crt ]; then
  cp /caddy-ca/root.crt /usr/local/share/ca-certificates/caddy-dev.crt
  update-ca-certificates >/dev/null
fi
npm ci --no-audit --no-fund
exec npx wrangler dev --ip 0.0.0.0 --port 8787 \
  --var "CAMO_SHARED_SECRET:${CAMO_SHARED_SECRET}"
EOF
RUN chmod +x /usr/local/bin/camo-entrypoint.sh

WORKDIR /src

EXPOSE 8787

ENTRYPOINT ["/usr/local/bin/camo-entrypoint.sh"]
