From d38f6da26f3b7765fc79f6e8b0daaff9a5b75431 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 21 Aug 2024 11:00:47 +0200 Subject: [PATCH] setup --- .dockerignore | 30 +++++++++++ .../Controllers/WeatherForecastController.cs | 33 ++++++++++++ Tools/MarketInsights/Dockerfile | 25 +++++++++ Tools/MarketInsights/MarketInsights.csproj | 17 ++++++ .../MarketInsights/MarketInsights.csproj.user | 6 +++ Tools/MarketInsights/MarketInsights.http | 6 +++ Tools/MarketInsights/Program.cs | 36 +++++++++++++ .../Properties/launchSettings.json | 52 +++++++++++++++++++ Tools/MarketInsights/WeatherForecast.cs | 13 +++++ .../appsettings.Development.json | 8 +++ Tools/MarketInsights/appsettings.json | 9 ++++ cs-codex-dist-testing.sln | 7 +++ 12 files changed, 242 insertions(+) create mode 100644 .dockerignore create mode 100644 Tools/MarketInsights/Controllers/WeatherForecastController.cs create mode 100644 Tools/MarketInsights/Dockerfile create mode 100644 Tools/MarketInsights/MarketInsights.csproj create mode 100644 Tools/MarketInsights/MarketInsights.csproj.user create mode 100644 Tools/MarketInsights/MarketInsights.http create mode 100644 Tools/MarketInsights/Program.cs create mode 100644 Tools/MarketInsights/Properties/launchSettings.json create mode 100644 Tools/MarketInsights/WeatherForecast.cs create mode 100644 Tools/MarketInsights/appsettings.Development.json create mode 100644 Tools/MarketInsights/appsettings.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/Tools/MarketInsights/Controllers/WeatherForecastController.cs b/Tools/MarketInsights/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..aeaa51c --- /dev/null +++ b/Tools/MarketInsights/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace MarketInsights.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Tools/MarketInsights/Dockerfile b/Tools/MarketInsights/Dockerfile new file mode 100644 index 0000000..bdecb0f --- /dev/null +++ b/Tools/MarketInsights/Dockerfile @@ -0,0 +1,25 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["Tools/MarketInsights/MarketInsights.csproj", "Tools/MarketInsights/"] +RUN dotnet restore "./Tools/MarketInsights/MarketInsights.csproj" +COPY . . +WORKDIR "/src/Tools/MarketInsights" +RUN dotnet build "./MarketInsights.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./MarketInsights.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "MarketInsights.dll"] \ No newline at end of file diff --git a/Tools/MarketInsights/MarketInsights.csproj b/Tools/MarketInsights/MarketInsights.csproj new file mode 100644 index 0000000..48b3185 --- /dev/null +++ b/Tools/MarketInsights/MarketInsights.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + ae71e621-bb16-41b2-b6f3-c597d2d21157 + Linux + ..\.. + + + + + + + + diff --git a/Tools/MarketInsights/MarketInsights.csproj.user b/Tools/MarketInsights/MarketInsights.csproj.user new file mode 100644 index 0000000..dd2d54c --- /dev/null +++ b/Tools/MarketInsights/MarketInsights.csproj.user @@ -0,0 +1,6 @@ + + + + Container (Dockerfile) + + \ No newline at end of file diff --git a/Tools/MarketInsights/MarketInsights.http b/Tools/MarketInsights/MarketInsights.http new file mode 100644 index 0000000..80a2698 --- /dev/null +++ b/Tools/MarketInsights/MarketInsights.http @@ -0,0 +1,6 @@ +@MarketInsights_HostAddress = http://localhost:5169 + +GET {{MarketInsights_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Tools/MarketInsights/Program.cs b/Tools/MarketInsights/Program.cs new file mode 100644 index 0000000..a8a42a5 --- /dev/null +++ b/Tools/MarketInsights/Program.cs @@ -0,0 +1,36 @@ + +namespace MarketInsights +{ + public class Program + { + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + + builder.Services.AddControllers(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(); + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + + app.UseAuthorization(); + + + app.MapControllers(); + + app.Run(); + } + } +} diff --git a/Tools/MarketInsights/Properties/launchSettings.json b/Tools/MarketInsights/Properties/launchSettings.json new file mode 100644 index 0000000..a856188 --- /dev/null +++ b/Tools/MarketInsights/Properties/launchSettings.json @@ -0,0 +1,52 @@ +{ + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5169" + }, + "https": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7011;http://localhost:5169" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:36575", + "sslPort": 44390 + } + } +} \ No newline at end of file diff --git a/Tools/MarketInsights/WeatherForecast.cs b/Tools/MarketInsights/WeatherForecast.cs new file mode 100644 index 0000000..7849df6 --- /dev/null +++ b/Tools/MarketInsights/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace MarketInsights +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/Tools/MarketInsights/appsettings.Development.json b/Tools/MarketInsights/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Tools/MarketInsights/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Tools/MarketInsights/appsettings.json b/Tools/MarketInsights/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Tools/MarketInsights/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/cs-codex-dist-testing.sln b/cs-codex-dist-testing.sln index 10617f8..89a0f79 100644 --- a/cs-codex-dist-testing.sln +++ b/cs-codex-dist-testing.sln @@ -74,6 +74,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OverwatchTranscript", "Fram EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TranscriptAnalysis", "Tools\TranscriptAnalysis\TranscriptAnalysis.csproj", "{C0EEBD32-23CB-45EC-A863-79FB948508C8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarketInsights", "Tools\MarketInsights\MarketInsights.csproj", "{004614DF-1C65-45E3-882D-59AE44282573}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -196,6 +198,10 @@ Global {C0EEBD32-23CB-45EC-A863-79FB948508C8}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0EEBD32-23CB-45EC-A863-79FB948508C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0EEBD32-23CB-45EC-A863-79FB948508C8}.Release|Any CPU.Build.0 = Release|Any CPU + {004614DF-1C65-45E3-882D-59AE44282573}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {004614DF-1C65-45E3-882D-59AE44282573}.Debug|Any CPU.Build.0 = Debug|Any CPU + {004614DF-1C65-45E3-882D-59AE44282573}.Release|Any CPU.ActiveCfg = Release|Any CPU + {004614DF-1C65-45E3-882D-59AE44282573}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -230,6 +236,7 @@ Global {B57A4789-D8EF-42E0-8D20-581C4057FFD3} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3} {870DDFBE-D7ED-4196-9681-13CA947BDEA6} = {81AE04BC-CBFA-4E6F-B039-8208E9AFAAE7} {C0EEBD32-23CB-45EC-A863-79FB948508C8} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3} + {004614DF-1C65-45E3-882D-59AE44282573} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {237BF0AA-9EC4-4659-AD9A-65DEB974250C}