Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3c22289cf | ||
|
|
d9b58b0502 | ||
|
|
6a1dc75b3b | ||
|
|
57b35ae431 | ||
|
|
4e25c0179e | ||
|
|
0a0f1ea10a |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.vs/
|
||||
@@ -4,9 +4,10 @@ stages: # Define the stages of the pipeline.
|
||||
#- test
|
||||
- release
|
||||
|
||||
install-job: # This job runs in the build stage, which runs first.
|
||||
web-build: # This job runs in the build stage, which runs first.
|
||||
stage: build
|
||||
image: node:24
|
||||
parallel: 2
|
||||
script:
|
||||
- cd Web
|
||||
- npm install
|
||||
@@ -15,12 +16,27 @@ install-job: # This job runs in the build stage, which runs first.
|
||||
paths:
|
||||
- Web/dist/Web/browser # The 'dist' directory will be available in the next stage.
|
||||
|
||||
api-build:
|
||||
stage: build
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
parallel: 2
|
||||
script:
|
||||
- cd Api
|
||||
- dotnet publish Api.csproj --output ./build --runtime linux-x64 --configuration Release --self-contained true
|
||||
artifacts:
|
||||
paths:
|
||||
- Api/build
|
||||
when: on_success
|
||||
access: all
|
||||
expire_in: 30 days
|
||||
|
||||
semantic-release:
|
||||
image: node:24
|
||||
stage: release
|
||||
script:
|
||||
- apt update && apt install zip -y
|
||||
- zip -r dist.zip Web/dist/Web/browser
|
||||
- zip -r api.zip Api/build
|
||||
- npm install --save-dev @semantic-release/gitlab
|
||||
- npx semantic-release --debug
|
||||
only:
|
||||
@@ -33,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."
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"@semantic-release/gitlab"
|
||||
],
|
||||
"assets": [
|
||||
{ "path": "dist.zip", "label": "bundle" },
|
||||
{ "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" }
|
||||
]
|
||||
}
|
||||
|
||||
5
Api/.config/dotnet-tools.json
Normal file
5
Api/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {}
|
||||
}
|
||||
30
Api/.dockerignore
Normal file
30
Api/.dockerignore
Normal file
@@ -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/**
|
||||
4
Api/.gitignore
vendored
Normal file
4
Api/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
obj/
|
||||
bin/
|
||||
.vs/
|
||||
build/
|
||||
21
Api/Api.csproj
Normal file
21
Api/Api.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>aspnet-Api-50db7f4c-1c75-467a-a923-a5477d7decc4</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>.</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" NoWarn="NU1605" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.18" NoWarn="NU1605" />
|
||||
<PackageReference Include="Microsoft.Identity.Web" Version="3.10.0" />
|
||||
<PackageReference Include="Microsoft.Identity.Web.DownstreamApi" Version="3.10.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
9
Api/Api.csproj.user
Normal file
9
Api/Api.csproj.user
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ActiveDebugProfile>https</ActiveDebugProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
6
Api/Api.http
Normal file
6
Api/Api.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@Api_HostAddress = http://localhost:5012
|
||||
|
||||
GET {{Api_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
31
Api/Api.sln
Normal file
31
Api/Api.sln
Normal file
@@ -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
|
||||
37
Api/Controllers/WeatherForecastController.cs
Normal file
37
Api/Controllers/WeatherForecastController.cs
Normal file
@@ -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<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Api/Dockerfile
Normal file
30
Api/Dockerfile
Normal file
@@ -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"]
|
||||
45
Api/Program.cs
Normal file
45
Api/Program.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Api/Properties/launchSettings.json
Normal file
42
Api/Properties/launchSettings.json
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Api/WeatherForecast.cs
Normal file
13
Api/WeatherForecast.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
8
Api/appsettings.Development.json
Normal file
8
Api/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Api/appsettings.json
Normal file
23
Api/appsettings.json
Normal file
@@ -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": "*"
|
||||
}
|
||||
2
Tests/.gitignore
vendored
Normal file
2
Tests/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
obj/
|
||||
bin/
|
||||
38
Tests/IntegrationTest1.cs
Normal file
38
Tests/IntegrationTest1.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace Tests.Tests
|
||||
{
|
||||
public class IntegrationTest1
|
||||
{
|
||||
// Instructions:
|
||||
// 1. Add a project reference to the target AppHost project, e.g.:
|
||||
//
|
||||
// <ItemGroup>
|
||||
// <ProjectReference Include="../MyAspireApp.AppHost/MyAspireApp.AppHost.csproj" />
|
||||
// </ItemGroup>
|
||||
//
|
||||
// 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<Projects.MyAspireApp_AppHost>();
|
||||
// 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<ResourceNotificationService>();
|
||||
// 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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
27
Tests/Tests.csproj
Normal file
27
Tests/Tests.csproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.Testing" Version="9.3.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System.Net" />
|
||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<Using Include="Aspire.Hosting.ApplicationModel" />
|
||||
<Using Include="Aspire.Hosting.Testing" />
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user