Skip to content
Scalpels home

Sign up now for $10 in credit on a new Laravel Cloud account.

Experiment

We ran Campfire on Laravel Cloud

· Ed Grosvenor

It works. Campfire is running on Laravel Cloud's early-access Ruby runtime, on managed Postgres, a managed Valkey cache (Valkey is Redis-compatible), an S3-compatible bucket, and a Resque worker. Two people can chat in a room in real time, attachments land in the bucket, search works, and everything survives a redeploy. Campfire's full test suite passes on Postgres, with 461 runs and no failures.

The fork is public at artisan-build/campfire-experiment. It's a throwaway, built to find out what the minimum change looks like, not to run in production. Coding agents working from written briefs did most of the porting. We checked their claims against the live app.

What we guessed

We guessed What happened
SQLite would have to go Right. We moved to Postgres and rewrote the FTS5 search to use Postgres full-text search
S3 would have a surprise in it Right, twice. Uploads hit a checksum clash, and image variants assumed a local disk
Managed Redis might object to something Right. The Valkey ACL refuses a command Action Cable sends on connect
Websockets were the real question Right. They don't get through Cloud's edge, so we had to go around it
Early access would have rough edges Right, and the biggest one was one we never guessed

Eighteen deploys, and the first seventeen failed

The Ruby build worked first time. The deploys did not. Every one failed with the same status, deploy.app.crashing, even though the logs showed Puma (the Ruby web server) booting cleanly and answering health checks from inside the container.

We ruled things out one variable per deploy. We tried port mismatches, the health-check path, the worker process, a leftover instance, and hibernation. None of it mattered. The answer was in the dashboard's deploy log and nowhere else. The API and CLI only ever report the status string. Laravel Cloud's network is IPv6-only. Puma was listening on 0.0.0.0, the IPv4 wildcard, so nothing on Cloud's network could reach it.

The fix has two parts. First, we made the bind address configurable and left the upstream default alone:

# config/puma.rb
# Laravel Cloud's network is IPv6-only, so production sets
# PUMA_BIND_HOST=[::]; the default stays IPv4 to match upstream.
PORT=ENV.fetch("PORT", 3000)
bind "tcp://#{ENV.fetch("PUMA_BIND_HOST", "0.0.0.0")}:#{PORT}"

Second, the start script has to launch Puma directly. rails server passes its own host and port, and those override the config file:

# bin/start-app
exec bundle exec puma -C config/puma.rb

Deploy eighteen went green. When Cloud says crashing, read the dashboard deploy log before you try anything else.

The smaller fixes

Don't disable SSL. Campfire has a DISABLE_SSL setting for running behind a proxy that terminates TLS, which sounds like exactly Cloud's setup. When we set it, Rails thought every request was plain HTTP while the browser was sending an HTTPS origin. Every form, starting with the first-run wizard, failed its CSRF check. Cloud handles HTTPS at its edge (it terminates TLS) and forwards the right headers, so leave it unset.

Valkey won't let you name your connection. Cloud's managed Valkey locks down what the app's user can do, and CLIENT SETNAME is not allowed. Action Cable names its Redis connection, so every message failed with a 500 error. We put the fix in a new initializer rather than editing upstream code:

# config/initializers/action_cable_redis.rb
ActionCable::SubscriptionAdapter::Redis.redis_connector = ->(config) do
  ::Redis.new(config.except(:adapter, :channel_prefix, :id))
end

Send one checksum at a time. Recent versions of the AWS SDK add a CRC32 checksum to every upload, on top of the MD5 that Active Storage already sends. Cloud's S3-compatible storage rejects a request with both. Two lines in config/storage.yml fix it:

cloud:
  service: S3
  # ...
  request_checksum_calculation: when_required
  response_checksum_validation: when_required

Thumbnails assumed a disk. Uploads worked, but image variants (avatars and previews) returned 500 errors, because the code asks for a local file path that an S3 service doesn't have. There is already an open pull request upstream that fixes it. We cherry-picked it rather than writing our own. Campfire is deliberately a single-server app, so we don't expect S3 fixes to be a priority upstream.

Getting realtime to work

Action Cable websockets do not get through Cloud's edge. The upgrade request to /cable comes back as a 520, because Cloud's web proxy doesn't forward the Upgrade header to the app. Action Cable itself was healthy. The connection just never reached it.

Cloud does offer managed websockets through Reverb, Laravel's websocket server. Reverb speaks the Pusher protocol. So instead of asking Action Cable to get through the proxy, we taught it to publish through Reverb:

  • A new Action Cable subscription adapter publishes every broadcast to Reverb's HTTP API. None of Campfire's existing broadcasts had to change.
  • In the browser, a small shim swaps Action Cable's consumer for pusher-js, so the existing channel code keeps working.
  • A channel auth endpoint reuses Campfire's own room permissions, so someone outside a room gets a 403 for its channel.

In total we changed 11 lines across 4 upstream files and added 17 new files. New files almost never conflict with upstream changes, so this is a much cheaper diff than it sounds.

Reverb on a Rails app had rough edges of its own. Cloud won't attach a Reverb application to a Rails environment yet, so we set the connection details by hand. A new Reverb app allows no origins until you say otherwise. Reverb also caps a message at 10,000 bytes, and a Campfire message broadcast is about 11,400, so we compress the payload before sending it.

Where it stands

Campfire is live on the Reverb branch, with realtime, attachments, search, and a Resque worker all working. We're taking everything above to the Laravel Cloud team as early-access feedback. Two changes would make most of the workarounds unnecessary. Cloud could forward websocket upgrades to Rails apps, and it could let a Rails environment attach Reverb the way a Laravel one can.

The bigger decision is still open. Keeping the diff small was the goal for the experiment. Some of what Cloud needs, starting with the S3 fixes, is unlikely to land upstream. That points toward a proper fork maintained for Cloud. It would watch upstream for patches and apply them deliberately, rather than trying to stay a thin layer on top. We will decide that after we talk with Laravel. Once we have, a one-click Campfire install through Scalpels comes back on the table.

The idea behind this experiment

  1. Idea

    Can Campfire run on Laravel Cloud?

    We just got early access to Ruby on Laravel Cloud, and 37signals open-sourced Campfire. Campfire was built to run on a single server you own, not on a managed cloud. We want to know how much has to change to run it there.

    Read the idea

Support the Lab

The Lab runs on our supporters

Every idea here gets tried for real: deployed, broken, fixed and written up. Right now that is one person doing the work between everything else, and supporters are what buy the time. As support grows, it will also pay freelancers to run experiments of their own, so more of these ideas get tested, sooner.

Our supporters

  • Chill Vibes

    A curated collection of fun and interesting experiments and projects built with AI to entertain and educate.

    Supporter Visit
    Visit Chill Vibes
  • Fawnfox Fables

    Create and publish your own children's books. Stories built around the people you love.

    Supporter Visit
    Visit Fawnfox Fables
  • Sputnik Intelligence

    Spain

    We transcribe the podcasts and read the newsletters, and make them searchable. Set up alerts, or hand it all to your AI agent over MCP or API.

    Supporter Visit
    Visit Sputnik Intelligence
  • Team of Me

    Free resources for indie makers and people thinking about striking out on their own.

    Supporter Visit
    Visit Team of Me
  • Wicked Viral

    Earth

    Connecting builders with promoters who can help them take their products to market. Get your product listed today!

    Supporter Visit
    Visit Wicked Viral