DevOps Classroom Notes – 23/July/2024

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 Tasks: Refer Here
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: eShopOnWeb.sln
- 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
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%