diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a4d6d9c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.vs/
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c58ce84..6e66a9a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,6 +7,7 @@ stages: # Define the stages of the pipeline.
web-build: # This job runs in the build stage, which runs first.
stage: build
image: node:24
+ parallel: 2
script:
- cd Web
- npm install
@@ -18,10 +19,10 @@ web-build: # This job runs in the build stage, which runs first.
api-build:
stage: build
image: mcr.microsoft.com/dotnet/sdk:8.0
+ parallel: 2
script:
- - ls -halt
- cd Api
- - dotnet build Api.csproj --output ./build --runtime linux-x64
+ - dotnet publish Api.csproj --output ./build --runtime linux-x64 --configuration Release --self-contained true
artifacts:
paths:
- Api/build
@@ -48,4 +49,7 @@ deploy-job: # This job runs in the deploy stage.
- deployment
script:
- cp -ir Web/dist/Web/browser/* /var/www/html
+ - systemctl stop api.service
+ - cp -ir Api/build/* /var/api
+ - systemctl start api.service
- echo "Application successfully deployed."
diff --git a/.releaserc.json b/.releaserc.json
index 089d51d..8f5570b 100644
--- a/.releaserc.json
+++ b/.releaserc.json
@@ -12,6 +12,7 @@
],
"assets": [
{ "path": "dist.zip", "label": "Web.zip" },
+ { "path": "api.zip", "label": "Api.zip" },
{ "url": "https://gitlab.lesko.me/marek/centrum/-/blob/main/README.md", "label": "README.md" }
]
}
diff --git a/Api/.config/dotnet-tools.json b/Api/.config/dotnet-tools.json
new file mode 100644
index 0000000..517f9b3
--- /dev/null
+++ b/Api/.config/dotnet-tools.json
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {}
+}
\ No newline at end of file
diff --git a/Api/.dockerignore b/Api/.dockerignore
new file mode 100644
index 0000000..4d72b4f
--- /dev/null
+++ b/Api/.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/Api/.gitignore b/Api/.gitignore
new file mode 100644
index 0000000..b7ccb59
--- /dev/null
+++ b/Api/.gitignore
@@ -0,0 +1,4 @@
+obj/
+bin/
+.vs/
+build/
\ No newline at end of file
diff --git a/Api/Api.csproj b/Api/Api.csproj
new file mode 100644
index 0000000..4dda03a
--- /dev/null
+++ b/Api/Api.csproj
@@ -0,0 +1,21 @@
+
+
+
+ net8.0
+ enable
+ enable
+ aspnet-Api-50db7f4c-1c75-467a-a923-a5477d7decc4
+ Linux
+ .
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Api/Api.csproj.user b/Api/Api.csproj.user
new file mode 100644
index 0000000..96e63d6
--- /dev/null
+++ b/Api/Api.csproj.user
@@ -0,0 +1,9 @@
+
+
+
+ https
+
+
+ ProjectDebugger
+
+
\ No newline at end of file
diff --git a/Api/Api.http b/Api/Api.http
new file mode 100644
index 0000000..3e2645b
--- /dev/null
+++ b/Api/Api.http
@@ -0,0 +1,6 @@
+@Api_HostAddress = http://localhost:5012
+
+GET {{Api_HostAddress}}/weatherforecast/
+Accept: application/json
+
+###
diff --git a/Api/Api.sln b/Api/Api.sln
new file mode 100644
index 0000000..7d308b3
--- /dev/null
+++ b/Api/Api.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36301.6
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "Api.csproj", "{EC86C676-06E8-4011-A4E3-5118543F4728}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "..\Tests\Tests.csproj", "{819F3EDC-F488-4C63-89D0-4BE09CD0C485}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EC86C676-06E8-4011-A4E3-5118543F4728}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EC86C676-06E8-4011-A4E3-5118543F4728}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EC86C676-06E8-4011-A4E3-5118543F4728}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EC86C676-06E8-4011-A4E3-5118543F4728}.Release|Any CPU.Build.0 = Release|Any CPU
+ {819F3EDC-F488-4C63-89D0-4BE09CD0C485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {819F3EDC-F488-4C63-89D0-4BE09CD0C485}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {819F3EDC-F488-4C63-89D0-4BE09CD0C485}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {819F3EDC-F488-4C63-89D0-4BE09CD0C485}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A7800B0A-84E4-432A-9E11-6EF3987291FC}
+ EndGlobalSection
+EndGlobal
diff --git a/Api/Controllers/WeatherForecastController.cs b/Api/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..b9e1680
--- /dev/null
+++ b/Api/Controllers/WeatherForecastController.cs
@@ -0,0 +1,37 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Identity.Web.Resource;
+
+namespace Api.Controllers
+{
+ //[Authorize]
+ [ApiController]
+ [Route("[controller]")]
+ //[RequiredScope(RequiredScopesConfigurationKey = "AzureAd:Scopes")]
+ 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/Api/Dockerfile b/Api/Dockerfile
new file mode 100644
index 0000000..0ed5132
--- /dev/null
+++ b/Api/Dockerfile
@@ -0,0 +1,30 @@
+# 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.
+
+# This stage is used when running from VS in fast mode (Default for Debug configuration)
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
+USER $APP_UID
+WORKDIR /app
+EXPOSE 8080
+EXPOSE 8081
+
+
+# This stage is used to build the service project
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
+ARG BUILD_CONFIGURATION=Release
+WORKDIR /src
+COPY ["Api.csproj", "."]
+RUN dotnet restore "./Api.csproj"
+COPY . .
+WORKDIR "/src/."
+RUN dotnet build "./Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
+
+# This stage is used to publish the service project to be copied to the final stage
+FROM build AS publish
+ARG BUILD_CONFIGURATION=Release
+RUN dotnet publish "./Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
+
+# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "Api.dll"]
\ No newline at end of file
diff --git a/Api/Program.cs b/Api/Program.cs
new file mode 100644
index 0000000..0c98ee1
--- /dev/null
+++ b/Api/Program.cs
@@ -0,0 +1,45 @@
+using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.Identity.Abstractions;
+using Microsoft.Identity.Web;
+using Microsoft.Identity.Web.Resource;
+
+namespace Api
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ var builder = WebApplication.CreateBuilder(args);
+
+ // Add services to the container.
+ //builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
+ // .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));
+
+ 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();
+ // }
+
+ if (!app.Environment.IsDevelopment())
+ {
+ app.UseHttpsRedirection();
+ }
+
+ // app.UseAuthorization();
+
+ app.MapControllers();
+
+ app.Run();
+ }
+ }
+}
diff --git a/Api/Properties/launchSettings.json b/Api/Properties/launchSettings.json
new file mode 100644
index 0000000..a25d3fd
--- /dev/null
+++ b/Api/Properties/launchSettings.json
@@ -0,0 +1,42 @@
+{
+ "profiles": {
+ "https": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "dotnetRunMessages": true,
+ "applicationUrl": "https://localhost:7145;http://localhost:5012"
+ },
+ "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:60760",
+ "sslPort": 44315
+ }
+ }
+}
\ No newline at end of file
diff --git a/Api/WeatherForecast.cs b/Api/WeatherForecast.cs
new file mode 100644
index 0000000..cc42c03
--- /dev/null
+++ b/Api/WeatherForecast.cs
@@ -0,0 +1,13 @@
+namespace Api
+{
+ 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/Api/appsettings.Development.json b/Api/appsettings.Development.json
new file mode 100644
index 0000000..ff66ba6
--- /dev/null
+++ b/Api/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/Api/appsettings.json b/Api/appsettings.json
new file mode 100644
index 0000000..760e771
--- /dev/null
+++ b/Api/appsettings.json
@@ -0,0 +1,23 @@
+{
+/*
+The following identity settings need to be configured
+before the project can be successfully executed.
+For more info see https://aka.ms/dotnet-template-ms-identity-platform
+*/
+ "AzureAd": {
+ "Instance": "https://login.microsoftonline.com/",
+ "Domain": "qualified.domain.name",
+ "TenantId": "22222222-2222-2222-2222-222222222222",
+ "ClientId": "11111111-1111-1111-11111111111111111",
+
+ "Scopes": "access_as_user",
+ "CallbackPath": "/signin-oidc"
+ },
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/Api/core b/Api/core
new file mode 100644
index 0000000..e10e7da
Binary files /dev/null and b/Api/core differ
diff --git a/Tests/.gitignore b/Tests/.gitignore
new file mode 100644
index 0000000..d86ba9f
--- /dev/null
+++ b/Tests/.gitignore
@@ -0,0 +1,2 @@
+obj/
+bin/
\ No newline at end of file
diff --git a/Tests/IntegrationTest1.cs b/Tests/IntegrationTest1.cs
new file mode 100644
index 0000000..77f39f8
--- /dev/null
+++ b/Tests/IntegrationTest1.cs
@@ -0,0 +1,38 @@
+namespace Tests.Tests
+{
+ public class IntegrationTest1
+ {
+ // Instructions:
+ // 1. Add a project reference to the target AppHost project, e.g.:
+ //
+ //
+ //
+ //
+ //
+ // 2. Uncomment the following example test and update 'Projects.MyAspireApp_AppHost' to match your AppHost project:
+ //
+ // [Fact]
+ // public async Task GetWebResourceRootReturnsOkStatusCode()
+ // {
+ // // Arrange
+ // var appHost = await DistributedApplicationTestingBuilder.CreateAsync();
+ // appHost.Services.ConfigureHttpClientDefaults(clientBuilder =>
+ // {
+ // clientBuilder.AddStandardResilienceHandler();
+ // });
+ // // To output logs to the xUnit.net ITestOutputHelper, consider adding a package from https://www.nuget.org/packages?q=xunit+logging
+ //
+ // await using var app = await appHost.BuildAsync();
+ // var resourceNotificationService = app.Services.GetRequiredService();
+ // await app.StartAsync();
+
+ // // Act
+ // var httpClient = app.CreateHttpClient("webfrontend");
+ // await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
+ // var response = await httpClient.GetAsync("/");
+
+ // // Assert
+ // Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ // }
+ }
+}
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
new file mode 100644
index 0000000..683e2fd
--- /dev/null
+++ b/Tests/Tests.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net8.0
+ enable
+ enable
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+