Hello, below I will write three posts series about the deployment of Ruby on Rails application into Azure Cloud Services where we compare them and try to describe pros and cons and hope it will help you to pick your Azure Service for running the application. Of course, this is not a silver bullet and it all depends on your current situation, application state, and where you plaining to be in terms of scaling and performance.
As a start point, we deploy an e-commerce shop using popular open-source Ruby on Rails engine called Spree, we fork it and apply our changes to deploy to Azure Cloud.
Dockerized @spree demo & starter template
Spree Starter (formerly Spark Starter Kit)
This is a Ruby on Rails application minimal template with Spree Commerce pre-installed, fully dockerized and ready to be deployed to Heroku.
Launch on Heroku
Local Installation
Install required tools and dependencies:
- Docker with docker-compose
Run setup scriptbin/setup
Import sample data such as products, categories, etc (optionally)docker-compose run web rake spree_sample:load
Running the projectdocker-compose up
Development
Running rails consoledocker-compose run web rails c
Running testsdocker-compose run web bash bundle exec rspec
Adding new gems
Update Gemfile
and runbundle install docker-compose build
You will need to restart the server if running:docker-compose restart
Updating gemsbundle update spree docker-compose build
Environment variables
variable | description | default value |
---|---|---|
DEBUG_ASSETS | Enables/disables asset debugging in development | false |
DB_POOL | database connection pool | 5 |
MEMCACHED_POOL_SIZE | memcache connection pool | 5 |
SENDGRID_API_KEY | API key to interface Sendgrid API |
License
Spree Starter (formerly Spark Starter Kit) is copyright…View on GitHub
We will compare Azure App Service, Azure Virtual Machines, and Azure Kubernetes Service.
Azure App Service
https://azure.microsoft.com/en-us/services/app-service
It is a managed platform for the deployment of your containerized application. Deploy any application at your choice: Node.js, ASP.NET, .NET Core, Python, Ruby, Java, Go. Also has a multi-container application deployment like managed docker-compose into the cloud. Build your application image and deploy them using compose YAML definition.
pros: free pricing plan, headless setup
cons: limitations, preview mode
Azure Virtual Machines
https://azure.microsoft.com/en-us/services/virtual-machines
It's a classic Virtual Machine with different CPU/RAM has plans. If you need or want to manage and control everything by yourself.
pros: full control of OS & application-level
cons: effort to setup and scale
Azure Kubernetes Service
https://azure.microsoft.com/en-us/services/kubernetes-service
Managed Kubernetes Cluster - if you plan to be able to scale fast without any manual maintenance. Ability to manually one-click adding resources to the cluster or automatically depends on your loading through Azure CLI.
pros: easy to scale
cons: high learning curve
What's service should you use?
There is no silver bullet if you are small and no planning to grows in case of traffic because for example sale some niche product then App Service will be preferable. If you are a mid-size project and planning to grow at the same time have developers to maintain everything may be better to use your own docker swarm or Kubernetes cluster at Azure Virtual Machines. In another case, if you are don't want to be the maintainer for your own servers by yourself but same time wants to be able to scale fast then managed Kubernetes Cluster will be answering for you.
In the following posts, we deploy to all these services and you will pick more relevant solutions for you.
What's a plan?
- CI/CD pipeline to build, test and push docker image to Azure container registry
- Azure App Service deployment
- Azure Virtual Machines deployment
- Azure Kubernetes Service deployment
These four articles will be published oned by one next few weeks.
The next one "Build, Test and push Docker image to Azure Container Registry using Github Actions" described how to build the docker image, run tests, and push it to Azure Container Registry. And uncovering the pros and cons of few approaches to build your CI pipeline coming soon next week.