chore: initial
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -8,3 +8,10 @@ configuration-production.yaml
|
||||
node_modules/
|
||||
|
||||
config/
|
||||
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
|
||||
[Oo]bj/
|
||||
|
||||
@@ -132,6 +132,10 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ${REPO_DIR}/configurations/otel/collector-config.yaml:/etc/otelcol-contrib/config.yaml
|
||||
power_control:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./dockerfiles/power_control.Dockerfile
|
||||
# Only enable if external services present
|
||||
# ports:
|
||||
# - 4317:4317 # OTLP gRPC receiver
|
||||
|
||||
24
dockerfiles/power_control.Dockerfile
Normal file
24
dockerfiles/power_control.Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0.101-noble-arm64v8 AS base
|
||||
USER $APP_UID
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0.101-noble-arm64v8 AS build
|
||||
COPY ./microservices/power_control/*.csproj /microservices/power_control/
|
||||
|
||||
WORKDIR /microservices/power_control
|
||||
RUN dotnet restore
|
||||
|
||||
WORKDIR /
|
||||
COPY ./microservices/power_control /microservices/power_control
|
||||
|
||||
WORKDIR /microservices/power_control
|
||||
# This stage is used to publish the service project to be copied to the final stage
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION
|
||||
RUN dotnet publish "./power_control.csproj" -c Release -o /app/publish
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "power_control.dll"]
|
||||
41
microservices/power_control/Program.cs
Normal file
41
microservices/power_control/Program.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast");
|
||||
|
||||
app.Run();
|
||||
|
||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
13
microservices/power_control/power_control.csproj
Normal file
13
microservices/power_control/power_control.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user