diff --git a/etc/azure/Dockerfile.base b/etc/azure/Dockerfile.base new file mode 100644 index 0000000..5b67d38 --- /dev/null +++ b/etc/azure/Dockerfile.base @@ -0,0 +1,3 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /app +COPY . . \ No newline at end of file diff --git a/etc/azure/azurepipelines.yml b/etc/azure/azurepipelines.yml new file mode 100644 index 0000000..0f96049 --- /dev/null +++ b/etc/azure/azurepipelines.yml @@ -0,0 +1,220 @@ +trigger: + tags: + include: + - "*.*.*" + +resources: + repositories: + - repository: abp-studio + type: github + endpoint: github.com_skoc10 + name: volosoft/abp-studio + ref: main + +variables: + dockerRegistryServiceConnection: 'volosoft-reg' + tag: $(Build.BuildNumber) + DOCKER_BUILDKIT: 1 + +pool: + name: aks-deployer-agent + + +stages: +- stage: Package + displayName: Package + jobs: + - job: Build + displayName: EventHub Build + pool: + name: aks-deployer-agent + + steps: + + - checkout: self + - checkout: abp-studio + + - task: Docker@2 + displayName: Build Base Image + inputs: + command: build + repository: eventhub-base + dockerfile: $(Build.SourcesDirectory)/eventhub/etc/azure/Dockerfile.base + buildContext: $(Build.SourcesDirectory) + tags: | + $(tag) + +# Build images + - task: Docker@2 + displayName: Build DB MIGRATOR + continueOnError: true + inputs: + command: build + repository: eventhub/dbmigrator + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.DbMigrator/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + - task: Docker@2 + displayName: Build WEB + continueOnError: true + inputs: + command: build + repository: eventhub/web + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.Web/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + - task: Docker@2 + displayName: Build API HOST + continueOnError: true + inputs: + command: build + repository: eventhub/apihost + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.HttpApi.Host/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + - task: Docker@2 + displayName: Build ADMIN WEB + continueOnError: true + inputs: + command: build + repository: eventhub/adminweb + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.Admin.Web/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + - task: Docker@2 + displayName: Build ADMIN API HOST + continueOnError: true + inputs: + command: build + repository: eventhub/adminapihost + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.Admin.HttpApi.Host/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + - task: Docker@2 + displayName: Build IDENTITY SERVER + continueOnError: true + inputs: + command: build + repository: eventhub/identityserver + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.IdentityServer/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + - task: Docker@2 + displayName: Build BACKGROUND + continueOnError: true + inputs: + command: build + repository: eventhub/background + dockerfile: $(Build.SourcesDirectory)/eventhub/src/EventHub.BackgroundServices/Dockerfile.azure + buildContext: $(Build.SourcesDirectory) + containerRegistry: $(dockerRegistryServiceConnection) + arguments: "--build-arg=BASE_IMAGE=eventhub-base:$(tag)" + tags: | + $(tag) + + +# Push images + - task: Docker@2 + displayName: Push DB MIGRATOR + continueOnError: true + inputs: + command: push + repository: eventhub/dbmigrator + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + + - task: Docker@2 + displayName: Push WEB + continueOnError: true + inputs: + command: push + repository: eventhub/web + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + + - task: Docker@2 + displayName: Push API HOST + continueOnError: true + inputs: + command: push + repository: eventhub/apihost + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + + - task: Docker@2 + displayName: Push ADMIN WEB + continueOnError: true + inputs: + command: push + repository: eventhub/adminweb + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + + - task: Docker@2 + displayName: Push ADMIN API HOST + continueOnError: true + inputs: + command: push + repository: eventhub/adminapihost + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + + - task: Docker@2 + displayName: Push IDENTITY SERVER + continueOnError: true + inputs: + command: push + repository: eventhub/identityserver + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + + - task: Docker@2 + displayName: Push BACKGROUND + continueOnError: true + inputs: + command: push + repository: eventhub/background + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) + +# Artifact + - bash: | + sed -i "s/eventHubImageVersion: latest/eventHubImageVersion: \"$(tag)\"/" $(Build.SourcesDirectory)/eventhub/etc/k8s/helm-chart/eventhub/values.azure.yaml + + + - task: PublishPipelineArtifact@1 + inputs: + targetPath: '$(Build.SourcesDirectory)/eventhub/etc/k8s/helm-chart/eventhub' + artifact: helm + publishLocation: pipeline \ No newline at end of file diff --git a/etc/k8s/helm-chart/eventhub/values.azure.yaml b/etc/k8s/helm-chart/eventhub/values.azure.yaml index 9ecc82f..c62cd80 100644 --- a/etc/k8s/helm-chart/eventhub/values.azure.yaml +++ b/etc/k8s/helm-chart/eventhub/values.azure.yaml @@ -21,18 +21,18 @@ global: imagePullPolicy: Always eventHubImageVersion: latest account: - containerImage: "volosoft.azurecr.io/eventhub.account" + containerImage: "volosoft.azurecr.io/eventhub/identityserver" api: - containerImage: "volosoft.azurecr.io/eventhub.api" + containerImage: "volosoft.azurecr.io/eventhub/apihost" www: - containerImage: "volosoft.azurecr.io/eventhub.www" + containerImage: "volosoft.azurecr.io/eventhub/web" admin-api: - containerImage: "volosoft.azurecr.io/eventhub.admin-api" + containerImage: "volosoft.azurecr.io/eventhub/adminapihost" admin: - containerImage: "volosoft.azurecr.io/eventhub.admin" + containerImage: "volosoft.azurecr.io/eventhub/adminweb" dbmigrator: - containerImage: "volosoft.azurecr.io/eventhub.dbmigrator" + containerImage: "volosoft.azurecr.io/eventhub/dbmigrator" background-services: - containerImage: "volosoft.azurecr.io/eventhub.background-services" + containerImage: "volosoft.azurecr.io/eventhub/background" nodeSelector: agentpool: demopool \ No newline at end of file diff --git a/src/EventHub.Admin.HttpApi.Host/Dockerfile.azure b/src/EventHub.Admin.HttpApi.Host/Dockerfile.azure new file mode 100644 index 0000000..0067a91 --- /dev/null +++ b/src/EventHub.Admin.HttpApi.Host/Dockerfile.azure @@ -0,0 +1,13 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.Admin.HttpApi.Host +RUN dotnet publish -c Release -o bin/Release/publish + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish +WORKDIR /app +EXPOSE 80 +ENV ASPNETCORE_URLS=http://+:80 +COPY --from=base /app/eventhub/src/EventHub.Admin.HttpApi.Host/bin/Release/publish . +ENTRYPOINT ["dotnet", "EventHub.Admin.HttpApi.Host.dll"] \ No newline at end of file diff --git a/src/EventHub.Admin.Web/Dockerfile.azure b/src/EventHub.Admin.Web/Dockerfile.azure new file mode 100644 index 0000000..e745697 --- /dev/null +++ b/src/EventHub.Admin.Web/Dockerfile.azure @@ -0,0 +1,10 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.Admin.Web +RUN dotnet publish -c Release -o bin/Release/publish + +FROM nginx:latest AS publish +COPY --from=base /app/eventhub/src/EventHub.Admin.Web/bin/Release/publish/wwwroot/ /usr/share/nginx/html/ +COPY --from=base /app/eventhub/src/EventHub.Admin.Web/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/src/EventHub.BackgroundServices/Dockerfile.azure b/src/EventHub.BackgroundServices/Dockerfile.azure new file mode 100644 index 0000000..88eec18 --- /dev/null +++ b/src/EventHub.BackgroundServices/Dockerfile.azure @@ -0,0 +1,13 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.BackgroundServices +RUN dotnet publish -c Release -o bin/Release/publish + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish +WORKDIR /app +EXPOSE 80 +ENV ASPNETCORE_URLS=http://+:80 +COPY --from=base /app/eventhub/src/EventHub.BackgroundServices/bin/Release/publish . +ENTRYPOINT ["dotnet", "EventHub.BackgroundServices.dll"] \ No newline at end of file diff --git a/src/EventHub.DbMigrator/Dockerfile.azure b/src/EventHub.DbMigrator/Dockerfile.azure new file mode 100644 index 0000000..883281e --- /dev/null +++ b/src/EventHub.DbMigrator/Dockerfile.azure @@ -0,0 +1,11 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.DbMigrator +RUN dotnet publish -c Release -o bin/Release/publish + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish +WORKDIR /app +COPY --from=base /app/eventhub/src/EventHub.DbMigrator/bin/Release/publish . +ENTRYPOINT ["dotnet", "EventHub.DbMigrator.dll"] \ No newline at end of file diff --git a/src/EventHub.HttpApi.Host/Dockerfile.azure b/src/EventHub.HttpApi.Host/Dockerfile.azure new file mode 100644 index 0000000..9c3795e --- /dev/null +++ b/src/EventHub.HttpApi.Host/Dockerfile.azure @@ -0,0 +1,13 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.HttpApi.Host +RUN dotnet publish -c Release -o bin/Release/publish + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish +WORKDIR /app +EXPOSE 80 +ENV ASPNETCORE_URLS=http://+:80 +COPY --from=base /app/eventhub/src/EventHub.HttpApi.Host/bin/Release/publish . +ENTRYPOINT ["dotnet", "EventHub.HttpApi.Host.dll"] \ No newline at end of file diff --git a/src/EventHub.IdentityServer/Dockerfile.azure b/src/EventHub.IdentityServer/Dockerfile.azure new file mode 100644 index 0000000..97c0874 --- /dev/null +++ b/src/EventHub.IdentityServer/Dockerfile.azure @@ -0,0 +1,13 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.IdentityServer +RUN dotnet publish -c Release -o bin/Release/publish + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish +WORKDIR /app +EXPOSE 80 +ENV ASPNETCORE_URLS=http://+:80 +COPY --from=base /app/eventhub/src/EventHub.IdentityServer/bin/Release/publish . +ENTRYPOINT ["dotnet", "EventHub.IdentityServer.dll"] \ No newline at end of file diff --git a/src/EventHub.Web/Dockerfile.azure b/src/EventHub.Web/Dockerfile.azure new file mode 100644 index 0000000..40c5640 --- /dev/null +++ b/src/EventHub.Web/Dockerfile.azure @@ -0,0 +1,13 @@ +ARG BASE_IMAGE=base + +FROM ${BASE_IMAGE} AS base + +WORKDIR /app/eventhub/src/EventHub.Web +RUN dotnet publish -c Release -o bin/Release/publish + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish +WORKDIR /app +EXPOSE 80 +ENV ASPNETCORE_URLS=http://+:80 +COPY --from=base /app/eventhub/src/EventHub.Web/bin/Release/publish . +ENTRYPOINT ["dotnet", "EventHub.Web.dll"] \ No newline at end of file