Skip to content

Commit

Permalink
Add HealthCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadKarimi committed Jan 9, 2024
1 parent 17a0eff commit d64f0f5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/SwiftLink.Presentation/Dockerfile
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
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/SwiftLink.Presentation/SwiftLink.Presentation.csproj", "src/SwiftLink.Presentation/"]
COPY ["src/SwiftLink.Infrastructure/SwiftLink.Infrastructure.csproj", "src/SwiftLink.Infrastructure/"]
COPY ["src/SwiftLink.Application/SwiftLink.Application.csproj", "src/SwiftLink.Application/"]
COPY ["src/SwiftLink.Domain/SwiftLink.Domain.csproj", "src/SwiftLink.Domain/"]
COPY ["src/SwiftLink.Shared/SwiftLink.Shared.csproj", "src/SwiftLink.Shared/"]
RUN dotnet restore "./src/SwiftLink.Presentation/./SwiftLink.Presentation.csproj"
COPY . .
WORKDIR "/src/src/SwiftLink.Presentation"
RUN dotnet build "./SwiftLink.Presentation.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./SwiftLink.Presentation.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SwiftLink.Presentation.dll"]
6 changes: 6 additions & 0 deletions src/SwiftLink.Presentation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@
options.GroupNameFormat = "'v'V";
options.SubstituteApiVersionInUrl = true;
});
builder.Services.AddHealthChecks();
}





var app = builder.Build();
{
app.MapHealthChecks("/health");
app.UseExceptionHandler(error =>
{
error.Run(async context =>
Expand Down

0 comments on commit d64f0f5

Please sign in to comment.