diff --git a/.azure/azure-pipelines.development.yml b/.azure/azure-pipelines.development.yml new file mode 100644 index 00000000..4cce47fe --- /dev/null +++ b/.azure/azure-pipelines.development.yml @@ -0,0 +1,68 @@ +trigger: + branches: + include: + - development + +pool: + vmImage: 'ubuntu-latest' + +variables: + dotnetConfiguration: 'Debug' + dotnetSolution: '$(System.DefaultWorkingDirectory)/NArchitecture.sln' + dotnetStartupProject: '$(System.DefaultWorkingDirectory)/src/starterProject/WebAPI/WebAPI.csproj' + dotnetEnvironmentName: 'Development' + +steps: +- script: git submodule update --init --recursive + name: 'DownloadGitSubmodules' + displayName: 'Download Git Submodules' + +- task: NuGetToolInstaller@1 + name: 'InstallNuGet' + displayName: 'Install NuGet Tool' + +- task: NuGetCommand@2 + name: 'RestoreNuGetPackages' + displayName: 'Restore NuGet Packages' + inputs: + command: 'restore' + restoreSolution: '$(dotnetSolution)' + feedsToUse: 'select' + +# - task: DotNetCoreCLI@2 +# name: 'RestoreDotnetTools' +# displayName: 'Restore Dotnet Tools' +# inputs: +# command: 'custom' +# custom: 'tool' +# arguments: 'restore' + +- task: DotNetCoreCLI@2 + name: 'RunTests' + displayName: 'Run Tests' + inputs: + command: 'test' + projects: '$(dotnetSolution)' + arguments: '--configuration $(dotnetConfiguration)' + +- task: DotNetCoreCLI@2 + name: 'PublishApp' + displayName: 'Publish Application' + inputs: + command: 'publish' + publishWebProjects: false + projects: '$(dotnetStartupProject)' + arguments: '--configuration $(dotnetConfiguration) --output $(Build.ArtifactStagingDirectory)' + zipAfterPublish: false + +# - task: DotNetCoreCLI@2 +# name: 'CreateSQLScripts' +# displayName: 'Create SQL Scripts' +# inputs: +# command: 'custom' +# custom: 'ef' +# arguments: 'migrations script --project $(System.DefaultWorkingDirectory)/src/starterProject/Persistence/Persistence.csproj --context BaseDbContext --startup-project $(dotnetStartupProject) --idempotent --output $(Build.ArtifactStagingDirectory)/SQL/migration.sql -- --environment $(dotnetEnvironmentName)' + +- task: PublishBuildArtifacts@1 + name: 'PublishArtifacts' + displayName: 'Publish Artifacts' \ No newline at end of file diff --git a/.azure/azure-pipelines.production.yml b/.azure/azure-pipelines.production.yml new file mode 100644 index 00000000..39bfb5f2 --- /dev/null +++ b/.azure/azure-pipelines.production.yml @@ -0,0 +1,68 @@ +trigger: + branches: + include: + - production + +pool: + vmImage: 'ubuntu-latest' + +variables: + dotnetConfiguration: 'Release' + dotnetSolution: '$(System.DefaultWorkingDirectory)/NArchitecture.sln' + dotnetStartupProject: '$(System.DefaultWorkingDirectory)/src/starterProject/WebAPI/WebAPI.csproj' + dotnetEnvironmentName: 'Production' + +steps: +- script: git submodule update --init --recursive + name: 'DownloadGitSubmodules' + displayName: 'Download Git Submodules' + +- task: NuGetToolInstaller@1 + name: 'InstallNuGet' + displayName: 'Install NuGet Tool' + +- task: NuGetCommand@2 + name: 'RestoreNuGetPackages' + displayName: 'Restore NuGet Packages' + inputs: + command: 'restore' + restoreSolution: '$(dotnetSolution)' + feedsToUse: 'select' + +# - task: DotNetCoreCLI@2 +# name: 'RestoreDotnetTools' +# displayName: 'Restore Dotnet Tools' +# inputs: +# command: 'custom' +# custom: 'tool' +# arguments: 'restore' + +- task: DotNetCoreCLI@2 + name: 'RunTests' + displayName: 'Run Tests' + inputs: + command: 'test' + projects: '$(dotnetSolution)' + arguments: '--configuration $(dotnetConfiguration)' + +- task: DotNetCoreCLI@2 + name: 'PublishApp' + displayName: 'Publish Application' + inputs: + command: 'publish' + publishWebProjects: false + projects: '$(dotnetStartupProject)' + arguments: '--configuration $(dotnetConfiguration) --output $(Build.ArtifactStagingDirectory)' + zipAfterPublish: false + +# - task: DotNetCoreCLI@2 +# name: 'CreateSQLScripts' +# displayName: 'Create SQL Scripts' +# inputs: +# command: 'custom' +# custom: 'ef' +# arguments: 'migrations script --project $(System.DefaultWorkingDirectory)/src/starterProject/Persistence/Persistence.csproj --context BaseDbContext --startup-project $(dotnetStartupProject) --idempotent --output $(Build.ArtifactStagingDirectory)/SQL/migration.sql -- --environment $(dotnetEnvironmentName)' + +- task: PublishBuildArtifacts@1 + name: 'PublishArtifacts' + displayName: 'Publish Artifacts' \ No newline at end of file diff --git a/.azure/azure-pipelines.staging.yml b/.azure/azure-pipelines.staging.yml new file mode 100644 index 00000000..b5f2f9fa --- /dev/null +++ b/.azure/azure-pipelines.staging.yml @@ -0,0 +1,68 @@ +trigger: + branches: + include: + - staging + +pool: + vmImage: 'ubuntu-latest' + +variables: + dotnetConfiguration: 'Debug' + dotnetSolution: '$(System.DefaultWorkingDirectory)/NArchitecture.sln' + dotnetStartupProject: '$(System.DefaultWorkingDirectory)/src/starterProject/WebAPI/WebAPI.csproj' + dotnetEnvironmentName: 'Staging' + +steps: +- script: git submodule update --init --recursive + name: 'DownloadGitSubmodules' + displayName: 'Download Git Submodules' + +- task: NuGetToolInstaller@1 + name: 'InstallNuGet' + displayName: 'Install NuGet Tool' + +- task: NuGetCommand@2 + name: 'RestoreNuGetPackages' + displayName: 'Restore NuGet Packages' + inputs: + command: 'restore' + restoreSolution: '$(dotnetSolution)' + feedsToUse: 'select' + +# - task: DotNetCoreCLI@2 +# name: 'RestoreDotnetTools' +# displayName: 'Restore Dotnet Tools' +# inputs: +# command: 'custom' +# custom: 'tool' +# arguments: 'restore' + +- task: DotNetCoreCLI@2 + name: 'RunTests' + displayName: 'Run Tests' + inputs: + command: 'test' + projects: '$(dotnetSolution)' + arguments: '--configuration $(dotnetConfiguration)' + +- task: DotNetCoreCLI@2 + name: 'PublishApp' + displayName: 'Publish Application' + inputs: + command: 'publish' + publishWebProjects: false + projects: '$(dotnetStartupProject)' + arguments: '--configuration $(dotnetConfiguration) --output $(Build.ArtifactStagingDirectory)' + zipAfterPublish: false + +# - task: DotNetCoreCLI@2 +# name: 'CreateSQLScripts' +# displayName: 'Create SQL Scripts' +# inputs: +# command: 'custom' +# custom: 'ef' +# arguments: 'migrations script --project $(System.DefaultWorkingDirectory)/src/starterProject/Persistence/Persistence.csproj --context BaseDbContext --startup-project $(dotnetStartupProject) --idempotent --output $(Build.ArtifactStagingDirectory)/SQL/migration.sql -- --environment $(dotnetEnvironmentName)' + +- task: PublishBuildArtifacts@1 + name: 'PublishArtifacts' + displayName: 'Publish Artifacts' \ No newline at end of file diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b03d467a..0af9d626 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -2,6 +2,12 @@ "version": 1, "isRoot": true, "tools": { + "dotnet-ef": { + "version": "8.0.0", + "commands": [ + "dotnet-ef" + ] + }, "csharpier": { "version": "0.22.1", "commands": [ diff --git a/src/starterProject/WebAPI/Program.cs b/src/starterProject/WebAPI/Program.cs index 8aefeb93..df19c443 100644 --- a/src/starterProject/WebAPI/Program.cs +++ b/src/starterProject/WebAPI/Program.cs @@ -44,6 +44,7 @@ }); builder.Services.AddDistributedMemoryCache(); // InMemory + // builder.Services.AddStackExchangeRedisCache(opt => opt.Configuration = "localhost:6379"); // Redis // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/src/starterProject/WebAPI/appsettings.Staging.json b/src/starterProject/WebAPI/appsettings.Staging.json new file mode 100644 index 00000000..fa737486 --- /dev/null +++ b/src/starterProject/WebAPI/appsettings.Staging.json @@ -0,0 +1,104 @@ +{ + "AllowedHosts": "*", + + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + + "ConnectionStrings": { + "BaseDb": "" + }, + + "CacheSettings": { + "SlidingExpiration": 2 + }, + + + "ElasticSearchConfig": { + "ConnectionString": "http://localhost:9200", + "Password": "", + "UserName": "" + }, + + "MailSettings": { + "AuthenticationRequired": false, + "DkimPrivateKey": "secret dkim key", + "DkimSelector": "dkim selector", + "DomainName": "domain name", + "Password": "Passw0rd", + "Port": 25, + "SenderEmail": "nArchitecture@kodlama.io", + "SenderFullName": "NArchitecture Security", + "Server": "127.0.0.1", + "UserName": "narchitecture" + }, + + "CloudinaryAccount": { + "ApiKey": "", + "ApiSecret": "", + "Cloud": "" + }, + + "SeriLogConfigurations": { + "PostgreConfiguration": { + "ConnectionString": "Host=localhost;Port=5432;Database=TestDb;Username=postgres;Password=test;", + "NeedAutoCreateTable": true, + "TableName": "Logs" + }, + "MsSqlConfiguration": { + "AutoCreateSqlTable": true, + "ConnectionString": "data source=NEPTUN\\DVLP2008;initial catalog=TestDb;persist security info=False;user id=sa;password=test^3;", + "TableName": "Logs" + }, + "OracleConfiguration": { + "ConnectionString": "Data Source=localhost:1521;User Id=SYSTEM;Password=test;" + }, + "FileLogConfiguration": { + "FolderPath": "/logs/" + }, + "MSTeamsConfiguration": { + "ChannelHookAdress": "" + }, + "MongoDbConfiguration": { + "Collection": "logs", + "ConnectionString": "mongodb://localhost:27017/customerdb?readPreference=primary&appname=MongoDB%20Compass&ssl=false" + }, + "ElasticSearchConfiguration": { + "ConnectionString": "http://localhost:9200" + }, + "GraylogConfiguration": { + "HostnameOrAddress": "localhost", + "Port": 12201 + }, + "RabbitMQConfiguration": { + "Exchange": "test_exchange", + "ExchangeType": "fanout", + "Hostnames": [ + "localhost" + ], + "Password": "guest", + "Port": 5672, + "RouteKey": "Logs", + "Username": "guest" + } + }, + + "TokenOptions": { + "AccessTokenExpiration": 10, + "Audience": "starterProject@kodlama.io", + "Issuer": "nArchitecture@kodlama.io", + "RefreshTokenTTL": 2, + "SecurityKey": "strongandsecretkeystrongandsecretkey" + }, + + "WebAPIConfiguration": { + "APIDomain": "http://localhost:5278/api", + "AllowedOrigins": [ + "http://localhost:4200", + "http://localhost:5278" + ] + } +} \ No newline at end of file diff --git a/src/starterProject/WebAPI/appsettings.json b/src/starterProject/WebAPI/appsettings.json index c8e83442..50040ade 100644 --- a/src/starterProject/WebAPI/appsettings.json +++ b/src/starterProject/WebAPI/appsettings.json @@ -9,7 +9,7 @@ }, "ConnectionStrings": { - "BaseDb": "Server=HOST_ADDRESS; Database=DATABASE_NAME; User Id=USER; Password=PASSWORD; TrustServerCertificate=True;" + "BaseDb": "" }, "CacheSettings": {