Docker CI Pipeline
-
Project: nopCommerce
-
code Refer Here
-
pre-reqs
- docker
curl -fsSL https://get.docker.com -o install-docker.sh sh install-docker.sh sudo usermod -aG docker <username> exit # relogin -
Get the code locally
git clone https://github.com/nopSolutions/nopCommerce.git
- Now build the code
cd nopCommerce
docker image build -t nopcommerce:latest .
- After this execute the command
docker image ls
- Lets make this work in our azure devops, import repository
- Lets consider CI as a stage
- Create a pipeline
---
stages:
- stage: ci
displayName: building code
jobs:
- job: docker
displayName: Build Image on Docker
pool:
vmImage: ubuntu-22.04
steps:
- task: Docker@2
inputs:
command: build
buildContext: '**'
Dockerfile: '**/Dockerfile'
- Exercise: Write a pipeline as collection of jobs with exactly same steps.
---
jobs:
- job: docker
displayName: Build using Docker
pool:
vmImage: ubuntu-22.04
steps:
- task: Docker@2
inputs:
command: build
buildContext: '**'
Dockerfile: '**/Dockerfile'
- Lets build a Project Refer Here
- Jobs:
- Dotnet build
dotnet build eShopOnWeb.sln
- Docker build
docker compose build
- Dotnet build
- Jobs:
- Dotnet build Tasks: Refer Here
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: eShopOnWeb.sln
- Docker compose build Refer Here
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
dockerComposeFile: '**/docker-compose.yml'
action: Build services
- Pipeline
---
jobs:
- job: dotnetbuild
displayName: Build using Dotnet
pool:
vmImage: ubuntu-22.04
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: eShopOnWeb.sln
- job: dockercompose
displayName: Build using Docker Compose
pool:
vmImage: ubuntu-22.04
steps:
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
dockerComposeFile: '**/docker-compose.yml'
action: Build services
- Lets express the same as two different stages
---
stages:
- stage: dotnet
jobs:
- job: dotnetbuild
displayName: Build using Dotnet
pool:
vmImage: ubuntu-22.04
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: eShopOnWeb.sln
- stage: docker
dependsOn: dotnet
jobs:
- job: dockercompose
displayName: Build using Docker Compose
pool:
vmImage: ubuntu-22.04
steps:
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
dockerComposeFile: '**/docker-compose.yml'
action: Build services
