Skip to content

Commit

Permalink
updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
goncalo-oliveira committed Aug 26, 2024
1 parent b7e4157 commit d9c09fe
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
source-url: https://nuget.pkg.github.com/justfaas/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
13 changes: 7 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/bin/Debug/net7.0/faas-events.dll",
"program": "${workspaceFolder}/src/bin/Debug/net8.0/faas-events.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
},
{
"name": ".NET Core Attach",
Expand Down
10 changes: 5 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/faas-events.csproj",
"${workspaceFolder}/events.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
Expand All @@ -19,9 +19,9 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/faas-events.csproj",
"${workspaceFolder}/events.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
Expand All @@ -33,7 +33,7 @@
"watch",
"run",
"--project",
"${workspaceFolder}/src/faas-events.csproj"
"${workspaceFolder}/events.sln"
],
"problemMatcher": "$msCompile"
}
Expand Down
47 changes: 30 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
### Builder
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:8.0-preview AS build
ARG TARGETARCH
WORKDIR /app
# syntax=docker/dockerfile:1.3

RUN apt update && apt install libxml2-utils -y
# Create a stage for building the application.
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

# restore dependencies; use nuget config for private dependencies
COPY ./src/faas-events.csproj ./
RUN dotnet restore -a $TARGETARCH
COPY src /source

COPY ./src/. ./
RUN dotnet publish -c release -a $TARGETARCH -o dist faas-events.csproj
WORKDIR /source

### Runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0 as final
# This is the architecture you’re building for, which is passed in by the builder.
# Placing it here allows the previous steps to be cached across architectures.
ARG TARGETARCH

RUN addgroup faas-app && useradd -G faas-app faas-user
RUN apk update && apk add --no-cache libxml2-utils

# Build the application.
# Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages.
# If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't
# work in .NET 6.0.
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app

# Create a new stage for running the application that contains the minimal
# runtime dependencies for the application. This often uses a different base
# image from the build stage where the necessary files are copied from the build
# stage.
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
WORKDIR /app
COPY --from=build /app/dist/ ./
RUN chown faas-user:faas-app -R .

USER faas-user
# Copy everything needed to run the app from the "build" stage.
COPY --from=build /app .

# Switch to a non-privileged user (defined in the base image) that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
# and https://github.com/dotnet/dotnet-docker/discussions/4764
USER $APP_UID

ENTRYPOINT [ "dotnet", "faas-events.dll" ]
ENTRYPOINT ["dotnet", "faas-events.dll"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@

END OF TERMS AND CONDITIONS

Copyright 2023 Goncalo Oliveira
Copyright 2024 Goncalo Oliveira

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
25 changes: 25 additions & 0 deletions events.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "faas-events", "src\faas-events.csproj", "{3F16192B-223E-4EC8-8730-BC9689717FC5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F16192B-223E-4EC8-8730-BC9689717FC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F16192B-223E-4EC8-8730-BC9689717FC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F16192B-223E-4EC8-8730-BC9689717FC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F16192B-223E-4EC8-8730-BC9689717FC5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CA6B8BA5-D3B9-4C28-8736-F878A0395A45}
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions src/AppVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Reflection;

namespace System;

internal static class AppVersion
{
private static readonly Lazy<string> lazyValue = new( () =>
{
var assembly = Assembly.GetExecutingAssembly();
var value = assembly.GetName().Version?.ToString( 3 ) ?? "0.0.0";
var infoVerAttr = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if ( infoVerAttr != null )
{
return infoVerAttr.InformationalVersion;
}
return value;
} );

public static string Value => lazyValue.Value;
}
14 changes: 8 additions & 6 deletions src/faas-events.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>faas_events</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<Version>0.2.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KubernetesOperatorSdk" Version="0.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="NATS.Client" Version="1.0.3" />
<PackageReference Include="prometheus-net" Version="8.0.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.0.0" />
<PackageReference Include="KubernetesOperatorSdk" Version="0.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="NATS.Client" Version="1.1.6" />
<PackageReference Include="prometheus-net" Version="8.2.1" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
</ItemGroup>

</Project>

0 comments on commit d9c09fe

Please sign in to comment.