How To Quickly Deploy Your Project To Production With Ruby On Rails 6 And Capistrano

How To Quickly Deploy Your Project To Production With Ruby On Rails 6 And Capistrano


ruby on rails shared hosting

Today We’re going to quickly deploy your ruby on rails 6 project to production using passenger, nginx and capistrano! We also sort of set up webpacker, but you’ll have to add a stylesheet pack tag to your application.html.erb if you follow the bootstrap tutorial video that I have posted.

My digital ocean affiliate link for 60 days, $100 credit:

———————————————
Recording Equipment Used In My Videos (Amazon Affiliate Links)

———————————————

The @GoRails guide that was used:

The gist:

You can support me on Patreon:

Adamantly opposed to Patreon? Buy me a coffee instead!

Photo by Alexander Dummer on Unsplash
———————————————
Follow me on Social media:

The subreddit:

And if you want to discuss the project, or anything really, we have a discord:

Also check out my GitHub if you’re interested in my code:

If you liked this video, please consider subscribing:

#Deanin #Rails6 #20in20

14 thoughts on “How To Quickly Deploy Your Project To Production With Ruby On Rails 6 And Capistrano

  1. @Deanin, not sure if you saw my comment, but just wanted to ping you one more time. Been it just seems like I have broken dependencies all the way down. I'm on Ubuntu 16.04.6 LTS Hopefully I can get past this so I can continue to develop my rails app!

  2. Got around to trying this out! Using Google Cloud Compute engine for an Ubuntu server instead of DigitalOcean because they offer $300 for free when you sign up! (I'm cheap) All good up until installing NGINX and Passenger. 

    Specifically, the line 
    'sudo apt-get install -y nginx-extras libnginx-mod-http-passenger' 
    results in the following error message:

    "
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    libnginx-mod-http-passenger : Depends: passenger (= 1:6.0.4-1~bionic1) but it is not going to be installed
    Depends: nginx-common (>= 1.14.0-0ubuntu1.6) but 1.10.3-0ubuntu0.16.04.5 is to be installed
    E: Unable to correct problems, you have held broken packages.
    "

    Pretty sure there were no errors up until this point. Any insight would be greatly appreciated!

  3. love it! just did a first watch through since I'm getting to the point of deploying my first app. Using mysql so I'll let you know how it goes. One thing I was wondering: is there any risk in using a public GitHub repo? Are there any sensitive passwords, keys, etc. that could be exposed?

  4. For anyone interested, I highly recommend using aws elastic beanstalk for deployment. Its super easy to deploy, and expand your services. Really life changing compared to the hell that is deploying rails on a fresh linux server

  5. I'd recommend using the bash's "tail -f log/production.log" command over using nano/vim. The reason is because if the server log accumulates enough, when you try to open the log, the log file is too big and the server's memory usage will spike and your terminal will freeze.

    the tail command will only read the lines on the bottom.

  6. Second edit: If you're trying to use webpacker in production, I've included an edit below that covers one last change.
    I felt bad not figuring out active storage in time to get the restaurant production video out, so hopefully this generic production deployment video makes up for it. Links as always are in the video description, I'll be creating a gist momentarily.
    Edit: Link to gist is https://gist.github.com/Deanout/17bd141858553030379e070a68aa827a

    Webpacker in production section:

    I noticed that you need to run yarn before you precompile your assets, so I'm including a task for capistrano. Inside of your config/deploy.rb file, at the very bottom, add these lines of code:

    before 'deploy:assets:precompile', 'deploy:yarn_install'

    namespace :deploy do

    desc 'Run rake yarn install'

    task :yarn_install do

    on roles(:web) do

    within release_path do

    execute("cd #{release_path} && yarn install –silent –no-progress –no-audit –no-optional")

    end

    end

    end

    end

Leave a Reply

Your email address will not be published. Required fields are marked *