Deploy Rails apps to Azure App Service using Docker & Continuous Deployment

This article is Request! Cloud Native application development tips![PR] It is his 20th day of Microsoft Japan Advent Calendar 2020 (I will write it later).


In this article, I would like to introduce how to deploy & continuously deploy Rails apps using Docker for Azure App Service.

procedure

The procedure is as follows.

  1. Log in with Azure CLI or Portal
  2. Create a resource group with Azure CLI or Portal
  3. Register the image to be used in Azure Container Registry (ACR) with Azure CLI or Portal
  4. Create a Docker Image for your Rails app
  5. Push the Docker Image of the Rails app created with the Azure CLI to the ACR
  6. Create an App Service Plan with Azure CLI or Portal
  7. Create an App Service by specifying the App Service Plan and Docker Image of ACR as parameters in Azure CLI or Portal.
  8. Associate App Service with ACR with Azure CLI or Portal
  9. Set the CD for App Service with Azure CLI or Portal
  10. Set up a webhook on the ACR with the Azure CLI or Portal
  11. Setting environment variables in Azure CLI or Portal

The following is an example of the execution command in Azure CLI.

1. Log in with the Azure CLI

$ az login

2. Create a resource group with Azure CLI

$ az group create --name [Resource group name] --location [Resource group location]

3. Register the image to be used in Azure Container Registry (ACR) with Azure CLI

$ az acr create --resource-group [Resource group name] --name [ACR name] --sku [Choice of favorite] --admin-enabled true --location [Same location as the resource group]

4. Create a Docker Image for your Rails app

(Skip because it is not Azure CLI)

5. Push the Docker Image of the Rails app created with the Azure CLI to the ACR

$ az acr login --name [ACR name]
$ docker push [ACR name and tag]

6. Create an App Service Plan with Azure CLI

$ az appservice plan create --resource-group [Resource group name] --name [App Service Plan name] --sku [Specify B1 or S1] --location [Same location as the resource group] --is-linux

7. Create an App Service with the App Service Plan and ACR Docker Image as parameters in the Azure CLI.

$ az webapp create --resource-group [Resource group name] --plan [App Service Plan name] --name [App Service name] --deployment-container-image-name [ACR name and tag]

8. Associate App Service with ACR with Azure CLI

$ az webapp config container set --name [App Service name] --resource-group [Resource group name] --docker-custom-image-name [ACR name and tag] --docker-registry-server-url [ACR location] --docker-registry-server-user [ACR name] --docker-registry-server-password [ACR Password]

9. Set the CD for App Service with Azure CLI or Portal

$ az webapp deployment container config --resource-group [Resource group name] --name [App Service name] --enable-cd true

10. Set up a webhook on the ACR with the Azure CLI or Portal

$ az acr webhook create --name [App Service name] --resource-group [Resource group name] --scope [ACR name and tag minus location] --location [Same location as the resource group] --uri [URI] --actions push delete

11. Setting environment variables in Azure CLI or Portal

$ az webapp config appsettings set --settings RAILS_ENV=[Environment name] --name [App Service name] --resource-group [Resource group name]

Recommended Posts

Deploy Rails apps to Azure App Service using Docker & Continuous Deployment
[Java] Deploy the Spring Boot application to Azure App Service
How to deploy jQuery in your Rails app using Webpacker
Deploy Rails on Docker to heroku
War deploy to Azure Web Apps (maven)
Migrate existing Rails 6 apps to Docker environment
Deploy to heroku with Docker (Rails 6, MySQL)
Try deploying Rails app to EC2-Part 2 (Deploy)-
Deploy Java web app to Azure with maven
Migrate ASP.NET Framework apps that rely on ODBC drivers to Azure App Service
Rails deploy with Docker
[Rails] Create sitemap using sitemap_generator and deploy to GAE
[Rails 6] Dockerize existing Rails apps [Docker]
I was able to deploy the Docker + laravel + MySQL app to Heroku!
How to deploy jQuery on Rails
How to deploy Bootstrap on Rails
[Rails] Reflection to db using seeds.rb
Build Redmine on Azure App Service
How to build CloudStack using Docker
Deploy your Rails app on Heroku
Inexperienced create a weather app using OpenWeatherMap and deploy it to Netlify
How to build a Ruby on Rails environment using Docker (for Docker beginners)
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
Ruby on Rails ✕ Docker ✕ MySQL Introducing Docker and docker-compose to apps under development
[AWS] How to automatically deploy a Web application created with Rails 6 to ECR / ECS using CircleCI ① Preparation [Container deployment]