Skip to main content

Deployment

PieceWhere it runsSourceHow it ships
ProgramSolana devnet, FbXiX6xcMRPVuTc7AZkQMSbpKa1uBzQY16NFf5jhJC7hmagic-chess-program/Manual anchor deploy
Frontend (ZUG Arena)Cloudflare Worker at playzug.xyzfrontend/Cloudflare Workers Builds on push
BackendRender at api.playzug.xyz (magic-chess-dev.onrender.com)backend/Render deploy on push
DatabaseSupabase Postgresbackend/src/db/migrate.tsMigrations run at backend start (RUN_MIGRATIONS_ON_START)
DocsGitHub Pagesdocs/.github/workflows/deploy-docs.yml on push to dev

Program​

cd magic-chess-program
cargo build-sbf --tools-version v1.52 # v1.52 works on macOS 12
solana config set --url devnet
anchor deploy --provider.cluster devnet
anchor idl upgrade --provider.cluster devnet \
--filepath target/idl/magic_chess.json FbXiX6xcMRPVuTc7AZkQMSbpKa1uBzQY16NFf5jhJC7h

# Ship the new IDL to the SDK and frontend
cd ../sdk && npm run sync-idl

An upgrade needs the upgrade authority keypair. DEPLOY.md in the repo root covers Surfpool, devnet, MagicBlock and troubleshooting in detail.

warning

Keypairs (*-keypair.json) are gitignored. Never commit them.

Frontend​

The frontend is a static Next.js export served by a Cloudflare Worker.

SettingValue
Root directoryfrontend/
Build commandnpm run build
Deploy commandnpx wrangler deploy
Configfrontend/wrangler.toml

Public settings (NEXT_PUBLIC_*, such as the API URL, Privy app ID and RPC endpoints) are in the [vars] block of wrangler.toml. They are baked in at build time, so a change needs a rebuild. The worker also redirects old /play/<id> links to /play?id=<id>.

Backend​

The backend is a Fastify service on Render.

SettingValue
Root directorybackend/
Build commandnpm ci && npm run build
Start commandnpm start
Health checkGET /health

The required environment variables are listed in backend/.env.example and in Backend → Configuration:

  • the database URL
  • RPC_ENDPOINT (use a dedicated devnet RPC; the public one rate-limits)
  • Privy app ID and verification key
  • sponsor keypair
  • CORS_ORIGIN

On Render's free tier the service sleeps when idle. The frontend tolerates a cold backend, but the first request after a sleep is slow.

Docs​

cd docs
npm ci
npm run build # fails on broken links
npm run serve

A push to dev that touches docs/ builds and publishes to https://docs.playzug.xyz/.