From b69bca09a33398d01270b66b420f3ecc3afe6b97 Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Wed, 12 Apr 2017 10:41:32 +0100 Subject: [PATCH] dotnet Core example --- sample-functions/BaseFunctions/README.md | 1 + .../BaseFunctions/dncore/Dockerfile | 16 ++++++++++++ .../BaseFunctions/dncore/src/.gitignore | 5 ++++ .../BaseFunctions/dncore/src/Program.cs | 25 +++++++++++++++++++ .../BaseFunctions/dncore/src/root.csproj | 8 ++++++ 5 files changed, 55 insertions(+) create mode 100644 sample-functions/BaseFunctions/dncore/Dockerfile create mode 100644 sample-functions/BaseFunctions/dncore/src/.gitignore create mode 100644 sample-functions/BaseFunctions/dncore/src/Program.cs create mode 100755 sample-functions/BaseFunctions/dncore/src/root.csproj diff --git a/sample-functions/BaseFunctions/README.md b/sample-functions/BaseFunctions/README.md index 8171899a..5cb0e90d 100644 --- a/sample-functions/BaseFunctions/README.md +++ b/sample-functions/BaseFunctions/README.md @@ -11,4 +11,5 @@ Each one will read the request from the watchdog then print it back resulting in | Golang | functions/base:golang-1.7.5-alpine | Golang compiled on Alpine Linux | | Python | functions/base:python-2.7-alpine | Python 2.7 built on Alpine Linux | | Java | functions/base:openjdk-8u121-jdk-alpine | OpenJDK built on Alpine Linux | +| Dotnet Core | functions/base:dotnet-sdk | Microsoft dotnet core SDK | | Busybox / shell | functions/alpine:latest | Busybox contains useful binaries which can be turned into a FaaS function such as `sha512sum` or `cat` | diff --git a/sample-functions/BaseFunctions/dncore/Dockerfile b/sample-functions/BaseFunctions/dncore/Dockerfile new file mode 100644 index 00000000..42b0c2c1 --- /dev/null +++ b/sample-functions/BaseFunctions/dncore/Dockerfile @@ -0,0 +1,16 @@ +FROM microsoft/dotnet:sdk + +ADD https://github.com/alexellis/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin +RUN chmod +x /usr/bin/fwatchdog + +ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 + +WORKDIR /root/ +COPY src src +WORKDIR /root/src +RUN dotnet restore +RUN dotnet build + +ENV fprocess="dotnet ./bin/Debug/netcoreapp1.1/root.dll" +EXPOSE 8080 +CMD ["fwatchdog"] diff --git a/sample-functions/BaseFunctions/dncore/src/.gitignore b/sample-functions/BaseFunctions/dncore/src/.gitignore new file mode 100644 index 00000000..c74559e2 --- /dev/null +++ b/sample-functions/BaseFunctions/dncore/src/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +.nuget/ +.dotnet/ +.templateengine/ diff --git a/sample-functions/BaseFunctions/dncore/src/Program.cs b/sample-functions/BaseFunctions/dncore/src/Program.cs new file mode 100644 index 00000000..3bdfd0cc --- /dev/null +++ b/sample-functions/BaseFunctions/dncore/src/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Text; + +namespace root +{ + class Program + { + private static string getStdin() { + StringBuilder buffer = new StringBuilder(); + string s; + while ((s = Console.ReadLine()) != null) + { + buffer.AppendLine(s); + } + return buffer.ToString(); + } + + static void Main(string[] args) + { + string buffer = getStdin(); + + Console.WriteLine(buffer); + } + } +} diff --git a/sample-functions/BaseFunctions/dncore/src/root.csproj b/sample-functions/BaseFunctions/dncore/src/root.csproj new file mode 100755 index 00000000..abb9969a --- /dev/null +++ b/sample-functions/BaseFunctions/dncore/src/root.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp1.1 + + +