From 252abae03dbf5c0b1e53f7819a4d5c51239be8ee Mon Sep 17 00:00:00 2001 From: Ryan Peters Date: Wed, 30 Nov 2022 21:44:56 -0500 Subject: [PATCH] add docker support --- .dockerignore | 25 ++++++++++++++++++++++ BinaryDad.Notes.csproj | 7 ++++++ Dockerfile | 22 +++++++++++++++++++ Properties/launchSettings.json | 39 ++++++++++++++++++++-------------- 4 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 .dockerignore create mode 100644 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.Notes.csproj b/BinaryDad.Notes.csproj index 4c2bb77..54dd2be 100644 --- a/BinaryDad.Notes.csproj +++ b/BinaryDad.Notes.csproj @@ -4,6 +4,13 @@ net7.0 enable enable + 36e65961-6eee-4cc2-b35e-aafd9f9e6a6f + Linux + . + + + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4b5a78d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +#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:7.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["BinaryDad.Notes.csproj", "."] +RUN dotnet restore "./BinaryDad.Notes.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "BinaryDad.Notes.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "BinaryDad.Notes.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "BinaryDad.Notes.dll"] \ No newline at end of file diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index dba6808..89dd84e 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -1,30 +1,22 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:2334", - "sslPort": 44381 - } - }, +{ "profiles": { "http": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5015" }, "https": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7042;http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7042;http://localhost:5015" }, "IIS Express": { "commandName": "IISExpress", @@ -32,6 +24,21 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true, + "useSSL": true + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2334", + "sslPort": 44381 } } -} +} \ No newline at end of file