Skip to content

Heroku

Heroku is a platform as a service (PaaS) we use to build, run, and operate applications in the cloud. It abstracts away a lot of the underlying infrastructure management involved in deploying client apps, including server setup.

  • Simplified Deployment:

    With Heroku, the process of deploying an application is much more straightforward compared to traditional deployment methods. This simplicity saves time and reduces the chances of encountering errors during deployment.

  • Scaling: Heroku allows for easy scaling of applications, meaning it can automatically manage resources as a client application’s user base grows.

  • Managed Services:

    Heroku offers a range of managed services, including databases, which takes away the headache of managing database servers and allows us to focus on improving the application.

  • Add-On Ecosystem:

    Heroku hosts a rich ecosystem of add-ons that can easily integrate with our applications to provide additional functionality and features without a lot of extra development work.

Steps for Using Heroku on Client Applications

Section titled “Steps for Using Heroku on Client Applications”
  1. Create a Heroku account using your Planet Argon email address.
  2. Request access from your project manager or tech lead to the Planet Argon Heroku Team or the client’s Heroku Team, depending on where the application is kept.
  3. Install the Heroku CLI:
  • Install Homebrew, then run:
    • brew tap heroku/brew && brew install heroku
  • Verify the installation:
    • heroku --version
  1. Make sure config/database.yml is set up to use the DATABASE_URL environment variable provided by Heroku for the production database.
  2. Precompile your assets:
  • Ensure that Rails is set up to serve static assets in config/environments/production.rb:
    • config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
  • Set up Rails to use the SECRET_KEY_BASE environment variable in production in config/environments/production.rb:
    • config.require_master_key = true
  • Deploying to Heroku:

    Add and commit changes, then deploy to Heroku:

    git add .
    git commit -m "Prepare for Heroku deployment"
    git push heroku main
  • Migrating a database:

    After a successful push, run:

    heroku run rake db:migrate
  • Opening an app:

    heroku open
  • Viewing logs:

    heroku logs --tail

Best Practices for Using Heroku with Ruby on Rails Applications

Section titled “Best Practices for Using Heroku with Ruby on Rails Applications”
  • Use environment variables to store sensitive information, such as API keys, to keep them secure and facilitate smoother deployments across different environments.
  • Regularly backup your database to prevent data loss.
  • Make sure to set up proper logging for the deployed applications to help diagnose and troubleshoot issues effectively.
  • Frequently review the metrics provided by Heroku to monitor the performance of our clients’ applications and ensure they’re running optimally.
  • Precompile your assets before deploying an app to speed up the deployment process. You can set up automated processes to handle this during deployment.
  • Familiarize yourself with the Heroku Command Line Interface (CLI). The CLI is a powerful tool that allows you to manage your Heroku applications from the command line, offering a range of functionalities including viewing logs, running one-off dynos, and setting config vars.
  • Always remember to run database migrations after deploying a new version of your application to ensure the database schema is up to date.