- 19
- 4 895
Dev Tester
Japan
Приєднався 29 лют 2024
Welcome to the Dev Tester UA-cam channel! I'm Dennis Martinez, an experienced freelance software engineer.
Stay tuned for tutorials, tips, and discussions on the latest trends in the world of software engineering, test automation, and DevOps. Don't forget to comment and join the conversation! #SoftwareEngineering #TestAutomation #DevOps
Stay tuned for tutorials, tips, and discussions on the latest trends in the world of software engineering, test automation, and DevOps. Don't forget to comment and join the conversation! #SoftwareEngineering #TestAutomation #DevOps
Let's Build a Dockerfile for Your Rails Apps From Scratch
Current versions of Ruby on Rails generate a Dockerfile that you can use to deploy your apps to production. But what if you have an application that was generated with an older version of Rails? You’ll have to create a Dockerfile on your own.
This video guides you step-by-step on how you can create your own Dockerfiles for Rails applications from scratch, covering all the details to have a lean production-ready Docker image ready to deploy. It’s worth learning how to put together a Dockerfile so you can build one to fit your specific needs.
*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: dennmart.com/
If your company needs help with setting up Docker-based deployments for Rails applications, I’m available to help. Send me a message through my website: dennmart.com/contact/
*Chapters:*
00:00:00 - Introduction
00:01:18 - Example Rails application: TeamYap
00:02:06 - Before creating a Dockerfile
00:03:41 - Multi-Stage Build Part 1: Base Stage
00:13:04 - Explaining Docker layer caching
00:15:16 - Differences between ARG and ENV
00:17:05 - Multi-Stage Build Part 2: Dependencies Stage
00:21:34 - Setting up node-build for Node.js
00:25:49 - Setting up gems and JavaScript dependencies
00:29:54 - Precompiling assets
00:31:28 - Multi-Stage Build Part 3: Final Stage
00:36:59 - Dealing with ENTRYPOINT and CMD
00:38:50 - Creating an ENTRYPOINT script
00:43:54 - Setting up .dockerignore
00:47:35 - Initial Docker image build testing
00:50:07 - Optimizing Docker image: Parser directives
00:52:25 - Optimizing Docker image: Using Bootsnap
00:54:00 - Optimizing Docker image: Setting up jemalloc
00:59:57 - Optimizing Docker image: Run Rails as non-root user
01:05:04 - Kamal deployment testing
01:06:02 - Wrap Up
*Related Links:*
- Rails 7.1 release announcement: rubyonrails.org/2023/10/5/Rails-7-1-0-has-been-released
- dockerfile-rails gem by Fly.io: github.com/fly-apps/dockerfile-rails
- End-to-End Testing with TestCafe book: testingwithtestcafe.com/
- TeamYap application (accompanying app for book): teamyap.app/
- Dokku: dokku.com/
- Ruby Docker image (official): hub.docker.com/_/ruby
- node-build: github.com/nodenv/node-build
- Article: “An Alternative to the Dockerfile”: matt-rickard.com/building-a-new-dockerfile-frontend
- jemalloc: jemalloc.net/
- jemalloc “Getting Started” documentation: github.com/jemalloc/jemalloc/wiki/getting-started
- Bootsnap gem: github.com/Shopify/bootsnap
*Background music used in video:*
- Summer Adventures by SergePavkinMusic: pixabay.com/users/sergepavkinmusic-6130722/
This video guides you step-by-step on how you can create your own Dockerfiles for Rails applications from scratch, covering all the details to have a lean production-ready Docker image ready to deploy. It’s worth learning how to put together a Dockerfile so you can build one to fit your specific needs.
*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: dennmart.com/
If your company needs help with setting up Docker-based deployments for Rails applications, I’m available to help. Send me a message through my website: dennmart.com/contact/
*Chapters:*
00:00:00 - Introduction
00:01:18 - Example Rails application: TeamYap
00:02:06 - Before creating a Dockerfile
00:03:41 - Multi-Stage Build Part 1: Base Stage
00:13:04 - Explaining Docker layer caching
00:15:16 - Differences between ARG and ENV
00:17:05 - Multi-Stage Build Part 2: Dependencies Stage
00:21:34 - Setting up node-build for Node.js
00:25:49 - Setting up gems and JavaScript dependencies
00:29:54 - Precompiling assets
00:31:28 - Multi-Stage Build Part 3: Final Stage
00:36:59 - Dealing with ENTRYPOINT and CMD
00:38:50 - Creating an ENTRYPOINT script
00:43:54 - Setting up .dockerignore
00:47:35 - Initial Docker image build testing
00:50:07 - Optimizing Docker image: Parser directives
00:52:25 - Optimizing Docker image: Using Bootsnap
00:54:00 - Optimizing Docker image: Setting up jemalloc
00:59:57 - Optimizing Docker image: Run Rails as non-root user
01:05:04 - Kamal deployment testing
01:06:02 - Wrap Up
*Related Links:*
- Rails 7.1 release announcement: rubyonrails.org/2023/10/5/Rails-7-1-0-has-been-released
- dockerfile-rails gem by Fly.io: github.com/fly-apps/dockerfile-rails
- End-to-End Testing with TestCafe book: testingwithtestcafe.com/
- TeamYap application (accompanying app for book): teamyap.app/
- Dokku: dokku.com/
- Ruby Docker image (official): hub.docker.com/_/ruby
- node-build: github.com/nodenv/node-build
- Article: “An Alternative to the Dockerfile”: matt-rickard.com/building-a-new-dockerfile-frontend
- jemalloc: jemalloc.net/
- jemalloc “Getting Started” documentation: github.com/jemalloc/jemalloc/wiki/getting-started
- Bootsnap gem: github.com/Shopify/bootsnap
*Background music used in video:*
- Summer Adventures by SergePavkinMusic: pixabay.com/users/sergepavkinmusic-6130722/
Переглядів: 106
Відео
Kamal 2.0: What’s New and How to Easily Upgrade Your Apps
Переглядів 2532 місяці тому
Kamal 2.0 was released a few weeks ago, and while not a lot has changed, this new version does contain a few major changes that will require some updates to your existing Kamal-deployed web applications. Let’s check out what’s changed in Kamal 2.0, and go through the process of upgrading a web application that’s deployed with an older version. *Thanks for watching!* If you find this video helpf...
Supercharge Your Kamal Deployed App with Traefik Middleware
Переглядів 1533 місяці тому
Deploying web applications with Kamal couldn’t be easier. But did you know that you can use Kamal to add extra functionality? Thanks to the underlying Traefik proxy service, you can set up middleware to handle basic authentication, compression, rate limiting, and more, without having to add more code to your app. In this video, I show how easy it is to add middleware to your Kamal-deployed appl...
Secure Your Kamal App Deployments with Let's Encrypt
Переглядів 3364 місяці тому
Do you have a web application deployed with Kamal, but want to know how to set up secure HTTPS connectivity to it? In this video, you’ll learn how easy it is to configure Kamal to generate free SSL certificates automatically for your apps using Let’s Encrypt. *Thanks for watching!* If you find this video helpful, consider subscribing to this channel for more tips on helping Rails developers shi...
Dead-Simple Load Testing at Scale on Lambda or Fargate
Переглядів 1025 місяців тому
Do you know if your web application can handle hundreds or even thousands of concurrent requests without crashing? You can run load tests to make sure your systems are stable enough. But running load tests that generate thousands of virtual users isn't an easy feat. Your systems will likely run into resource constraints, and you might not have enough bandwidth to sustain this type of testing. I...
Hassle-Free Automated PostgreSQL Backups for Kamal Apps
Переглядів 1685 місяців тому
Kamal makes deploying web applications to your preferred infrastructure a breeze. However, it has its tradeoffs, mainly that you need to manage a lot of the maintenance work yourself. One of the essential things you’ll need to handle yourself when using Kamal are database backups. In this video, I'll show you a quick and easy way to back up PostgreSQL databases for your Kamal-deployed web apps ...
Load Balancers Made Easy on Hetzner Cloud with Terraform
Переглядів 3816 місяців тому
If you need to scale your web applications by deploying them across multiple servers, you'll need a load balancer to distribute traffic to them. While you can create your own load balancer, using a managed solution can help save you time and money by managing the complexity. Hetzner Cloud provides managed load balancers to distribute traffic to your infrastructure. In this video, I'll show you ...
Get Started with Artillery - Load Testing Made Simple
Переглядів 1,1 тис.6 місяців тому
Checking how our applications run under load is an essential part of the software development lifecycle, so we can make sure our systems can handle expected and unexpected traffic. However, many developers and testers gloss over this important step. These days, load testing your applications is as simple as ever. In this video, I'll talk about how to get started with my favorite load testing to...
Rails Deployments Made Easy with Terraform and Kamal
Переглядів 1 тис.7 місяців тому
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 depl...
Automating Rubocop Into Your Rails Development Workflow
Переглядів 2998 місяців тому
Do you have Rubocop set up on your Ruby on Rails application, but not using it very often? If so, you’re not making the most out of having this very powerful tool. In this video, I’ll show you a couple of ways to run Rubocop early and often so you and your team can ensure you’re avoiding inconsistencies and bugs while maintaining your code for the long haul. *Thanks for watching!* If you find t...
Clean up Your Messy Legacy Ruby on Rails Codebase With Rubocop
Переглядів 3118 місяців тому
Are you overwhelmed after setting up Rubocop in your legacy Ruby on Rails applications? Setting up Rubocop on a new Rails application will get you on the path towards a well-maintained codebase. But what if you have an older project? When you set up Rubocop on an existing application, it’ll likely show you hundreds or thousands of issues the first time you run static code analysis. That’s enoug...
i tried to follow along with you to set up kamal using postgresql and digitalOcean and i was really upset with other videos out there as they dont show the simple way to deploy and i always have errrors at runtime so by far i hope i can still follow what i see from your video and make it work i hope
Great content this deserves way more attention.
Kamal 2 deprecated the kamal env push command shown in this tutorial. That could be a good timing for a version 2 of this video, with another cloud provider?
Sorry if there was any confusion on this older video - at the time I published it I didn't know Kamal would change a lot in a short time! I have a video on this channel that covers how to upgrade to Kamal 2.0, which mentions that this command is no longer available. It would be great to make an updated version of this video, so I'll do my best to make that happen. Thanks for the suggestion!
Great work, helped a lot. Thanks!
Thank you, I'm glad it helped!
Keep it up bro
Thank you for watching and for your comment 🙏
Hi thanks for sharing! This is very helpful. In my setup, my sidekiq dashboard usually lose its data after deployment and I am not sure why
I'm not sure why you're losing data from Sidekiq after deployments. If you have a Redis accessory with a data volume set up, Kamal deploys shouldn't clear that information. I'd start by making sure that you have a Redis accessory set up and that it's working correctly on the server where it's running. If you want more help, feel free to reach out to me (my contact info is on my home page - check my channel for more details) and I'll try to help out!
Great video. I hope you make a video deploying rails 7 app with kamal. It works well for rails 8
I have another video in this channel that shows how to deploy a Rails 7 app called "Rails Deployments Made Easy with Terraform and Kamal". Hopefully that one has enough information you're looking for!
Great !
Thank you!
You're doing great! I suggest that you remove your background music.
Thanks for the suggestion - my next video will have minimal background music!
Wonderful explanation!
Thank you so much for your comment, hope it was helpful!
Excellent explanation. Thanks so much.
Thanks for the comment, I hope this video helped!
Awesome video! One point though - doesn't manually running kamal setup kind of defeat the purpose of using terraform in the first place? We have multiple prod and non-prod environments running on Kamal and I'm trying to automate the provisioning of new envs through terraform, but this seems to be the only manual step in the entire journey
You can likely automate this whole process, from provisioning servers with Terraform to running that initial kamal setup command. Depending on how complex your setup is, you should be able to handle this with just about any CI/CD solution out there. I think Kamal isn't really built for this type of scenario, though, so I can see it getting messy quickly, especially if you need to do a lot of templating/modifiying the deploy.yml file for Kamal. If you're scaling up your app through multiple services, you're probably better off creating a golden image of your initial Kamal setup that you can use when provisioning new servers so you can bypass that step, and can simply focus on updating the Docker container for your app
I had a hard time getting Let's Encrypt to work. Followed your video, which exposed the problem (not having the right path in the Container).
I'm glad the video helped you find the issue!
You’re very good at making videos. Everything was clear and to the point. I subscribed. Hope to see more videos :)
Thank you so much for this comment, I appreciate it - stay tuned for more videos soon!
Great content, but how to do this work with rootless context? I can't get this to work using a user with docker rootless permission. I guess it need some configuration at the rootless, but I can't find it.
I haven't used Kamal with Docker in rootless mode, so I'm not sure how to get it working that way or even if it's possible. A quick search online shows that it should be possible, but haven't seen anyone say how. I'm guessing the main issue will be around binding privileged ports (ports under 1024) for Traefik. I'm curious to see if it's a possibility, so I'll tinker around with it to see if I can find a solution.
Thanks Dennis. An excellent presentation and explanation.
Thank you so much, I hope it helped!
Great content!!! Best source i have ever found which explains the traefik labels, how would you handle the www redirection like i want to access my application with www and without. Is it possible to configure multiple domains to one application which all have their own certificates? I want to route different domains to my app and handle the routing internally in the rails app.
Thanks for the kind words! I'm glad you found some value out of this video. For doing redirections like you mentioned from www to non-www, you'll need to create middleware (which you can do through labels) that uses regex to capture the user going to the www domain and redirects them to the non-www domain. Then you can add the middleware to the Traefik router. Here's an example configuration file showing the labels under the `servers` section: gist.github.com/dennmart/91981691f16def7e99b5068be3a0660b As for setting up multiple domains to use SSL, you'll need a wildcard certificate from Let's Encrypt. However, you can't use the HTTP challenge to generate the certificate (as shown in this video). You'll need to set up a DNS challenge instead. Traefik does have support for this as well: doc.traefik.io/traefik/https/acme/#dnschallenge. I've never done this myself, but I'll explore it and maybe do a future video about it.
@@DevTesterBlog yes i found some examples for the dnschallenge but from my understanding i need this for wildcard certificates. What if i want just different domains i mean complete different domains like domain1 and domain2 can i use there still the web challenge? You should make a video about middleware it took me quite a while to find out how i enable gzip in traefik but got it working in the end.
@@hansdampf10 You can create different routers for the web app in Kamal that point to different domains (using the `traefik.http.routers.<router-name>` labels as I showed in the video), and your app should generate the SSL certificates for each domain using the web challenge. I did a quick test and it worked great. Let me know if you need help setting that up. Also, thanks for the video suggestion - look for a future video talking about Traefik middleware!
Please make a video about ssl certificates in this config
Thanks for the suggestion, I'll work on this! I have a video showing how to set up SSL using load balancers, but it would also be nice to have a video showing how to use it on a single server since not everyone needs a load balancer for small apps.
Great video. Learned a lot.
I'm happy to hear that!
Great video yet again! Please keep going! 💪
Glad you enjoyed this one, hope you found it helpful!
This one is awesome, thank you. I have a request, could you prepare a content that covers grafana prometheus, and also a python backend framework like fastapi to monitor our apps performance. Also I really want to see other types of tests in this channel with this amazing presentation and edit.
Those are good suggestions. I'm not much of a Python developer, but I do have plans to make a video covering monitoring/observability (likely for a Ruby on Rails app), hopefully it will still be helpful. I also have some more testing topics to cover so keep an eye out for those in the near future. Thanks for the kind words!
Absolutely fantastic and so comprehensive! Thank you.
Thank you so much, I'm glad you found it valuable!