-
Notifications
You must be signed in to change notification settings - Fork 62
feat: add .NET 8 runtime and builder #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ dotnet: | |
| - 'dotnet/**' | ||
| dotnet20: | ||
| - 'dotnet20/**' | ||
| dotnet8: | ||
| - 'dotnet8/**' | ||
| go: | ||
| - 'go/**' | ||
| jvm: | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,60 @@ | ||
| # Build results | ||
| [Dd]ebug/ | ||
| [Dd]ebugPublic/ | ||
| [Rr]elease/ | ||
| [Rr]eleases/ | ||
| x64/ | ||
| x86/ | ||
| [Ww][Ii][Nn]32/ | ||
| [Aa][Rr][Mm]/ | ||
| [Aa][Rr][Mm]64/ | ||
| bld/ | ||
| [Bb]in/ | ||
| [Oo]bj/ | ||
| [Ll]og/ | ||
| [Ll]ogs/ | ||
|
|
||
| # Visual Studio cache/options directory | ||
| .vs/ | ||
|
|
||
| # .NET Core | ||
| project.lock.json | ||
| project.fragment.lock.json | ||
| artifacts/ | ||
|
|
||
| # Files built by Visual Studio | ||
| *.user | ||
| *.userosscache | ||
| *.sln.docstates | ||
|
|
||
| # Build results | ||
| *.dll | ||
| *.exe | ||
| *.pdb | ||
| *.cache | ||
| *.log | ||
|
|
||
| # NuGet Packages | ||
| *.nupkg | ||
| *.snupkg | ||
| # The packages folder can be ignored because of Package Restore | ||
| **/[Pp]ackages/* | ||
| # except build/, which is used as an MSBuild target. | ||
| !**/[Pp]ackages/build/ | ||
| # Uncomment if necessary however generally it will be regenerated when needed | ||
| #!**/[Pp]ackages/repositories.config | ||
| # NuGet v3's project.json files produces more ignorable files | ||
| *.nuget.props | ||
| *.nuget.targets | ||
|
|
||
| # Visual Studio cache files | ||
| # files ending in .cache can be ignored | ||
| *.[Cc]ache | ||
| # but keep track of directories ending in .cache | ||
| !?*.[Cc]ache/ | ||
|
|
||
| # Example ZIP files (for testing) | ||
| examples/**/*.zip | ||
|
|
||
| # macOS | ||
| .DS_Store |
This file contains hidden or 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,32 @@ | ||
| # Use the .NET 8 SDK image for runtime (needed for compilation support) | ||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 | ||
|
|
||
| # Install required tools | ||
| RUN apt-get update && apt-get install -y unzip curl && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy the Fission .NET runtime application | ||
| COPY Fission.DotNet/ /app/Fission.DotNet/ | ||
| COPY Fission.DotNet.Common/ /app/Fission.DotNet.Common/ | ||
|
|
||
| # Build the runtime application | ||
| RUN dotnet restore Fission.DotNet/Fission.DotNet.csproj | ||
| RUN dotnet publish Fission.DotNet/Fission.DotNet.csproj -c Release -o /app/publish | ||
|
|
||
| # Build and copy Fission.DotNet.Common.dll to /app for runtime compilation | ||
| RUN dotnet build Fission.DotNet.Common/Fission.DotNet.Common.csproj -c Release -o /app/ | ||
|
|
||
| # Create function directory | ||
| RUN mkdir -p /function | ||
|
|
||
| # Set environment variables | ||
| ENV ASPNETCORE_URLS=http://*:8888 | ||
| ENV ASPNETCORE_ENVIRONMENT=Production | ||
|
|
||
| # Expose port | ||
| EXPOSE 8888 | ||
|
|
||
| # Start the runtime | ||
| CMD ["dotnet", "/app/publish/Fission.DotNet.dll"] |
26 changes: 26 additions & 0 deletions
26
dotnet8/Fission.DotNet.Common/Fission.DotNet.Common.csproj
This file contains hidden or 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,26 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <PackageId>Fission.DotNet.Common</PackageId> | ||
| <Version>1.1.0</Version> | ||
| <Authors>Lorenzo Caldon</Authors> | ||
| <Description>Fission dotnet environment common package</Description> | ||
| <PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression> | ||
| <RepositoryUrl>https://github.com/lcsoft77/fission-env-dotnet8</RepositoryUrl> | ||
| <PackageOutputPath>./nupkg</PackageOutputPath> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <PackageReadmeFile>README.md</PackageReadmeFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="README.md" Pack="true" PackagePath="\"/> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or 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,24 @@ | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.5.2.0 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fission.DotNet.Common", "Fission.DotNet.Common.csproj", "{66CA3524-4798-6315-18DF-47CD0B936395}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {66CA3524-4798-6315-18DF-47CD0B936395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {66CA3524-4798-6315-18DF-47CD0B936395}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {66CA3524-4798-6315-18DF-47CD0B936395}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {66CA3524-4798-6315-18DF-47CD0B936395}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {AF6A70F1-84DB-4983-A581-08BC54DF98A5} | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or 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,76 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Text; | ||
| using System.Text.Json; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Fission.DotNet.Common; | ||
|
|
||
| public class FissionContext | ||
| { | ||
| protected Stream _content; | ||
| protected Dictionary<string, object> _arguments; | ||
| protected Dictionary<string, string> _headers; | ||
| protected Dictionary<string, string> _parameters; | ||
|
|
||
| public FissionContext(Stream body, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters) | ||
| { | ||
| if (body == null) throw new ArgumentNullException(nameof(body)); | ||
| if (arguments == null) throw new ArgumentNullException(nameof(arguments)); | ||
| if (headers == null) throw new ArgumentNullException(nameof(headers)); | ||
| if (parameters == null) throw new ArgumentNullException(nameof(parameters)); | ||
|
|
||
| _content = body; | ||
| _arguments = arguments; | ||
| _headers = headers; | ||
| _parameters = parameters; | ||
| } | ||
|
|
||
| protected string GetHeaderValue(string key, string defaultValue = null) | ||
| { | ||
| return _headers.ContainsKey(key) ? _headers[key] : defaultValue; | ||
| } | ||
|
|
||
| public Dictionary<string, object> Arguments => _arguments; | ||
| public Dictionary<string, string> Parameters => _parameters; | ||
|
|
||
| public string TraceID => GetHeaderValue("traceparent", Guid.NewGuid().ToString()); | ||
| public string FunctionName => GetHeaderValue("X-Fission-Function-Name"); | ||
| public string Namespace => GetHeaderValue("X-Fission-Function-Namespace"); | ||
| public string ResourceVersion => GetHeaderValue("X-Fission-Function-Resourceversion"); | ||
| public string UID => GetHeaderValue("X-Fission-Function-Uid"); | ||
| public string Trigger => GetHeaderValue("Source-Name"); | ||
| public string ContentType => GetHeaderValue("Content-Type"); | ||
| public Int32 ContentLength => GetHeaderValue("Content-Length") != null ? Int32.Parse(GetHeaderValue("Content-Length")) : 0; | ||
| public Stream Content => _content; | ||
|
|
||
| public async Task<string?> ContentAsString() | ||
| { | ||
| if (_content == null) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| _content.Position = 0; | ||
| using (StreamReader reader = new StreamReader(_content, Encoding.UTF8, leaveOpen: true)) | ||
| { | ||
| return await reader.ReadToEndAsync(); | ||
| } | ||
| } | ||
|
|
||
| public async Task<T> ContentAs<T>(JsonSerializerOptions? options = null) | ||
| { | ||
| if (_content == null) | ||
| { | ||
| return default; | ||
| } | ||
|
|
||
| _content.Position = 0; | ||
| using (StreamReader reader = new StreamReader(_content, Encoding.UTF8, leaveOpen: true)) | ||
| { | ||
| string content = await reader.ReadToEndAsync(); | ||
| return JsonSerializer.Deserialize<T>(content, options); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,44 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Text; | ||
| using System.Text.Json; | ||
|
|
||
| namespace Fission.DotNet.Common; | ||
|
|
||
| public class FissionHttpContext : FissionContext | ||
| { | ||
| private string _method; | ||
|
|
||
| public FissionHttpContext(Stream body, string method, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters) : base(body, arguments, headers, parameters) | ||
| { | ||
| _method = method; | ||
| } | ||
|
|
||
| public Dictionary<string, string> Headers => _headers; | ||
| public string Url | ||
| { | ||
| get | ||
| { | ||
| var urlHeader = GetHeaderValue("X-Fission-Full-Url"); | ||
|
|
||
| if (urlHeader != null) | ||
| { | ||
| if (urlHeader.Contains("?")) | ||
| { | ||
| urlHeader = urlHeader.Substring(0, urlHeader.IndexOf("?")); | ||
| } | ||
|
|
||
| return urlHeader; | ||
| } | ||
| else | ||
| { | ||
| return "/"; | ||
| } | ||
| } | ||
| } | ||
| public string Method => _method; | ||
| public string Host => GetHeaderValue("X-Forwarded-Host"); | ||
| public int Port => _headers.ContainsKey("X-Forwarded-Port") ? Int32.Parse(GetHeaderValue("X-Forwarded-Port")) : 0; | ||
| public string UserAgent => GetHeaderValue("User-Agent"); | ||
| } |
This file contains hidden or 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,17 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
|
|
||
| namespace Fission.DotNet.Common; | ||
|
|
||
| public class FissionMqContext : FissionContext | ||
| { | ||
| public FissionMqContext(Stream body, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters) : base(body, arguments, headers, parameters) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| public string Topic => GetHeaderValue("Topic"); | ||
| public string ErrorTopic => GetHeaderValue("Errortopic"); | ||
| public string ResponseTopic => GetHeaderValue("Resptopic"); | ||
| } |
This file contains hidden or 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 @@ | ||
| using System; | ||
|
|
||
| namespace Fission.DotNet.Common | ||
| { | ||
| public interface ICorsPolicy | ||
| { | ||
| void AllowAnyOrigin(); | ||
| void AllowAnyHeader(); | ||
| void AllowAnyMethod(); | ||
| void AllowCredentials(); | ||
|
|
||
| void WithOrigin(string[] origin); | ||
| void WithHeader(string[] header); | ||
| void WithMethod(string[] method); | ||
| } | ||
| } |
This file contains hidden or 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,14 @@ | ||
| using System; | ||
|
|
||
| namespace Fission.DotNet.Common | ||
| { | ||
| public interface ILogger | ||
| { | ||
| void LogInformation(string message); | ||
| void LogDebug(string message); | ||
| void LogWarning(string message); | ||
| void LogError(string message); | ||
| void LogCritical(string message); | ||
| void LogError(string message, Exception exception); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also check code in donet20 and if we can consolidate both ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by consolidate both by looking at dotnet20 code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let it be, I was exploring if we can keep only one env.
But this can done later once dotnet8 is released