anycable_rails_demo icon indicating copy to clipboard operation
anycable_rails_demo copied to clipboard

Kamal 2 w/ multiple gRPC servers

Open prog-supdex opened this issue 7 months ago • 2 comments

Purpose

Add multi‑host deployment of AnyCable Rails Demo with:

  • Horizontal scaling of Rails web, AnyCable RPC, and AnyCable‑Go processes across multiple hosts
  • Static RPC list (grpc-list://)
  • Centralized configuration via .env and Kamal secrets

Changes

  • Multi‑stage Docker build

  • Kamal 2 deployment

    • config/deploy.yml declares web, rpc, anycable‑go, db, and redis roles/accessories
    • .kamal/hooks/pre-app-boot stops existing rpc containers to avoid port collisions
    • .kamal/secrets.sample maps RAILS_MASTER_KEY, POSTGRES_PASSWORD, DATABASE_URL, and REDIS_PASSWORD
  • Environment management

    • Added .env.sample listing all parameters
    • Added gem dotenv to load .env in deploy.yml
  • Entrypoint script (bin/docker-entrypoint)

    • Automatically runs rails db:prepare on server start
  • Healthcheck endpoint

    • GET /up returns HTTP 200 for Kamal’s proxy health checks

This also leverages AnyCable Go 1.6.2’s grpc-list:// feature to pass a static list of RPC endpoints

Setup and Deploy:

  1. Copy and fill samples
cp .env.sample .env
cp .kamal/secrets.sample .kamal/secrets
# Fill in all values (.env, .kamal/secrets)
  1. Local dev (Docker Compose)
dip provision
dip up web
  1. Production (Kamal)
kamal setup # or kamal deploy after the setup

prog-supdex avatar May 28 '25 12:05 prog-supdex

If I do t need massive scale, and just want to reliably use actioncable in a chrome extension, do I need production any cable, or should I be good with a kamal accessory?

adenta avatar Jun 28 '25 00:06 adenta

Hey @adenta,

It sounds like in your case using AnyCable Thruster could be the simplest option. Check it out.

Do you use AnyCable RPC? You may also consider running it in the embedded mode or via HTTP, so no additional services required.

palkan avatar Jun 28 '25 00:06 palkan