From d32d41509241b0b38fcaa4418d89ddfce3dde9fd Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 26 May 2019 10:05:56 +0800 Subject: [PATCH] doc(docker): Add docker support file --- .dockerignore | 9 ++++++++ Bootstrap.Admin/Bootstrap.Admin.csproj | 2 ++ Bootstrap.Admin/Dockerfile | 23 +++++++++++++++++++ Bootstrap.Admin/Dockerfile.linux | 20 ++++++++++++++++ .../Properties/launchSettings.json | 5 ++++ 5 files changed, 59 insertions(+) create mode 100644 .dockerignore create mode 100644 Bootstrap.Admin/Dockerfile create mode 100644 Bootstrap.Admin/Dockerfile.linux diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..df2e0fe5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.dockerignore +.env +.git +.gitignore +.vs +.vscode +*/bin +*/obj +**/.toolstarget \ No newline at end of file diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 9888019a..bca9b9a9 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -10,12 +10,14 @@ ..\Bootstrap.Admin\Bootstrap.Admin.xml + Windows + diff --git a/Bootstrap.Admin/Dockerfile b/Bootstrap.Admin/Dockerfile new file mode 100644 index 00000000..0043ca66 --- /dev/null +++ b/Bootstrap.Admin/Dockerfile @@ -0,0 +1,23 @@ +#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. +#For more information, please see https://aka.ms/containercompat + +FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build +WORKDIR /src +COPY ["Bootstrap.Admin/Bootstrap.Admin.csproj", "Bootstrap.Admin/"] +COPY ["Bootstrap.DataAccess/Bootstrap.DataAccess.csproj", "Bootstrap.DataAccess/"] +RUN dotnet restore "Bootstrap.Admin/Bootstrap.Admin.csproj" +COPY . . +WORKDIR "/src/Bootstrap.Admin" +RUN dotnet build "Bootstrap.Admin.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "Bootstrap.Admin.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "Bootstrap.Admin.dll"] \ No newline at end of file diff --git a/Bootstrap.Admin/Dockerfile.linux b/Bootstrap.Admin/Dockerfile.linux new file mode 100644 index 00000000..c94e7d6b --- /dev/null +++ b/Bootstrap.Admin/Dockerfile.linux @@ -0,0 +1,20 @@ +FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base +WORKDIR /app +EXPOSE 80 + +FROM microsoft/dotnet:2.2-sdk AS build +WORKDIR /src +COPY ["Bootstrap.Admin/Bootstrap.Admin.csproj", "Bootstrap.Admin/"] +COPY ["Bootstrap.DataAccess/Bootstrap.DataAccess.csproj", "Bootstrap.DataAccess/"] +RUN dotnet restore "Bootstrap.Admin/Bootstrap.Admin.csproj" +COPY . . +WORKDIR "/src/Bootstrap.Admin" +RUN dotnet build "Bootstrap.Admin.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "Bootstrap.Admin.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "Bootstrap.Admin.dll"] \ No newline at end of file diff --git a/Bootstrap.Admin/Properties/launchSettings.json b/Bootstrap.Admin/Properties/launchSettings.json index 0f179450..818a0181 100644 --- a/Bootstrap.Admin/Properties/launchSettings.json +++ b/Bootstrap.Admin/Properties/launchSettings.json @@ -23,6 +23,11 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "http://localhost:50852/" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}" } } } \ No newline at end of file