diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0426a8a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +README.md diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0cad4fb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,40 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/src/EventHub.Web/bin/Debug/net5.0/EventHub.Web.dll", + "args": [], + "cwd": "${workspaceFolder}/src/EventHub.Web", + "stopAtEntry": false, + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + }, + { + "name": "Docker .NET Core Launch", + "type": "docker", + "request": "launch", + "preLaunchTask": "docker-run: debug", + "netCore": { + "appProject": "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..7f054e8 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,99 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "type": "docker-build", + "label": "docker-build: debug", + "dependsOn": [ + "build" + ], + "dockerBuild": { + "tag": "eventhub:dev", + "target": "base", + "dockerfile": "${workspaceFolder}/src/EventHub.Web/Dockerfile", + "context": "${workspaceFolder}", + "pull": true + }, + "netCore": { + "appProject": "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj" + } + }, + { + "type": "docker-build", + "label": "docker-build: release", + "dependsOn": [ + "build" + ], + "dockerBuild": { + "tag": "eventhub:latest", + "dockerfile": "${workspaceFolder}/src/EventHub.Web/Dockerfile", + "context": "${workspaceFolder}", + "pull": true + }, + "netCore": { + "appProject": "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj" + } + }, + { + "type": "docker-run", + "label": "docker-run: debug", + "dependsOn": [ + "docker-build: debug" + ], + "dockerRun": {}, + "netCore": { + "appProject": "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj", + "enableDebugging": true, + "configureSsl": false + } + }, + { + "type": "docker-run", + "label": "docker-run: release", + "dependsOn": [ + "docker-build: release" + ], + "dockerRun": {}, + "netCore": { + "appProject": "${workspaceFolder}/src/EventHub.Web/EventHub.Web.csproj" + } + } + ] +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1b6088b..0e663ca 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,22 +5,18 @@ trigger: - dev - - variables: # Container registry service connection established during pipeline creation - dockerRegistryServiceConnection: '2b7ea4b4-1757-4911-b98e-6cbb012bf891' + dockerRegistryServiceConnection: '0648130a-0d3e-41f3-b92e-fc7f620264e8' imageRepository: 'voloeventhub' containerRegistry: 'voloeventhub.azurecr.io' dockerfilePath: '**/Dockerfile' tag: '$(Build.BuildNumber)' - # Agent VM image name vmImageName: 'ubuntu-latest' - stages: - stage: Build displayName: Build stage @@ -52,13 +48,11 @@ stages: displayName: Deploy pool: vmImage: $(vmImageName) - environment: 'volosofteventhub-6985.default' + environment: 'volosofteventhub.default' strategy: runOnce: deploy: steps: - - - task: KubernetesManifest@0 displayName: Deploy to Kubernetes cluster inputs: @@ -66,8 +60,6 @@ stages: manifests: | $(Pipeline.Workspace)/manifests/deployment.yml $(Pipeline.Workspace)/manifests/service.yml - imagePullSecrets: | - $(imagePullSecret) containers: | $(containerRegistry)/$(imageRepository):$(tag) diff --git a/src/.dockerignore b/src/.dockerignore new file mode 100644 index 0000000..0426a8a --- /dev/null +++ b/src/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +README.md diff --git a/src/EventHub.BackgroundServices/appsettings.json b/src/EventHub.BackgroundServices/appsettings.json index 9c5c6b9..fef526a 100644 --- a/src/EventHub.BackgroundServices/appsettings.json +++ b/src/EventHub.BackgroundServices/appsettings.json @@ -1,9 +1,11 @@ { "ConnectionStrings": { - "Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432" + + "Default": "Server=tcp:volosofteventhub.database.windows.net,1433;Initial Catalog=volosofteventhub;Persist Security Info=False;User ID=volosoft;Password=@Palandoken2021;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" + }, "Redis": { - "Configuration": "127.0.0.1" + "Configuration": "Server=tcp:volosofteventhub.database.windows.net,1433;Initial Catalog=volosofteventhub;Persist Security Info=False;User ID=volosoft;Password=@Palandoken2021;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" }, "StringEncryption": { "DefaultPassPhrase": "TxVIZFPxK33czbbv" diff --git a/src/EventHub.DbMigrator/appsettings.json b/src/EventHub.DbMigrator/appsettings.json index 828fd62..5c40679 100644 --- a/src/EventHub.DbMigrator/appsettings.json +++ b/src/EventHub.DbMigrator/appsettings.json @@ -1,6 +1,8 @@ { "ConnectionStrings": { - "Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432" + + "Default": "Server=tcp:volosofteventhub.database.windows.net,1433;Initial Catalog=volosofteventhub;Persist Security Info=False;User ID=volosoft;Password=@Palandoken2021;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" + }, "IdentityServer": { "Clients": { diff --git a/src/EventHub.HttpApi.Host/.dockerignore b/src/EventHub.HttpApi.Host/.dockerignore new file mode 100644 index 0000000..dbb5e63 --- /dev/null +++ b/src/EventHub.HttpApi.Host/.dockerignore @@ -0,0 +1,15 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +.env +*/bin +*/obj +bin +obj +README.md +LICENSE +.vscode \ No newline at end of file diff --git a/src/EventHub.HttpApi.Host/Dockerfile b/src/EventHub.HttpApi.Host/Dockerfile new file mode 100644 index 0000000..c0e1620 --- /dev/null +++ b/src/EventHub.HttpApi.Host/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +WORKDIR /app +EXPOSE 5002 + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /src +COPY ["src/EventHub.HttpApi.Host/EventHub.HttpApi.Host.csproj", "src/EventHub.HttpApi.Host/"] +RUN dotnet restore "src/EventHub.HttpApi.Host/EventHub.HttpApi.Host.csproj" +COPY . . +WORKDIR "/src/src/EventHub.HttpApi.Host" +RUN dotnet build "EventHub.HttpApi.Host.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "EventHub.HttpApi.Host.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "EventHub.HttpApi.Host.dll"] \ No newline at end of file diff --git a/src/EventHub.HttpApi.Host/appsettings.json b/src/EventHub.HttpApi.Host/appsettings.json index 472e591..a88dd3d 100644 --- a/src/EventHub.HttpApi.Host/appsettings.json +++ b/src/EventHub.HttpApi.Host/appsettings.json @@ -3,10 +3,12 @@ "CorsOrigins": "https://*.EventHub.com,https://localhost:44307,https://localhost:44308" }, "ConnectionStrings": { - "Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432" + + "Default": "Server=tcp:volosofteventhub.database.windows.net,1433;Initial Catalog=volosofteventhub;Persist Security Info=False;User ID=volosoft;Password=@Palandoken2021;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" + }, "Redis": { - "Configuration": "127.0.0.1" + "Configuration": "volosofteventhub.redis.cache.windows.net:6380,password=9Kc6E1lbwy5c+RHR1KZS26JPydYR5SeR8UixdECQWv4=,ssl=True,abortConnect=False" }, "AuthServer": { "Authority": "https://localhost:44313", diff --git a/src/EventHub.HttpApi.Host/manifests/deployment.yml b/src/EventHub.HttpApi.Host/manifests/deployment.yml new file mode 100644 index 0000000..051f3b2 --- /dev/null +++ b/src/EventHub.HttpApi.Host/manifests/deployment.yml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: volosoft-eventhub-httpapi-host-deployment +spec: + selector: + matchLabels: + app: volosoft-eventhub-httpapi-host-pod + replicas: 2 + template: + metadata: + labels: + app: volosoft-eventhub-httpapi-host-pod + spec: + containers: + - name: volosoft-eventhub-httpapi-host-container + image: voloeventhubhttpapihost.azurecr.io/voloeventhubhttpapihost:v1 + resources: + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 5002 \ No newline at end of file diff --git a/src/EventHub.HttpApi.Host/manifests/service.yml b/src/EventHub.HttpApi.Host/manifests/service.yml new file mode 100644 index 0000000..df7aba8 --- /dev/null +++ b/src/EventHub.HttpApi.Host/manifests/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: volosoft-eventhub-httpapi-host-service +spec: + selector: + app: volosoft-eventhub-httpapi-host-pod + ports: + - port: 80 + targetPort: 80 + type: LoadBalancer diff --git a/src/EventHub.IdentityServer/.dockerignore b/src/EventHub.IdentityServer/.dockerignore new file mode 100644 index 0000000..dbb5e63 --- /dev/null +++ b/src/EventHub.IdentityServer/.dockerignore @@ -0,0 +1,15 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +.env +*/bin +*/obj +bin +obj +README.md +LICENSE +.vscode \ No newline at end of file diff --git a/src/EventHub.IdentityServer/Dockerfile b/src/EventHub.IdentityServer/Dockerfile new file mode 100644 index 0000000..d9f8fd5 --- /dev/null +++ b/src/EventHub.IdentityServer/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +WORKDIR /app +EXPOSE 5001 + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /src +COPY ["src/EventHub.IdentityServer/EventHub.IdentityServer.csproj", "src/EventHub.IdentityServer/"] +RUN dotnet restore "src/EventHub.IdentityServer/EventHub.IdentityServer.csproj" +COPY . . +WORKDIR "/src/src/EventHub.IdentityServer" +RUN dotnet build "EventHub.IdentityServer.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "EventHub.IdentityServer.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "EventHub.IdentityServer.dll"] \ No newline at end of file diff --git a/src/EventHub.IdentityServer/appsettings.json b/src/EventHub.IdentityServer/appsettings.json index c9e8b26..2b3f928 100644 --- a/src/EventHub.IdentityServer/appsettings.json +++ b/src/EventHub.IdentityServer/appsettings.json @@ -5,10 +5,12 @@ "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" }, "ConnectionStrings": { - "Default": "Host=localhost;Database=EventHub;Username=root;Password=root;Port=5432" + + "Default": "Server=tcp:volosofteventhub.database.windows.net,1433;Initial Catalog=volosofteventhub;Persist Security Info=False;User ID=volosoft;Password=@Palandoken2021;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" + }, "Redis": { - "Configuration": "127.0.0.1" + "Configuration": "volosofteventhub.redis.cache.windows.net:6380,password=9Kc6E1lbwy5c+RHR1KZS26JPydYR5SeR8UixdECQWv4=,ssl=True,abortConnect=False" }, "StringEncryption": { "DefaultPassPhrase": "TxVIZFPxK33czbbv" diff --git a/src/EventHub.IdentityServer/manifests/deployment.yml b/src/EventHub.IdentityServer/manifests/deployment.yml new file mode 100644 index 0000000..b5301e5 --- /dev/null +++ b/src/EventHub.IdentityServer/manifests/deployment.yml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: volosoft-eventhub-identityserver-deployment +spec: + selector: + matchLabels: + app: volosoft-eventhub-identityserver-pod + template: + metadata: + labels: + app: volosoft-eventhub-identityserver-pod + spec: + containers: + - name: volosoft-eventhub-identityserver-container + image: voloeventhubidentityserver.azurecr.io/voloeventhubidentityserver:v1 + resources: + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 5001 \ No newline at end of file diff --git a/src/EventHub.IdentityServer/manifests/service.yml b/src/EventHub.IdentityServer/manifests/service.yml new file mode 100644 index 0000000..30efb7d --- /dev/null +++ b/src/EventHub.IdentityServer/manifests/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: volosoft-eventhub-identityserver-service +spec: + selector: + app: volosoft-eventhub-identityserver-pod + ports: + - port: 80 + targetPort: 80 + type: LoadBalancer \ No newline at end of file diff --git a/src/EventHub.Web/.dockerignore b/src/EventHub.Web/.dockerignore new file mode 100644 index 0000000..dbb5e63 --- /dev/null +++ b/src/EventHub.Web/.dockerignore @@ -0,0 +1,15 @@ +node_modules +npm-debug.log +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +.env +*/bin +*/obj +bin +obj +README.md +LICENSE +.vscode \ No newline at end of file diff --git a/src/EventHub.Web/Dockerfile b/src/EventHub.Web/Dockerfile new file mode 100644 index 0000000..8a0a056 --- /dev/null +++ b/src/EventHub.Web/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /src +COPY ["src/EventHub.Web/EventHub.Web.csproj", "src/EventHub.Web/"] +RUN dotnet restore "src/EventHub.Web/EventHub.Web.csproj" +COPY . . +WORKDIR "/src/src/EventHub.Web" +RUN dotnet build "EventHub.Web.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "EventHub.Web.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "EventHub.Web.dll"] \ No newline at end of file diff --git a/src/EventHub.Web/appsettings.json b/src/EventHub.Web/appsettings.json index 2d20ae9..870d464 100644 --- a/src/EventHub.Web/appsettings.json +++ b/src/EventHub.Web/appsettings.json @@ -8,7 +8,7 @@ } }, "Redis": { - "Configuration": "127.0.0.1" + "Configuration": "volosofteventhub.redis.cache.windows.net:6380,password=9Kc6E1lbwy5c+RHR1KZS26JPydYR5SeR8UixdECQWv4=,ssl=True,abortConnect=False" }, "AuthServer": { "Authority": "https://localhost:44313", diff --git a/src/EventHub.Web/manifests/deployment.yml b/src/EventHub.Web/manifests/deployment.yml new file mode 100644 index 0000000..37bca0f --- /dev/null +++ b/src/EventHub.Web/manifests/deployment.yml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: volosoft-eventhub-web-deployment +spec: + selector: + matchLabels: + app: volosoft-eventhub-web-pod + template: + metadata: + labels: + app: volosoft-eventhub-web-pod + spec: + containers: + - name: volosoft-eventhub-web-container + image: voloeventhub.azurecr.io/voloeventhub:v1 + resources: + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 80 diff --git a/src/EventHub.Web/manifests/service.yml b/src/EventHub.Web/manifests/service.yml new file mode 100644 index 0000000..a470dfd --- /dev/null +++ b/src/EventHub.Web/manifests/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: volosoft-eventhub-web-service +spec: + selector: + app: volosoft-eventhub-web-pod + ports: + - port: 8080 + targetPort: 80 + type: ClusterIP \ No newline at end of file diff --git a/src/common.props b/src/common.props new file mode 100644 index 0000000..fbef883 --- /dev/null +++ b/src/common.props @@ -0,0 +1,8 @@ + + + latest + 1.0.0 + $(NoWarn);CS1591;CS0436 + app + + \ No newline at end of file