Anto Subash.

Published on

Docker and CI/CD - .NET Microservice with ABP - Part 10

This is the part 10 of the series: .NET Microservice with ABP

Posts in the Series

Part 1. Initial Setup

Part 2. Shared Project

Part 3. Administration Service

Part 4. Identity Service

Part 5. SaaS Service

Part 6. DB Migration

Part 7. Yarp and Tye

Part 8. Identity server and Angular App

Part 9. Distributed event bus

Part 10. Docker and CI/CD (this post)

Part 11. Add a New service

Part 12. Central Logging

Table of contents

Intro

In this post we will see how to add docker support to all the services and setup a CI/CD pipeline with github actions.

Docker support

Docker support can be added easily by using visual studio. since all the project is available in the solution vs will create a Docker file and add it to the project. In this we will use the Identity server it will be similar for all the other services.

To add Docker support right click on the Identity server project and choose add.

Add Docker

In the add menu choose docker support

Add Menu

In the docker file option choose linux

Docker Options

The final docker file will look like this. Here is the location of this sample file https://github.com/antosubash/AbpMicroservice/blob/main/apps/Tasky.IdentityServer/Dockerfile

Docker file

We have to do this to all the services.

CI/CD

Here is the sample github action file.

1name: Docker Image CI
2
3on:
4  push:
5    branches: [ main ]
6  pull_request:
7    branches: [ main ]
8
9jobs:
10
11  build:
12
13    runs-on: ubuntu-latest
14
15    steps:
16    - uses: actions/checkout@v2
17    - name: Build the Gateway Docker image
18      run: docker build . --file gateway/Tasky.Gateway/Dockerfile --tag gateway:dev
19    - name: Build the IdentityServer Docker image
20      run: docker build . --file apps/Tasky.IdentityServer/Dockerfile --tag identityserver:dev
21    - name: Build the Administration Docker image
22      run: docker build . --file services/administration/host/Tasky.AdministrationService.HttpApi.Host/Dockerfile --tag administration:dev
23    - name: Build the IdentityService Docker image
24      run: docker build . --file services/identity/host/Tasky.IdentityService.HttpApi.Host/Dockerfile --tag identityservice:dev
25    - name: Build the SaaS Docker image
26      run: docker build . --file services/saas/host/Tasky.SaaSService.HttpApi.Host/Dockerfile --tag saas:dev