I'm just starting my first steps on the subject and I need help please. My application runs with Docker. I have a Azure Virtual Machine also with Docker installed, and the source code repository in DevOps. It is taking me a while to configure the CI/CD to deploy my application.
I'm creating again and answering my own question because when I created it another time, it turned out to be "too big, and no one was going to give me a 10-page answer." Now after a lot of effort I achieved the goal and I want to share the knowledge acquired.
What I did was:
Pipeline:
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- main
pool:
vmImage: ubuntu-latest
jobs:
- deployment: VMDeploy
displayName: Deploy to VM
environment:
name: VM-ENV
resourceName: VM
resourceType: virtualMachine
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
persistCredentials: true
- script: git -C ~/Dir/to/repo pull
- script: docker compose -f ~/Dir/to/repo/docker-compose.yml up -d
I hope it is helpful to someone else