From 07c51b58b594b8f56da603ccbb496670cb387519 Mon Sep 17 00:00:00 2001 From: Nice <2017875139@qq.com> Date: Thu, 16 Dec 2021 11:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 25 +++++++++++++++ SimpleDevApi.sln | 25 +++++++++++++++ SimpleDevApi/Dockerfile | 21 +++++++++++++ SimpleDevApi/Program.cs | 4 +++ SimpleDevApi/Properties/launchSettings.json | 35 +++++++++++++++++++++ SimpleDevApi/SimpleDevApi.csproj | 14 +++++++++ SimpleDevApi/appsettings.Development.json | 8 +++++ SimpleDevApi/appsettings.json | 9 ++++++ 8 files changed, 141 insertions(+) create mode 100644 .dockerignore create mode 100644 SimpleDevApi.sln create mode 100644 SimpleDevApi/Dockerfile create mode 100644 SimpleDevApi/Program.cs create mode 100644 SimpleDevApi/Properties/launchSettings.json create mode 100644 SimpleDevApi/SimpleDevApi.csproj create mode 100644 SimpleDevApi/appsettings.Development.json create mode 100644 SimpleDevApi/appsettings.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.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 \ No newline at end of file diff --git a/SimpleDevApi.sln b/SimpleDevApi.sln new file mode 100644 index 0000000..484a416 --- /dev/null +++ b/SimpleDevApi.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32002.185 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDevApi", "SimpleDevApi\SimpleDevApi.csproj", "{DC8E3FE4-A24F-421E-A38D-A82FD9A05ADC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DC8E3FE4-A24F-421E-A38D-A82FD9A05ADC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC8E3FE4-A24F-421E-A38D-A82FD9A05ADC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC8E3FE4-A24F-421E-A38D-A82FD9A05ADC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC8E3FE4-A24F-421E-A38D-A82FD9A05ADC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58AC5A8A-2BCA-47D3-8E74-9AA1C1AE514C} + EndGlobalSection +EndGlobal diff --git a/SimpleDevApi/Dockerfile b/SimpleDevApi/Dockerfile new file mode 100644 index 0000000..3678b48 --- /dev/null +++ b/SimpleDevApi/Dockerfile @@ -0,0 +1,21 @@ +#See https://aka.ms/containerfastmode to understand 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 +WORKDIR /src +COPY ["SimpleDevApi/SimpleDevApi.csproj", "SimpleDevApi/"] +RUN dotnet restore "SimpleDevApi/SimpleDevApi.csproj" +COPY . . +WORKDIR "/src/SimpleDevApi" +RUN dotnet build "SimpleDevApi.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "SimpleDevApi.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "SimpleDevApi.dll"] \ No newline at end of file diff --git a/SimpleDevApi/Program.cs b/SimpleDevApi/Program.cs new file mode 100644 index 0000000..e957604 --- /dev/null +++ b/SimpleDevApi/Program.cs @@ -0,0 +1,4 @@ +var builder = WebApplication.CreateBuilder(args); +var app = builder.Build(); +app.MapGet("/",() => "Hello Drone!"); +app.Run(); diff --git a/SimpleDevApi/Properties/launchSettings.json b/SimpleDevApi/Properties/launchSettings.json new file mode 100644 index 0000000..63e3d92 --- /dev/null +++ b/SimpleDevApi/Properties/launchSettings.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2155", + "sslPort": 0 + } + }, + "profiles": { + "SimpleDevApi": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:5005", + "dotnetRunMessages": true + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true + } + } +} \ No newline at end of file diff --git a/SimpleDevApi/SimpleDevApi.csproj b/SimpleDevApi/SimpleDevApi.csproj new file mode 100644 index 0000000..f31c710 --- /dev/null +++ b/SimpleDevApi/SimpleDevApi.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + Linux + + + + + + + diff --git a/SimpleDevApi/appsettings.Development.json b/SimpleDevApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/SimpleDevApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SimpleDevApi/appsettings.json b/SimpleDevApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/SimpleDevApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}