stevo
stevo

Reputation: 2284

Setup Azure Pipelines for a Azure multi container app (multiple repositories)

I currently have a web app split into three parts. Each part has its own git repository.

  1. Frontend Angular (foo.bar)
  2. Backend Angular (foo.bar/admin)
  3. .NET Core API (foo.bar/api)

In front sits an NGINX Server which acts as a reverse proxy. Currently, it all runs on a VM together with a Jenkins Server which allows me to develop and deploy each part separately, which I really like.

I would like to containerize the application and move it to Azure Web Service for Containers. For the CD/CI I would like to use Azure DevOps & Azure Pipelines. Since Azure Web Service for Containers supports multi-container via Docker Compose and Kubernetes.

The main question is: How can I build and deploy one specific container (e.g. Azure/frontend:10) in the multi-container (via Docker Compose) environment? (Without building all the other containers)

If that is possible...

Or do I need to use Kubernetes?

Alternately I could use three different App Webs on the same Service Plan and control it per domain/sub-domain.

  1. Frontend Angular (foo.bar)
  2. Backend Angular (admin.foo.bar)
  3. .NET Core API (api.foo.bar)

I don’t know where to start. It is a small project too. I don’t want to make it too complicated.

Any tip is more than welcome. Thanks in advance!

Upvotes: 2

Views: 1778

Answers (2)

Johnathan Enslin
Johnathan Enslin

Reputation: 355

You can use a container registry which will allow you to use docker to build each individual containers. You can then deploy a multi container app using containers from the container registry.

Building the container file follows the standard methods allowing you to copy configure and so forth. Once built you can push these by tagging them as follows: container_registry_name/container_name:{{.Run.ID}}

I would suggest based on the provided sample using a production database instead of a container as I have run into issues where a db data gets reset on container restart. Volumes for files can be persisted with the below:

  • ${WEBAPP_STORAGE_HOME}/something/another:/var/www/html

Docker-Compose for containers does not (currently) allow you to use build in the azure pipeline as its meant for deployment only

One will need first build the dockerfiles and then reference your newly stored container registry images in docker-compose.yml. Also please take note that you cannot simply reference a docker hub image and a container registry image in the same compose file. You will need to pull and tag or build and tag the container to use it in that way. You can either use container registry images or public images.

In order to for your app to be able to connect to these images you need to add this to your app settings as well as allow admin in the container registry service:

 DOCKER_REGISTRY_SERVER_USERNAME = [azure-container-registry-name]
 DOCKER_REGISTRY_SERVER_URL = [azure-container-registry-name].azurecr.io
 DOCKER_REGISTRY_SERVER_PASSWORD = [password]

Once you have your basic app setup you can then configure your continous integration options for further development such as webhooks, build options and so forth.

Upvotes: 0

Charles Xu
Charles Xu

Reputation: 31452

I do not have experience with Azure Pipelines, but there are some ideas about Azure Container Registry and the Azure Web App for Container.

First, if you just want to build one specific container in the multi-container via Docker compose, you can just set this in the tutorial:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

The compose also can be work with one container set in the file.

Second, the compose file can be everywhere that you run the command to create Web App for Container. For example, you can run the CLI command in your local machine with the compose file that store in your local machine.

Third, if you use Azure Web App for Container, you should prepare the docker image ready before in your repository, for example, the Azure Container Registry. It does not like docker compose installed in your local machine.

The AKS is also a good choice. You can create the service one by one or set them all in one yaml file. It's quite flexible.

Hope this will help you. If you need more help about the AKS or ACR please give the message.

Upvotes: 2

Related Questions