From 8f881bf0cfc76a8383a0073f3f5d668cfa16fcf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=81=E5=8B=9D=20=E5=BC=B5?= Date: Wed, 7 Feb 2024 00:19:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EDOCKER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 30 +++++++++++++++ WebApi_data_value/Dockerfile | 24 ++++++++++++ .../Properties/launchSettings.json | 38 ++++++++++++------- WebApi_data_value/WebApi_data_value.csproj | 2 + 4 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 .dockerignore create mode 100644 WebApi_data_value/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/WebApi_data_value/Dockerfile b/WebApi_data_value/Dockerfile new file mode 100644 index 0000000..c1d4d6d --- /dev/null +++ b/WebApi_data_value/Dockerfile @@ -0,0 +1,24 @@ +#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 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["WebApi_data_value/WebApi_data_value.csproj", "WebApi_data_value/"] +RUN dotnet restore "./WebApi_data_value/./WebApi_data_value.csproj" +COPY . . +WORKDIR "/src/WebApi_data_value" +RUN dotnet build "./WebApi_data_value.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./WebApi_data_value.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "WebApi_data_value.dll"] \ No newline at end of file diff --git a/WebApi_data_value/Properties/launchSettings.json b/WebApi_data_value/Properties/launchSettings.json index a2d81c4..923279d 100644 --- a/WebApi_data_value/Properties/launchSettings.json +++ b/WebApi_data_value/Properties/launchSettings.json @@ -1,23 +1,14 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:38552", - "sslPort": 44357 - } - }, +{ "profiles": { "WebApi_data_value": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5174", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5174" }, "IIS Express": { "commandName": "IISExpress", @@ -26,6 +17,25 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "environmentVariables": { + "ASPNETCORE_URLS": "https://+:443;http://+:80" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:38552", + "sslPort": 44357 } } -} +} \ No newline at end of file diff --git a/WebApi_data_value/WebApi_data_value.csproj b/WebApi_data_value/WebApi_data_value.csproj index b858af5..7a29b7d 100644 --- a/WebApi_data_value/WebApi_data_value.csproj +++ b/WebApi_data_value/WebApi_data_value.csproj @@ -6,6 +6,8 @@ enable True true + 2dcbafb3-d1a3-4af1-af93-43f2f2cbafea + Linux