cicd_dotnet6webapi_sql_gitlab_gitlabrunner

CI/CD for Dotnet 6 WebAPI using GitLab runner On-Premise

Stars
1
Committers
3

About the Project

Using GitLab runner to setup CI/CD Pipelines for a Containerized Dotnet 6 Web Application.

Run the Project

  • Debug mode:

    • appsetting.json: Change MSQL Server for TodoItemConnectionString with a valid server name.
      • visual studio: select TodoItem.WebAPI and run the project.
      • using dotnet CLI : navigate to TodoItem.WebAPI, then dotnet run command.
  • Docker:

    • Navigate to root folder... where docker compose files are located, and :
      • docker-compose -f docker-compose.yml -f docker-compose.override.yml build

GitLab - (all on-premise or Hybrid)

  • 1 --> How to run GitLab CE + GitLab Runner - All On-Premise(Not working in Windows OS - Network Issue ):

    • navigate to the project root where ... docker compose files are located and run the following command:
     docker-compose -f docker-compose.gitlab-all-onpremise-networking-issue-in-windows.yml up -d
    
    • Open GitLab via the browser : Gitlab UI
    • Follow this suggested solution to reset Root's password.
    • After creating new repo, navigate to http://localhost:9090/{username|root}/{projectname}/-/settings/ci_cd, and expend runners.
    • Then, disable Enable shared runners for this project
    • Use your cmd to register GitLab Runner to GitLab, by executing the following script:
      docker-compose exec gitlab-runner \
      gitlab-runner register \
      --non-interactive \
      --url "[gitlab-ce IP](https://stackoverflow.com/a/20686101)" \
      --registration-token "[gitlab-runner token](https://devops.stackexchange.com/a/4617)" \
      --executor docker \
      --description "Dotnet 6 Web.API Runner" \
      --docker-image "docker:stable"
    
  • 2 --> How to run GitLab Runner - Hybrid:

    • navigate to the project root where ... docker compose files are located and run the following command:
     docker-compose -f docker-compose.gitlabrunner-on-premise.yml up -d
    
    • Open GitLab via the browser : Gitlab UI
    • After creating new repo, navigate to https://gitlab.com/{username|root}/{projectname}/-/settings/ci_cd, and expend runners.
    • Then, disable Enable shared runners for this project - Shared runners are paid
    • Use your cmd to register GitLab Runner to GitLab, by executing the following script:
      docker-compose exec gitlab-runner \
      gitlab-runner register \
      --non-interactive \
      --url "https://gitlab.com/" \
      --registration-token "project runner token" \
      --executor docker \
      --description "Dotnet 6 Web.API Runner" \
      --docker-image "docker:stable"
    

Used Tech

References