From 0d137dd7b5e632eeac714e6ab3f24cbd405ea66b Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 17 Apr 2024 15:41:35 +0800 Subject: [PATCH] add dockerfile --- Src/Dlhis.Visitor/Dlhis.Visitor.csproj | 3 +++ Src/Dlhis.Visitor/Dockerfile | 25 +++++++++++++++++++ .../Properties/launchSettings.json | 23 +++++++++++------ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 Src/Dlhis.Visitor/Dockerfile diff --git a/Src/Dlhis.Visitor/Dlhis.Visitor.csproj b/Src/Dlhis.Visitor/Dlhis.Visitor.csproj index 1c1ea281..3e4a2742 100644 --- a/Src/Dlhis.Visitor/Dlhis.Visitor.csproj +++ b/Src/Dlhis.Visitor/Dlhis.Visitor.csproj @@ -5,6 +5,8 @@ disable enable True + Linux + ..\.. @@ -13,6 +15,7 @@ + diff --git a/Src/Dlhis.Visitor/Dockerfile b/Src/Dlhis.Visitor/Dockerfile new file mode 100644 index 00000000..104cb4f1 --- /dev/null +++ b/Src/Dlhis.Visitor/Dockerfile @@ -0,0 +1,25 @@ +#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. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["Src/Dlhis.Visitor/Dlhis.Visitor.csproj", "Src/Dlhis.Visitor/"] +COPY ["Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj", "Src/Dlhis.Basic.Api/"] +COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"] +RUN dotnet restore "./Src/Dlhis.Visitor/./Dlhis.Visitor.csproj" +COPY . . +WORKDIR "/src/Src/Dlhis.Visitor" +RUN dotnet build "./Dlhis.Visitor.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./Dlhis.Visitor.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Dlhis.Visitor.dll"] \ No newline at end of file diff --git a/Src/Dlhis.Visitor/Properties/launchSettings.json b/Src/Dlhis.Visitor/Properties/launchSettings.json index bdb16e59..8499ad17 100644 --- a/Src/Dlhis.Visitor/Properties/launchSettings.json +++ b/Src/Dlhis.Visitor/Properties/launchSettings.json @@ -1,15 +1,22 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", +{ "profiles": { "Dlhis.Visitor": { "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, "launchUrl": "weatherforecast", - "applicationUrl": "http://localhost:5021", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5021" + }, + "Docker": { + "commandName": "Docker", + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast", + "environmentVariables": { + "ASPNETCORE_URLS": "http://+:80" + }, + "publishAllPorts": true } - } -} + }, + "$schema": "https://json.schemastore.org/launchsettings.json" +} \ No newline at end of file