Skip to content

Kamal 2 w/ multiple gRPC servers#39

Draft
prog-supdex wants to merge 1 commit intoanycable:masterfrom
prog-supdex:feat/kamal-deploy
Draft

Kamal 2 w/ multiple gRPC servers#39
prog-supdex wants to merge 1 commit intoanycable:masterfrom
prog-supdex:feat/kamal-deploy

Conversation

@prog-supdex
Copy link
Copy Markdown

@prog-supdex prog-supdex commented May 28, 2025

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 prog-supdex force-pushed the feat/kamal-deploy branch 2 times, most recently from f2f379a to b673572 Compare May 28, 2025 12:49
Comment thread .dockerdev/Dockerfile Outdated
Comment on lines +67 to +72
COPY Gemfile Gemfile.lock ./
RUN gem update --system --quiet && \
gem install --no-document bundler && \
bundle install --jobs 4 --retry 3

FROM gems AS dev
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to run bundle install in development when building a container; that happens later and uses volumes. Only gem update is required.

See the example multi-env Dockerfile: https://evilmartians.com/chronicles/ruby-on-whales-docker-for-ruby-rails-development#from-development-to-production

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done!

@prog-supdex prog-supdex force-pushed the feat/kamal-deploy branch 4 times, most recently from ce3451d to bccaaea Compare June 2, 2025 10:00
@palkan palkan changed the title support kamal 2 deployment Kamal 2 w/ multiple gRPC servers Jun 28, 2025
@palkan palkan added the demo Demo branch PR label Jun 28, 2025
@palkan palkan marked this pull request as draft June 28, 2025 00:34
@palkan palkan mentioned this pull request Jun 28, 2025
3 tasks
@adenta
Copy link
Copy Markdown

adenta commented Jun 28, 2025

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?

@palkan
Copy link
Copy Markdown
Member

palkan commented Jun 28, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

demo Demo branch PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants