From 869d1f2ef12ac444046ae934cf756028608fcc5f Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Tue, 2 Sep 2025 18:19:20 +0330 Subject: [PATCH] ... --- .dockerignore | 30 ++++++++++++++++ Presentation/Hushian.WebApi/DockerCommand.txt | 3 ++ Presentation/Hushian.WebApi/Dockerfile | 35 +++++++++++++++++++ .../Hushian.WebApi/Hushian.WebApi.csproj | 4 +++ .../Properties/launchSettings.json | 32 ++++++++++------- Presentation/HushianWebApp/Program.cs | 2 +- 6 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 .dockerignore create mode 100644 Presentation/Hushian.WebApi/DockerCommand.txt create mode 100644 Presentation/Hushian.WebApi/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.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/Presentation/Hushian.WebApi/DockerCommand.txt b/Presentation/Hushian.WebApi/DockerCommand.txt new file mode 100644 index 0000000..177f0d5 --- /dev/null +++ b/Presentation/Hushian.WebApi/DockerCommand.txt @@ -0,0 +1,3 @@ +E:\_hushian> docker build -f Presentation\Hushian.WebApi\Dockerfile -t hushianapi . + +docker run --name hushian_api -d -p 8080:8080 [imageid] \ No newline at end of file diff --git a/Presentation/Hushian.WebApi/Dockerfile b/Presentation/Hushian.WebApi/Dockerfile new file mode 100644 index 0000000..53f037d --- /dev/null +++ b/Presentation/Hushian.WebApi/Dockerfile @@ -0,0 +1,35 @@ +# 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:9.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:9.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["Presentation/Hushian.WebApi/Hushian.WebApi.csproj", "Presentation/Hushian.WebApi/"] +COPY ["Common/Common.csproj", "Common/"] +COPY ["Hushian.Application/Hushian.Application.csproj", "Hushian.Application/"] +COPY ["Hushian.Domain/Hushian.Domain.csproj", "Hushian.Domain/"] +COPY ["Infrastructure/Infrastructure/Hushian.Infrastructure.csproj", "Infrastructure/Infrastructure/"] +COPY ["Infrastructure/Persistence/Hushian.Persistence.csproj", "Infrastructure/Persistence/"] +RUN dotnet restore "./Presentation/Hushian.WebApi/Hushian.WebApi.csproj" +COPY . . +WORKDIR "/src/Presentation/Hushian.WebApi" +RUN dotnet build "./Hushian.WebApi.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 "./Hushian.WebApi.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", "Hushian.WebApi.dll"] \ No newline at end of file diff --git a/Presentation/Hushian.WebApi/Hushian.WebApi.csproj b/Presentation/Hushian.WebApi/Hushian.WebApi.csproj index 7f64e23..51b5a70 100644 --- a/Presentation/Hushian.WebApi/Hushian.WebApi.csproj +++ b/Presentation/Hushian.WebApi/Hushian.WebApi.csproj @@ -4,6 +4,9 @@ net9.0 enable enable + a648da2d-f055-444d-91e3-3d53de7d1f5a + Linux + ..\.. @@ -16,6 +19,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Presentation/Hushian.WebApi/Properties/launchSettings.json b/Presentation/Hushian.WebApi/Properties/launchSettings.json index aa32003..a31322a 100644 --- a/Presentation/Hushian.WebApi/Properties/launchSettings.json +++ b/Presentation/Hushian.WebApi/Properties/launchSettings.json @@ -1,23 +1,31 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", +{ "profiles": { "http": { "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "http://localhost:5089", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5089" }, "https": { "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:7046;http://localhost:5089", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7046;http://localhost:5089" + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true } - } -} + }, + "$schema": "https://json.schemastore.org/launchsettings.json" +} \ No newline at end of file diff --git a/Presentation/HushianWebApp/Program.cs b/Presentation/HushianWebApp/Program.cs index 4496975..55e72d6 100644 --- a/Presentation/HushianWebApp/Program.cs +++ b/Presentation/HushianWebApp/Program.cs @@ -8,7 +8,7 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5089/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:8080/api/") }); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped();