This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from goncalo-oliveira/develop
Added aspnet-controller template
- Loading branch information
Showing
9 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM openfaas/of-watchdog:0.8.1 as watchdog | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim as builder | ||
ARG PACKAGE_SOURCE | ||
ARG PACKAGE_SOURCE_USERNAME | ||
ARG PACKAGE_SOURCE_PASSWORD | ||
|
||
# suppress data collection | ||
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 | ||
|
||
# caches restore result by copying csproj file separately | ||
WORKDIR /source/faas/function | ||
COPY function/function.csproj . | ||
|
||
# restore packages | ||
COPY add-package-source.sh /tmp/ | ||
RUN chmod u+x /tmp/add-package-source.sh \ | ||
&& /tmp/add-package-source.sh $PACKAGE_SOURCE $PACKAGE_SOURCE_USERNAME $PACKAGE_SOURCE_PASSWORD \ | ||
&& dotnet restore | ||
|
||
# Copies the rest of the code | ||
WORKDIR /source/faas | ||
COPY . . | ||
|
||
# build and publish | ||
RUN dotnet publish -c release -o published function/function.csproj | ||
|
||
# runner | ||
FROM docker.pkg.github.com/goncalo-oliveira/faas-run/faas-run:1.6 | ||
|
||
COPY --from=watchdog /fwatchdog /usr/bin/ | ||
|
||
# Create a non-root user | ||
RUN addgroup --system app \ | ||
&& adduser --system --ingroup app app | ||
|
||
WORKDIR /home/app/ | ||
COPY --from=builder /source/faas/published . | ||
RUN chown app:app -R /home/app | ||
|
||
USER app | ||
|
||
ENV fprocess="faas-run ./function.dll" | ||
ENV cgi_headers="true" | ||
ENV mode="http" | ||
ENV upstream_url="http://localhost:9000" | ||
EXPOSE 8080 | ||
|
||
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 | ||
|
||
CMD ["fwatchdog"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# $1: package source | ||
# $2: username | ||
# $3: password | ||
|
||
if [ -n "$1" ] && [ -n "$2" ] && [ -n "$3" ]; then | ||
echo "--source $1 --username $2 --password $3" | ||
# dotnet nuget add source | ||
dotnet nuget add source -n private -u $2 -p $3 --store-password-in-clear-text $1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace OpenFaaS | ||
{ | ||
[ApiController] | ||
[Route("/")] | ||
public class Controller : ControllerBase | ||
{ | ||
[HttpGet] | ||
public Task<IActionResult> GetAsync() | ||
{ | ||
var result = new | ||
{ | ||
Message = "Hello!" | ||
}; | ||
|
||
return Task.FromResult<IActionResult>( Ok( result ) ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace OpenFaaS | ||
{ | ||
public class Startup | ||
{ | ||
public Startup( IConfiguration configuration ) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
// This method gets called by the runtime. Use this method to add services to the container. | ||
public void ConfigureServices( IServiceCollection services ) | ||
{ | ||
// add your services here. | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure( IApplicationBuilder app, bool isDevelopmentEnv ) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<RootNamespace>OpenFaaS</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" /> | ||
<PackageReference Include="OpenFaaS.Functions" Version="1.3.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: aspnet-controller | ||
fprocess: faas-run ./function.dll | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters