-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
7 changed files
with
124 additions
and
3 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,29 @@ | ||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | ||
USER app | ||
WORKDIR /app | ||
EXPOSE 8080 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
# Install clang/zlib1g-dev dependencies for publishing to native | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
clang zlib1g-dev | ||
ARG BUILD_CONFIGURATION=Release | ||
WORKDIR /src | ||
COPY ["src/Prometheus.SystemMetrics.Example.AOT/Prometheus.SystemMetrics.Example.AOT.csproj", "src/Prometheus.SystemMetrics.Example.AOT/"] | ||
RUN dotnet restore "./src/Prometheus.SystemMetrics.Example.AOT/./Prometheus.SystemMetrics.Example.AOT.csproj" | ||
COPY . . | ||
WORKDIR "/src/src/Prometheus.SystemMetrics.Example.AOT" | ||
RUN dotnet build "./Prometheus.SystemMetrics.Example.AOT.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
||
FROM build AS publish | ||
ARG BUILD_CONFIGURATION=Release | ||
RUN dotnet publish "./Prometheus.SystemMetrics.Example.AOT.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true | ||
|
||
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0 AS final | ||
WORKDIR /app | ||
EXPOSE 8080 | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["./Prometheus.SystemMetrics.Example.AOT"] |
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 Prometheus; | ||
using Prometheus.SystemMetrics; | ||
|
||
var builder = WebApplication.CreateSlimBuilder(args); | ||
|
||
var services = builder.Services; | ||
services.AddSystemMetrics(); | ||
|
||
var app = builder.Build(); | ||
|
||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseRouting(); | ||
app.MapMetrics(); | ||
app.MapGet("/", async context => | ||
{ | ||
context.Response.Redirect("/metrics"); | ||
}); | ||
|
||
app.Run(); |
22 changes: 22 additions & 0 deletions
22
src/Prometheus.SystemMetrics.Example.AOT/Prometheus.SystemMetrics.Example.AOT.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<PublishAot>true</PublishAot> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<DockerfileContext>..\..</DockerfileContext> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" /> | ||
<PackageReference Include="prometheus-net.AspNetCore" Version="8.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Prometheus.SystemMetrics\Prometheus.SystemMetrics.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
24 changes: 24 additions & 0 deletions
24
src/Prometheus.SystemMetrics.Example.AOT/Properties/launchSettings.json
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,24 @@ | ||
{ | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "todos", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"dotnetRunMessages": true, | ||
"applicationUrl": "http://localhost:5017" | ||
}, | ||
"Docker": { | ||
"commandName": "Docker", | ||
"launchBrowser": true, | ||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/todos", | ||
"environmentVariables": { | ||
"ASPNETCORE_HTTP_PORTS": "8080" | ||
}, | ||
"publishAllPorts": true | ||
} | ||
}, | ||
"$schema": "http://json.schemastore.org/launchsettings.json" | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Prometheus.SystemMetrics.Example.AOT/appsettings.Development.json
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,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |