In this article we will use a simple web app and api application to create a build pipeline to build this application and service in docker container using docker-compose file. Download the Web pp and api from this github link- https://github.com/subudear/dockercomposeexample
Push these folders and files to VSTS repo and start creating build pipeline as explained below-
1. Go To Pipelines–>Builds and click “New Build Pipeline” to create new build definition
2. Select a source – Azure Repos Git and set the Team Project and Repository pointing to your setup-
3. Select a Empty job template-
4. Set the Name and select the build agent from the pool. I have used the self hosted Linux agent. You have to install docker-compose manually on the agent box before running the build-
5. Add a task “Docker Compose”-
6. Configure the task with Docker compose file path and add the Action and Command-
7. Save and queue the build definition. This will create the build and deploy the containers for web app and api on the self hosted agent box. The logs will look something like this-
8. You can access the Web app using the url-
http://<IP of self hosted agent box>:5002
The output on browser will be something like-