cred402/infra/Dockerfile
caelum0x 7fdc321d79 feat: live-wire Casper writes, add marketing homepage, fix cold-start UX
Round 1 against STRATEGY-2026-10-23.md's backlog:

- Wire register_agent/stake/set_credit_score/deposit_liquidity to the real
  Casper Testnet contracts (lib/casper/live_bridge.ts), verified live against
  the real RPC node with a freshly generated (unfunded) keypair
  (npm run casper:keygen). Honesty flags built in for the Odra payable
  calling convention and the admin-gated set_credit_score call.
- Unblock NEAR's paid x402 route (npm run near:keygen generates a real
  implicit account id); QIE stays correctly flagged as blocked on unconfirmed
  external facts (asset contract, facilitator), not env plumbing.
- New public Home tab: live-stats hero, how-it-works, a real competitor
  comparison table, and a "90-second proof" that calls the real API live in
  the browser (verified end-to-end with gstack browse).
- Cold-start UX: visible retry state in X402Playground + the TS SDK, plus a
  keep-warm self-ping (lib/services/keepalive.ts) so the free Render dyno
  rarely idles out from under a real first-time caller.
- New GET /v1/credit-score/:agentId alias + docs/integrations/ samples for
  Skyfire/Nevermined/Coinbase x402.
- Self-hosting quickstart: root docker-compose.yml + scripts/bootstrap.sh,
  both run for real; fixed a real EACCES crash-loop bug in infra/Dockerfile
  (non-root user never owned the /data volume mount) found while verifying.

450/450 tests pass, typecheck clean, frontend build clean.
2026-10-23 19:57:40 +03:00

40 lines
1.4 KiB
Docker

# Cred402 API + console — multi-stage production image.
# Stage 1 builds the React console; stage 2 runs the zero-extra-dep Node API
# (tsx) serving the built dashboard and the /api + /v1 surfaces.
FROM node:20-bookworm-slim AS frontend
WORKDIR /app
COPY package.json package-lock.json* ./
COPY frontend/package.json frontend/
RUN npm install --no-audit --no-fund \
&& cd frontend && npm install --no-audit --no-fund
COPY . .
RUN cd frontend && npm run build
FROM node:20-bookworm-slim AS runtime
ENV NODE_ENV=production
WORKDIR /app
# Non-root runtime user.
RUN useradd --no-create-home --uid 10001 cred402
COPY --from=frontend /app /app
# /data is where CRED402_DATA_DIR writes (event journal, payment-attempt
# stores, etc.) — it must be owned by the runtime user BEFORE the volume is
# mounted, or every write fails EACCES the moment a volume (named or bind)
# is attached at this mount point, since Docker otherwise creates it root:root.
RUN mkdir -p /data && chown -R cred402:cred402 /app /data
USER cred402
EXPOSE 4021
ENV CRED402_PORT=4021 \
CRED402_ENV=testnet \
CRED402_LOG_LEVEL=info \
CRED402_AUTH_REQUIRED=true \
CRED402_DATA_DIR=/data
VOLUME ["/data"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD node -e "fetch('http://localhost:'+(process.env.CRED402_PORT||4021)+'/v1/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
CMD ["npx", "tsx", "api/server.ts"]