From af70aa693c63268b629c896d87a15a5f95782bc3 Mon Sep 17 00:00:00 2001 From: Ryan Peters Date: Sat, 25 Jun 2022 12:55:54 -0400 Subject: [PATCH] docker support --- .dockerignore | 25 +++++++++++++++++++ BinaryDad.Coding/BinaryDad.Coding.csproj | 5 ++++ BinaryDad.Coding/Dockerfile | 21 ++++++++++++++++ .../Properties/launchSettings.json | 16 ++++++++---- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 BinaryDad.Coding/Dockerfile 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/BinaryDad.Coding/BinaryDad.Coding.csproj b/BinaryDad.Coding/BinaryDad.Coding.csproj index e948168..da4f060 100644 --- a/BinaryDad.Coding/BinaryDad.Coding.csproj +++ b/BinaryDad.Coding/BinaryDad.Coding.csproj @@ -2,6 +2,11 @@ net6.0 + Linux + + + + diff --git a/BinaryDad.Coding/Dockerfile b/BinaryDad.Coding/Dockerfile new file mode 100644 index 0000000..55e4d84 --- /dev/null +++ b/BinaryDad.Coding/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 ["BinaryDad.Coding/BinaryDad.Coding.csproj", "BinaryDad.Coding/"] +RUN dotnet restore "BinaryDad.Coding/BinaryDad.Coding.csproj" +COPY . . +WORKDIR "/src/BinaryDad.Coding" +RUN dotnet build "BinaryDad.Coding.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "BinaryDad.Coding.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "BinaryDad.Coding.dll"] \ No newline at end of file diff --git a/BinaryDad.Coding/Properties/launchSettings.json b/BinaryDad.Coding/Properties/launchSettings.json index e4fe0b6..2906a65 100644 --- a/BinaryDad.Coding/Properties/launchSettings.json +++ b/BinaryDad.Coding/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, @@ -17,12 +17,18 @@ }, "BinaryDad.Coding": { "commandName": "Project", - "dotnetRunMessages": "true", "launchBrowser": true, - "applicationUrl": "http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "applicationUrl": "http://localhost:5000", + "dotnetRunMessages": "true" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true } } -} +} \ No newline at end of file