Linux AOT and Container

This commit is contained in:
Mike Phares 2025-02-09 15:21:13 -07:00
parent 7aada4303e
commit 264b6319cb
5 changed files with 138 additions and 1 deletions

100
.vscode/tasks.json vendored
View File

@ -58,12 +58,95 @@
"type": "process", "type": "process",
"args": [ "args": [
"build", "build",
"-r",
"win-x64",
"${workspaceFolder}/File-Folder-Helper.csproj", "${workspaceFolder}/File-Folder-Helper.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{
"label": "build Linux",
"command": "dotnet",
"type": "process",
"args": [
"build",
"-r",
"linux-x64",
"${workspaceFolder}/File-Folder-Helper.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "podmanLogin",
"command": "podman",
"type": "process",
"args": [
"login",
"gitea.phares.duckdns.org:443"
],
"problemMatcher": "$msCompile"
},
{
"label": "podmanBuild",
"command": "podman",
"type": "process",
"args": [
"build",
"-t",
"file-folder-helper",
"."
],
"problemMatcher": "$msCompile"
},
{
"label": "podmanImageList",
"command": "podman",
"type": "process",
"args": [
"image",
"ls"
],
"problemMatcher": "$msCompile"
},
{
"label": "podmanRun",
"command": "podman",
"type": "process",
"args": [
"run",
"-p",
"5001:5001",
"--name",
"file-folder-helper-001",
"a3de856b5731"
],
"problemMatcher": "$msCompile"
},
{
"label": "podmanTag",
"command": "podman",
"type": "process",
"args": [
"tag",
"a3de856b5731",
"gitea.phares.duckdns.org:443/phares3757/file-folder-helper:latest"
],
"problemMatcher": "$msCompile"
},
{
"label": "podmanPush",
"command": "podman",
"type": "process",
"args": [
"push",
"gitea.phares.duckdns.org:443/phares3757/file-folder-helper:latest"
],
"problemMatcher": "$msCompile"
},
{ {
"label": "publish", "label": "publish",
"command": "dotnet", "command": "dotnet",
@ -105,6 +188,23 @@
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{
"label": "Publish AOT Linux",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"-r",
"linux-x64",
"-c",
"Release",
"-p:PublishAot=true",
"${workspaceFolder}/File-Folder-Helper.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{ {
"label": "File-Folder-Helper AOT s J Verdaccio", "label": "File-Folder-Helper AOT s J Verdaccio",
"type": "shell", "type": "shell",

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
# Stage 1: Build Stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# restore
COPY ["src/File-Folder-Helper/File-Folder-Helper.csproj", "File-Folder-Helper/"]
RUN dotnet restore 'File-Folder-Helper/File-Folder-Helper.csproj'
# build
COPY ["src/File-Folder-Helper", "File-Folder-Helper/"]
WORKDIR /src/File-Folder-Helper
RUN dotnet build 'File-Folder-Helper.csproj' -c Release -o /app/build
# Stage 2: Publish Stage
FROM build AS publish
RUN dotnet publish 'File-Folder-Helper.csproj' -c Release -o /app/publish
# Stage 3: Run Stage
FROM mcr.microsoft.com/dotnet/aspnet:8.0
ENV ASPNETCORE_HTTP_PORTS=5001
EXPOSE 5001
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [ "dotnet", "File-Folder-Helper.dll" ]

View File

@ -4,7 +4,7 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64;linux-x64</RuntimeIdentifier>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<UserSecretsId>8da397d4-13ec-4576-9722-3c79cad25563</UserSecretsId> <UserSecretsId>8da397d4-13ec-4576-9722-3c79cad25563</UserSecretsId>
<UserSecretsIdWindowsShortcut>eb9e8f58-fcb5-45bb-9d4d-54f064c485b1</UserSecretsIdWindowsShortcut> <UserSecretsIdWindowsShortcut>eb9e8f58-fcb5-45bb-9d4d-54f064c485b1</UserSecretsIdWindowsShortcut>

6
docker-compose.yaml Normal file
View File

@ -0,0 +1,6 @@
services:
webapp:
container_name: file-folder-helper
build:
context: .
dockerfile: Dockerfile

6
global.json Normal file
View File

@ -0,0 +1,6 @@
{
"sdk": {
"rollForward": "latestMinor",
"version": "8.0.112"
}
}