MENU

Fun & Interesting

Rails Deployments Made Easy with Terraform and Kamal

Dev Tester 1,246 lượt xem 11 months ago
Video Not Working? Fix It Now

Deploying your Ruby on Rails applications has never been easier, thanks to platforms like Heroku, Render, or AWS Elastic Beanstalk. However, the convenience of using these platforms comes at a price. If you're seeking an alternative to those platforms, Kamal is the solution.

In this video, I’ll show you how to use Infrastructure as Code to spin up a server on the cloud using Terraform, and deploy your Rails app onto that new server with ease. I have no doubt that in the coming years, these tools will become the preferred way of deploying Ruby on Rails applications.

*Thanks for watching!*

If you find this video helpful, consider subscribing to this channel for more tips on helping Rails developers ship their code with more confidence, from development to deployment.

You can also check my website for more in-depth articles covering Rails, testing, DevOps, and other software engineering topics: https://dennmart.com/

*Additional resources*

- Get Started With Hetzner Cloud and Terraform for Easy Deployments: https://dennmart.com/articles/get-started-with-hetzner-cloud-and-terraform-for-easy-deployments/
- Deploy Your Rails Applications the Easy Way With Kamal: https://dennmart.com/articles/deploy-your-rails-applications-the-easy-way-with-kamal/


*Chapters:*

0:00 - Introduction
2:56 - Terraform and Kamal: Prerequisites for project
4:07 - Setting up Hetzner Cloud account for Terraform
5:39 - Initial setup of Terraform project
6:24 - Setting up Hetzner Cloud provider for Terraform
7:39 - Setting up Hetzner Cloud API token as Terraform variable
10:30 - Initializing the Terraform project
11:00 - Creating a Hetzner cloud firewall resource with Terraform
15:32 - Previewing and applying infrastructure changes with Terraform
17:04 - Creating a Hetzner Cloud private network with Terraform
19:00 - Creating a Hetzner Cloud private network subnet with Terraform
23:09 - Creating a Hetzner Cloud server with Terraform
31:14 - Handling resource creation order in Terraform
33:26 - Applying changes to create new server
34:54 - Notes on Kamal prerequisites
35:57 - Installing and initializing Kamal
37:19 - Configuring Kamal for deployments
38:26 - Managing different server roles
42:30 - Managing environment variables
44:32 - Managing Docker build configuration
45:55 - Managing accessories (services) for your app
51:34 - Fixing private network ports for accessories
52:08 - Deploying your app for the first time with Kamal
54:32 - Managing future deployments with Kamal
55:12 - Updating environment variables with Kamal
55:52 - Rolling back deployments with Kamal
56:58 - Executing commands on your containers using Kamal
58:47 - Wrapup

*Related Links:*

- Kamal homepage: https://kamal-deploy.org/
- Terraform homepage: https://www.terraform.io/
- Hetzner Cloud homepage: https://www.hetzner.com/cloud/
- Traefik homepage: https://traefik.io/traefik/
- Terraform installation instructions: https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli
- Docker installation instructions: https://docs.docker.com/engine/install/
- Terraform providers: https://developer.hashicorp.com/terraform/language/providers
- Hetzner Cloud provider for Terraform: https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs
- Hetzner Cloud - Server Overview documentation: https://docs.hetzner.com/cloud/servers/overview/
- Hetzner Cloud - Locations documentation: https://docs.hetzner.com/cloud/general/locations/
- Hetzner Cloud - Operating Systems Images documentation: https://docs.hetzner.com/robot/dedicated-server/operating-systems/standard-images/
- Kamal documentation: https://kamal-deploy.org/docs/
- PostgreSQL Docker image: https://hub.docker.com/_/postgres
- Redis Docker image: https://hub.docker.com/_/redis

*Background music used in video:*

- Summer Adventures by SergePavkinMusic: https://pixabay.com/users/sergepavkinmusic-6130722/

*Video clips used in video:*

- Video by Pixabay: https://www.pexels.com/video/us-dollars-856668/
- Video by Matthias Groeneveld from Pexels: https://www.pexels.com/video/a-weather-worn-barn-door-and-lock-2618443/

Comment