-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7e4157
commit d9c09fe
Showing
8 changed files
with
100 additions
and
36 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
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 |
---|---|---|
@@ -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"] |
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,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 |
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,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; | ||
} |
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