From b4b33de8105522ac9974c0f6e1502e5d06c817df Mon Sep 17 00:00:00 2001 From: Andreas Mosti Date: Wed, 18 Nov 2020 10:35:54 +0100 Subject: [PATCH 1/4] updated to dotnet 5 --- template/csharp-httprequest/Dockerfile | 10 +++++----- template/csharp-httprequest/Program.cs | 16 ++++++++++------ template/csharp-httprequest/Startup.cs | 2 +- template/csharp-httprequest/root.csproj | 9 ++++----- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/template/csharp-httprequest/Dockerfile b/template/csharp-httprequest/Dockerfile index 95953be..a5ce0dd 100644 --- a/template/csharp-httprequest/Dockerfile +++ b/template/csharp-httprequest/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.8 as watchdog +FROM alpine:3.12 as watchdog RUN apk --no-cache add curl \ && echo "Pulling watchdog binary from Github." \ @@ -7,15 +7,15 @@ RUN apk --no-cache add curl \ && cp /usr/bin/fwatchdog /home/app \ && apk del curl --no-cache -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 as builder +FROM mcr.microsoft.com/dotnet/sdk:5.0 as builder # Supress collection of data. ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 # Optimize for Docker builder caching by adding projects first. -RUN mkdir -p /home/app/function -WORKDIR /home/app/function +RUN mkdir -p /home/app/src/function +WORKDIR /home/app/src/function COPY ./function/Function.csproj . WORKDIR /home/app/src/ @@ -26,7 +26,7 @@ COPY . . RUN dotnet publish -c release -o published -FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 +FROM mcr.microsoft.com/dotnet/aspnet:5.0.0 COPY --from=watchdog /usr/bin/fwatchdog /usr/bin/ diff --git a/template/csharp-httprequest/Program.cs b/template/csharp-httprequest/Program.cs index 20c3165..e7c541c 100644 --- a/template/csharp-httprequest/Program.cs +++ b/template/csharp-httprequest/Program.cs @@ -1,12 +1,16 @@ -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; public class Program { - public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); + public static void Main(string[] args) => CreateHostBuilder(args).Build().Run(); - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseUrls("http://localhost:5000"); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseKestrel(); + webBuilder.UseStartup(); + webBuilder.UseUrls("http://localhost:5000"); + }); } diff --git a/template/csharp-httprequest/Startup.cs b/template/csharp-httprequest/Startup.cs index 5b4b00f..dd76da7 100644 --- a/template/csharp-httprequest/Startup.cs +++ b/template/csharp-httprequest/Startup.cs @@ -11,7 +11,7 @@ public void ConfigureServices(IServiceCollection services) { } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.Run(async (context) => { diff --git a/template/csharp-httprequest/root.csproj b/template/csharp-httprequest/root.csproj index fde3a18..d707919 100644 --- a/template/csharp-httprequest/root.csproj +++ b/template/csharp-httprequest/root.csproj @@ -1,8 +1,7 @@ - - + Exe - netcoreapp2.2 + net5.0 false false false @@ -18,7 +17,7 @@ - + + - From be17ab420428d7881c5e3f5009d829fa1ce3fc31 Mon Sep 17 00:00:00 2001 From: Andreas Mosti Date: Wed, 18 Nov 2020 17:54:06 +0100 Subject: [PATCH 2/4] using latest of-watchdog --- template/csharp-httprequest/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/csharp-httprequest/Dockerfile b/template/csharp-httprequest/Dockerfile index a5ce0dd..6b210fe 100644 --- a/template/csharp-httprequest/Dockerfile +++ b/template/csharp-httprequest/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.12 as watchdog RUN apk --no-cache add curl \ && echo "Pulling watchdog binary from Github." \ - && curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.5.1/of-watchdog > /usr/bin/fwatchdog \ + && curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.8.1/of-watchdog > /usr/bin/fwatchdog \ && chmod +x /usr/bin/fwatchdog \ && cp /usr/bin/fwatchdog /home/app \ && apk del curl --no-cache @@ -26,7 +26,7 @@ COPY . . RUN dotnet publish -c release -o published -FROM mcr.microsoft.com/dotnet/aspnet:5.0.0 +FROM mcr.microsoft.com/dotnet/aspnet:5.0 COPY --from=watchdog /usr/bin/fwatchdog /usr/bin/ From bb52de7e37c5d2c2e3790d28a89a717a4173eab2 Mon Sep 17 00:00:00 2001 From: trbl Date: Tue, 13 Dec 2022 19:06:38 +0100 Subject: [PATCH 3/4] update to .net7.0 --- csharp-httprequest.sln | 31 ------------------- template/csharp-httprequest/Dockerfile | 14 ++++----- .../function/Function.csproj | 2 +- template/csharp-httprequest/root.csproj | 2 +- 4 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 csharp-httprequest.sln diff --git a/csharp-httprequest.sln b/csharp-httprequest.sln deleted file mode 100644 index 0fc9be9..0000000 --- a/csharp-httprequest.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2035 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Function", "template\csharp-httprequest\function\Function.csproj", "{7A443F1C-78ED-416E-9625-0CAD4B63D7CA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "root", "template\csharp-httprequest\root.csproj", "{132C9C0D-0AF1-4D73-91B0-5C072B1B553E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A443F1C-78ED-416E-9625-0CAD4B63D7CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A443F1C-78ED-416E-9625-0CAD4B63D7CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A443F1C-78ED-416E-9625-0CAD4B63D7CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A443F1C-78ED-416E-9625-0CAD4B63D7CA}.Release|Any CPU.Build.0 = Release|Any CPU - {132C9C0D-0AF1-4D73-91B0-5C072B1B553E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {132C9C0D-0AF1-4D73-91B0-5C072B1B553E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {132C9C0D-0AF1-4D73-91B0-5C072B1B553E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {132C9C0D-0AF1-4D73-91B0-5C072B1B553E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D19A35C8-5F1E-4B8E-B82C-C6A548B5E62C} - EndGlobalSection -EndGlobal diff --git a/template/csharp-httprequest/Dockerfile b/template/csharp-httprequest/Dockerfile index 6b210fe..c21c50d 100644 --- a/template/csharp-httprequest/Dockerfile +++ b/template/csharp-httprequest/Dockerfile @@ -1,21 +1,21 @@ -FROM alpine:3.12 as watchdog +FROM alpine:3.8 as watchdog RUN apk --no-cache add curl \ && echo "Pulling watchdog binary from Github." \ - && curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.8.1/of-watchdog > /usr/bin/fwatchdog \ + && curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.5.1/of-watchdog > /usr/bin/fwatchdog \ && chmod +x /usr/bin/fwatchdog \ && cp /usr/bin/fwatchdog /home/app \ && apk del curl --no-cache - -FROM mcr.microsoft.com/dotnet/sdk:5.0 as builder + +FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine as builder # Supress collection of data. ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 # Optimize for Docker builder caching by adding projects first. -RUN mkdir -p /home/app/src/function -WORKDIR /home/app/src/function +RUN mkdir -p /home/app/function +WORKDIR /home/app/function COPY ./function/Function.csproj . WORKDIR /home/app/src/ @@ -26,7 +26,7 @@ COPY . . RUN dotnet publish -c release -o published -FROM mcr.microsoft.com/dotnet/aspnet:5.0 +FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine COPY --from=watchdog /usr/bin/fwatchdog /usr/bin/ diff --git a/template/csharp-httprequest/function/Function.csproj b/template/csharp-httprequest/function/Function.csproj index ec15780..7c713fb 100644 --- a/template/csharp-httprequest/function/Function.csproj +++ b/template/csharp-httprequest/function/Function.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net7.0 false diff --git a/template/csharp-httprequest/root.csproj b/template/csharp-httprequest/root.csproj index d707919..e8751ab 100644 --- a/template/csharp-httprequest/root.csproj +++ b/template/csharp-httprequest/root.csproj @@ -1,7 +1,7 @@  Exe - net5.0 + net7.0 false false false From a78e8ebf5bb36a372d53aeac074c19a491370c2c Mon Sep 17 00:00:00 2001 From: trbl Date: Tue, 13 Dec 2022 19:10:17 +0100 Subject: [PATCH 4/4] fix watchdog version and workdir --- template/csharp-httprequest/Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/template/csharp-httprequest/Dockerfile b/template/csharp-httprequest/Dockerfile index c21c50d..1feb314 100644 --- a/template/csharp-httprequest/Dockerfile +++ b/template/csharp-httprequest/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.8 as watchdog +FROM alpine:3.12 as watchdog RUN apk --no-cache add curl \ && echo "Pulling watchdog binary from Github." \ - && curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.5.1/of-watchdog > /usr/bin/fwatchdog \ + && curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.8.1/of-watchdog > /usr/bin/fwatchdog \ && chmod +x /usr/bin/fwatchdog \ && cp /usr/bin/fwatchdog /home/app \ && apk del curl --no-cache @@ -13,9 +13,8 @@ FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine as builder ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 # Optimize for Docker builder caching by adding projects first. - -RUN mkdir -p /home/app/function -WORKDIR /home/app/function +RUN mkdir -p /home/app/src/function +WORKDIR /home/app/src/function COPY ./function/Function.csproj . WORKDIR /home/app/src/