Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to Deploy Rails to Render Discussion

Great video, thanks Collin!

Reply

Thank you, sir!

Reply

Love this info, I'm so close to deploying successfully. All but the web container. I keep getting ActiveSupport::MessageEncryptor::InvalidMessage, ArgumentError: key must be 16 bytes. All answers point to regenerating the master.key and enc file. I do so, update the RAILS_MASTER_KEY with the new one, and it doesn't solve the issue. Some say to save the old info and reuse it in the new enc. Still no joy. Anyone else hit this?

SOLVED: My fault... I was supposed to add the content master.key in render RAILS_MASTER_KEY and not the base secret which I was using. As you were folks, nothing to see here.

Reply

Now I can't seem to get yarn up and running:
error An unexpected error occurred: "EROFS: read-only file system, mkdir '/node_modules'".
jsbundling-rails: Command build failed, ensure yarn is installed and yarn build runs without errors. hmm...

Reply

do you have the yarn build as part of your build commands?

Reply

I didn't explicitly add it no. I've tried adding it to render-build.sh but it seems to be ignoring what I add in there after the standard:

bundle install
bundle exec rake assets:precompile
bundle exec rake assets:clean
bundle exec rake db:migrate

I'm thinking the assets:precompile triggers it

Tried to add mkdir /node_modules && chown ruby:ruby -R /node_modules /app before the precompile and got the same scenario: mkdir: cannot create directory ‘/node_modules’: Read-only file system

Reply

Yeah should do, it works locally?

Reply

Yes, I use docker locally without any issues. Is there a setting to change to be able to create this folder?

Reply

haha you had me up to docker. I don't use docker. Have you tried going down this route? - https://render.com/docs/docker

Reply

Nice, that may be the solution, thank you! Now, to be clear, I'm not using docket other than local, so this is all using this video, straight up. I'm inches away from deploying. Always the case isn't it! Thanks for helping Tim!

Collin's advice is GOLD. Even if you have an existing app, use this to deploy the simplest beginning of it and THEN add-on.

Spent the last 2 weeks trying to deploy on render, fly.io, digital ocean... nothing worked for all different reasons. So, I followed his advice and I can live again! Thank you Collin. You guys are the tide that raises all rails boats.

Successfully deployed also using tailwind:

  1. rails new app_name -j esbuild --css tailwind --database=postgresql

  2. Added this to package.json:
    { "name": "app", "private": "true", "dependencies": { "@hotwired/stimulus": "^3.0.1", "@hotwired/turbo-rails": "^7.1.0", "autoprefixer": "^10.4.1", "esbuild": "^0.14.9", "postcss": "^8.4.5", "tailwindcss": "^3.0.8" }, "scripts": { "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds", "build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css" }}

  3. Ran through this tutorial but got stuck:
    Oct 27 10:47:53 PM  ==> Generating container image from build. This may take a few minutes...
    Oct 27 10:49:43 PM  ==> Uploading build...
    Oct 27 10:50:13 PM  ==> Build uploaded in 24s
    Oct 27 10:50:13 PM  ==> Build successful
    Oct 27 10:50:13 PM  ==> Deploying...
    Error getting active endpoint: revision.serving.knative.dev "srv-cddj6eien0hmkdfelnig-kn-00001" not found

  4. Trying minor update and redeploying.

DEPLOYED!!! ::YAY:

Reply

Everything works up until the last step, where instead of a successful deploy, it fails again (despite adding the Linux platform) with:

Dec 30 01:18:45 PM RubyGems system software updated
Dec 30 01:18:46 PM ==> Running build command './bin/render-build.sh'...
Dec 30 01:18:47 PM Could not find nokogiri-1.13.10-x86_64-linux in cached gems or installed locally
Dec 30 01:18:47 PM ==> Build failed 😞

Reply

After executing the following I was still running into failed deployments as above:

bundle lock --add-platform x86_64-darwin
bundle lock --add-platform x86_64-linux

This fixed it for me:

bundle package --all-platforms

Now deployment succeeded! Woohoo!

Reply

Just a side note that after adding Tailwind, I ran into the same error of missing the Linux package (I'm developing on macOS) until I re-ran:

bundle package --all-platforms

Reply

If you don't add "free" to the render.yaml for postgres and the web service, it will go to starter plan and charge you money - just a heads up. That may be what you want, but if you're trying to use the free plan, make sure to update your render.yaml like so:

databases:
  ...
  plan: free
services:
  - type: web
    ...
    plan: free
  - type: redis
     ...
    plan: free
Reply

I am using windows I cannot run the chmod command so it always shows permission denied when deploying to render

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,842+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.