How Do You Deploy?

Hello,

I’m revisiting Rails after a hiatus that went a few years.

If I recall correctly, services such as Heroku used to simply accept a Github repo and would spin up your app. It was easy peasy. You could just open up the console to initiate commands.

With Rails 8 it seems like it’s not so simple. From what I understand, the database now needs to be spun up as a separate service?

I have tried both Heroku and Koyeb and both services keep giving me database errors. Everything from “bad PG connection” to “bad URI” to “unable to parse database name” and everything else you can imagine.

Can anyone please lend a helping hand on how I’m supposed to spin up my app and have a simple Postgres database connected to it?

Thank you!

Heroku is still maybe the easiest way to deploy a rails app, even in Rails 8. They have a guide:

Make sure you look at the steps around provisioning a database, sounds like that might be your issue.

1 Like

A good alternative to heroku is Rails on Fly.io · Fly Docs

From what I understand, the database now needs to be spun up as a separate service?

If you used any db other than sqlite that was aways the case, rails new by default will use sqlite so there is no need for a separate service.

Hi!

In my case, I initially planned to simply copy everything to the production server. However, I came across Kamal 2, which seemed quite straightforward and easy to use, so I decided to give it a try. I have to say, it was a nightmare of errors—connection issues, permission errors, namespace problems, secret-related errors, you name it. I spent about 20 hours non-stop battling Kamal 2, with ChatGPT and Grok on fire and an infinite number of browser tabs open.

I was ready to throw everything out the window, but in the end, it worked! Once I sorted out all the Kamal configuration issues and fixed the app itself, the deployment became incredibly smooth and easy. Now, I just run a three-line bash script, bv_deploy.production.sh, and it’s done.

So I will tell you to check deeply Kamal2 to do all the deployment

One of the “traditional” ways is to simply use git + Capistrano (the gem):

  1. You “git push” your .git directory to your server (only your latest code updates → fast)
  2. You run Capistrano’s “deploy” command (which ensures the presence of all required folders, sym links, etc. on the server)

Done.

Hey everyone. I solved the problem. Turns out the issue was extremely simple (though very frustrating).

Long story short: there’s an errata in the Koyeb documentation.

See the erb tag below that Koyeb instructs you to copy/paste into your config file? That second equals sign isn’t supposed to be there. I don’t even want to admit how long it took me to notice it.

3 Likes

Wow. Don’t feel too bad, that’s a pretty sneaky little error. All the more so since it comes from an official source.

Did you have a chance to file a PR against this issue?

I shared the issue on the Koyeb forum, and it looks like it’s being escalated.

Thank you to everyone chiming in and offering to help!

Using Kamal 2, but as others have said, it is not quite there yet. That is just the territory of handling your own infra, but I do believe it is worth it.

Highly recommend deploying very soon after starting a greenfield project. Keep your Dockerfiles up to date with your app. It will be easier to add stuff one by one (redis, external libraries, etc) than all at once when you’re ready to deploy, and you’ll have experience with issues that can arise. For example, it was surprising to me how much memory was consumed by Solid trifecta. Kamal runs two instances of the container for gap-less deployments, so I would sometimes get OOM errors, which Kamal would not know anything about.

on debian vps apache2 - using systemd proxy and puma via git push and post-receive hook … I think. :face_without_mouth: