faas-cli new --lang csharp pinetes
Edit ./pinetes/FunctionHandler.cs
Console.WriteLine("Pi there! "+ input);
Edit ./template/csharp/Dockerfile
Add -r linux-arm to the end of the dotnet publish command
RUN dotnet publish -c release -o published
Comment out all other lines in the file
Run a build:
faas-cli build -f pinetes.yml
Extract the binary folder:
docker create --name pinetes pinetes docker cp pinetes:/root/src/published .
Now scp the file to the RPi:
scp -r published [email protected]:~
Log into the RPi
faas-cli new --lang Dockerfile pinetes
mv published pinetes/
Now create the Dockerfile:
FROM microsoft/dotnet:2.0.0-runtime-stretch-arm32v7
RUN echo "Pulling watchdog binary from Github." \
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.6.5/fwatchdog-armhf > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog
WORKDIR /root/
COPY published published
WORKDIR /root/published
ENV fprocess "dotnet root.dll"
CMD ["/usr/bin/fwatchdog"]
Edit pinetes.yml with your Docker hub account name
At this point you can now build, push and deploy as per usual. For the next build of the .NET code on your laptop only repeat the steps below:
faas-cli build -f pinetes.yml
faas-cli push -f pinetes.yml
faas-cli deploy -f pinetes.yml --gateway http://127.0.0.1:31112
.NET is pretty big so the deployment may take a while. Once it's in place you can invoke it like this:
curl 127.0.0.1:31112/function/pinetes -d test
Pi there! test
If you want to watch for the deployment type in watch kubectl get pods
watch kubectl get pods
NAME READY STATUS RESTARTS AGE
alertmanager-56d9c57b48-7qjjr 1/1 Running 0 1d
faas-netesd-78597bdfdd-ngrl8 1/1 Running 0 1d
gateway-f9bd744fb-4jvj6 1/1 Running 0 1d
pinetes-5997656d58-g8c4h 0/1 ContainerCreating 0 26s