mirror of
https://github.com/mmahdium/HoolIt.git
synced 2025-08-02 16:04:26 +02:00
Initial commit
This commit is contained in:
25
.dockerignore
Normal file
25
.dockerignore
Normal 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
|
21
HoolIt.sln
Normal file
21
HoolIt.sln
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HoolIt", "HoolIt\HoolIt.csproj", "{E3812095-9B4D-4A38-B33C-84214FBB7620}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5DD66A23-C25C-4F51-82D3-95A4AC05768B}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
compose.yaml = compose.yaml
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E3812095-9B4D-4A38-B33C-84214FBB7620}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E3812095-9B4D-4A38-B33C-84214FBB7620}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E3812095-9B4D-4A38-B33C-84214FBB7620}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E3812095-9B4D-4A38-B33C-84214FBB7620}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
23
HoolIt/Dockerfile
Normal file
23
HoolIt/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||||
|
USER $APP_UID
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 8080
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["HoolIt/HoolIt.csproj", "HoolIt/"]
|
||||||
|
RUN dotnet restore "HoolIt/HoolIt.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/HoolIt"
|
||||||
|
RUN dotnet build "HoolIt.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "HoolIt.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "HoolIt.dll"]
|
18
HoolIt/HoolIt.csproj
Normal file
18
HoolIt/HoolIt.csproj
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
<PublishAot>true</PublishAot>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\.dockerignore">
|
||||||
|
<Link>.dockerignore</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
11
HoolIt/HoolIt.http
Normal file
11
HoolIt/HoolIt.http
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@HoolIt_HostAddress = http://localhost:5246
|
||||||
|
|
||||||
|
GET {{HoolIt_HostAddress}}/todos/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{HoolIt_HostAddress}}/todos/1
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
35
HoolIt/Program.cs
Normal file
35
HoolIt/Program.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateSlimBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.ConfigureHttpJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
|
||||||
|
});
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
var sampleTodos = new Todo[]
|
||||||
|
{
|
||||||
|
new(1, "Walk the dog"),
|
||||||
|
new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)),
|
||||||
|
new(3, "Do the laundry", DateOnly.FromDateTime(DateTime.Now.AddDays(1))),
|
||||||
|
new(4, "Clean the bathroom"),
|
||||||
|
new(5, "Clean the car", DateOnly.FromDateTime(DateTime.Now.AddDays(2)))
|
||||||
|
};
|
||||||
|
|
||||||
|
var todosApi = app.MapGroup("/todos");
|
||||||
|
todosApi.MapGet("/", () => sampleTodos);
|
||||||
|
todosApi.MapGet("/{id}", (int id) =>
|
||||||
|
sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo
|
||||||
|
? Results.Ok(todo)
|
||||||
|
: Results.NotFound());
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
public record Todo(int Id, string? Title, DateOnly? DueBy = null, bool IsComplete = false);
|
||||||
|
|
||||||
|
[JsonSerializable(typeof(Todo[]))]
|
||||||
|
internal partial class AppJsonSerializerContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
HoolIt/Properties/launchSettings.json
Normal file
15
HoolIt/Properties/launchSettings.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "todos",
|
||||||
|
"applicationUrl": "http://localhost:5246",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
HoolIt/appsettings.Development.json
Normal file
8
HoolIt/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
compose.yaml
Normal file
6
compose.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
hoolit:
|
||||||
|
image: hoolit
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: HoolIt/Dockerfile
|
Reference in New Issue
Block a user