Added backend project

This commit is contained in:
2025-02-28 15:56:27 +01:00
parent 27119c798d
commit 204f1a3e1d
9 changed files with 178 additions and 9 deletions

25
.dockerignore Normal file
View File

@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*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

View File

@@ -1,13 +1,13 @@
image: node:lts-alpine
stages: stages:
- install - install
- lint - lint
- build - build
- test
- publish - publish
install-mobile: install-mobile:
stage: install stage: install
image: node:lts-alpine
before_script: before_script:
- cd src/WorkTime.Mobile - cd src/WorkTime.Mobile
script: script:
@@ -15,12 +15,13 @@ install-mobile:
cache: cache:
key: key:
files: files:
- package.json - src/WorkTime.Mobile/package.json
paths: paths:
- node_modules - src/WorkTime.Mobile/node_modules
lint-mobile: lint-mobile:
stage: lint stage: lint
image: node:lts-alpine
needs: ["install-mobile"] needs: ["install-mobile"]
before_script: before_script:
- cd src/WorkTime.Mobile - cd src/WorkTime.Mobile
@@ -29,13 +30,14 @@ lint-mobile:
cache: cache:
key: key:
files: files:
- package.json - src/WorkTime.Mobile/package.json
paths: paths:
- node_modules - src/WorkTime.Mobile/node_modules
policy: pull policy: pull
build-mobile: build-mobile:
stage: build stage: build
image: node:lts-alpine
needs: ["lint-mobile"] needs: ["lint-mobile"]
before_script: before_script:
- cd src/WorkTime.Mobile - cd src/WorkTime.Mobile
@@ -43,16 +45,35 @@ build-mobile:
- npm run build - npm run build
artifacts: artifacts:
paths: paths:
- $CI_PROJECT_DIR/www - $CI_PROJECT_DIR/src/WorkTime.Mobile/www
expire_in: 10 minutes expire_in: 10 minutes
cache: cache:
key: key:
files: files:
- package.json - src/WorkTime.Mobile/package.json
paths: paths:
- node_modules - src/WorkTime.Mobile/node_modules
policy: pull policy: pull
build-backend:
stage: build
image: mcr.microsoft.com/dotnet/sdk:9.0
script:
- dotnet restore
- dotnet build --configuration Release --no-restore
artifacts:
paths:
- "**/bin/Release"
expire_in: 10 minutes
test-backend:
stage: test
image: mcr.microsoft.com/dotnet/sdk:9.0
script:
- dotnet test --verbosity normal
dependencies:
- build-backend
publish-mobile: publish-mobile:
stage: publish stage: publish
needs: ["build-mobile"] needs: ["build-mobile"]
@@ -70,3 +91,15 @@ publish-mobile:
- docker push registry.leon-hoppe.de/leon.hoppe/worktime:latest - docker push registry.leon-hoppe.de/leon.hoppe/worktime:latest
only: only:
- tags - tags
publish-backend:
stage: publish
script:
- export VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//')
- dotnet pack -c Release -o . /p:Version=$VERSION
- for nupkg in *.nupkg; do dotnet nuget push $nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json; done
only:
- tags
dependencies:
- build-backend
- test-backend

View File

@@ -1,8 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{25C5A6B2-A1F9-4244-9538-18E3FE76D382}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkTime.Api", "src\WorkTime.Api\WorkTime.Api.csproj", "{63F71A39-70D8-4F22-8006-C345E0CD4A5C}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{63F71A39-70D8-4F22-8006-C345E0CD4A5C} = {25C5A6B2-A1F9-4244-9538-18E3FE76D382}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal EndGlobal

View File

@@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/WorkTime.Api/WorkTime.Api.csproj", "src/WorkTime.Api/"]
RUN dotnet restore "src/WorkTime.Api/WorkTime.Api.csproj"
COPY . .
WORKDIR "/src/src/WorkTime.Api"
RUN dotnet build "WorkTime.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "WorkTime.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WorkTime.Api.dll"]

View File

@@ -0,0 +1,15 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) {
app.MapOpenApi();
}
app.UseHttpsRedirection();
app.Run();

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5295",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7294;http://localhost:5295",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0"/>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}