World is Flat hackathon eligibility requires using $wif onchain on Robinhood Chain; the existing integration only proved testnet Mock-USDC. Adds a real robinhoodWif registry entry (18-decimal $wif, contract and chain id verified live via eth_call), a Permit2 facilitator asset entry, and a ready-to-run LIVE=1-gated mainnet settlement proof script (scripts/wif-mainnet-proof.ts) with a safe default SIMULATE mode (no funds, no key) smoke-tested against the live chain. Also diagnoses and partially fixes settlekit-api.onrender.com timing out: neither the migration client nor the app's DB connection set a connect_timeout, so a stale DATABASE_URL hung boot indefinitely, and the Dockerfile CMD's `&&` meant a migration failure blocked the server from even starting. Adds a bounded default timeout and decouples server start from migration success so failures are fast and visible instead of silent. packages/chains + packages/x402-facilitator: 194/194 tests pass (registry invariants updated for the two intentional exceptions: $wif=18 decimals, robinhoodWif is mainnet-only). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
62 lines
2.8 KiB
Docker
62 lines
2.8 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# Multi-stage build for the SettleKit API (@settlekit/api).
|
|
# Build context is the monorepo root: `docker build -f apps/api/Dockerfile .`
|
|
|
|
# ---- Base: Node 22 + pnpm via Corepack -------------------------------------
|
|
FROM node:22-alpine AS base
|
|
ENV PNPM_HOME=/pnpm
|
|
ENV PATH=$PNPM_HOME:$PATH
|
|
# Non-interactive build: lets the prod-deps `pnpm install --prod` purge the
|
|
# modules dir without a TTY prompt (ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY).
|
|
ENV CI=true
|
|
RUN corepack enable
|
|
WORKDIR /app
|
|
|
|
# ---- Dependencies: install only the api and its workspace deps (frozen) ----
|
|
FROM base AS deps
|
|
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml tsconfig.base.json ./
|
|
COPY packages ./packages
|
|
COPY apps ./apps
|
|
RUN pnpm install --frozen-lockfile --filter settlekit --filter "@settlekit/api..."
|
|
|
|
# ---- Build: compile package deps + the api via tsc project references ------
|
|
FROM deps AS build
|
|
# `tsc -b` on the api walks its referenced packages and builds them in order.
|
|
RUN pnpm --filter @settlekit/api... build
|
|
|
|
# ---- Production deps: prune dev dependencies -------------------------------
|
|
FROM build AS prod-deps
|
|
RUN pnpm --filter @settlekit/api... install --prod --frozen-lockfile
|
|
|
|
# ---- Runtime: ship dist + production node_modules --------------------------
|
|
FROM base AS runtime
|
|
ENV NODE_ENV=production
|
|
ENV PORT=8787
|
|
WORKDIR /app
|
|
|
|
# Workspace metadata so pnpm can resolve the workspace symlinks at runtime.
|
|
COPY --from=build /app/package.json /app/pnpm-workspace.yaml ./
|
|
COPY --from=prod-deps /app/node_modules ./node_modules
|
|
|
|
# Built output + production deps for every package the api depends on.
|
|
COPY --from=build /app/packages ./packages
|
|
COPY --from=prod-deps /app/packages ./packages
|
|
COPY --from=build /app/apps/api/dist ./apps/api/dist
|
|
COPY --from=build /app/apps/api/package.json ./apps/api/package.json
|
|
COPY --from=prod-deps /app/apps/api/node_modules ./apps/api/node_modules
|
|
|
|
WORKDIR /app/apps/api
|
|
EXPOSE 8787
|
|
# Apply pending migrations (idempotent), then serve. Render's preDeployCommand
|
|
# is paid-plan only, so the free API migrates on boot.
|
|
#
|
|
# The migration step is `||`, not `&&`: found 2026-11-10 that a stale/
|
|
# unreachable DATABASE_URL made migration hang (now bounded by
|
|
# packages/database's DEFAULT_CONNECT_TIMEOUT_SECONDS) and, with the old
|
|
# `&&` chain, a migration failure meant the server was never even attempted
|
|
# — one bad DB env var took down the whole container, including endpoints
|
|
# that don't need the database. Now the server always starts and reports
|
|
# its own real DB-connectivity error (fast, bounded, visible in logs)
|
|
# instead of the whole boot silently never finishing.
|
|
CMD ["sh", "-c", "if [ -n \"$DATABASE_URL\" ]; then node /app/packages/database/dist/cli.js || echo '[migrate] failed or timed out — starting the server anyway so non-DB endpoints still serve'; fi; exec node dist/server.js"]
|