-
Notifications
You must be signed in to change notification settings - Fork 2k
Add basic HTTP health check #4352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b064171
Add basic HTTP healthcheck
richlander 2fde9cb
Install curl
richlander 6019214
Add port and comment
richlander 21c9673
Update samples/aspnetapp/Dockerfile
richlander 09d257d
Add support for SIGTERM
richlander 8aa846d
Update Program.cs
richlander f03e8f6
Switch to anonymous type
richlander 296b00b
Remove 0 assignments
richlander 5c012ec
Switch to Alpine for health check
richlander a6ed176
Add healthcheck for nanoserver
richlander 6d32950
Rename Alpine Dockerfile
richlander fd1a9e0
Update samples/aspnetapp/Dockerfile.alpine-slim
richlander 4cbbf90
Update HEALTHCHECK
richlander 40a91af
Update samples manifest
richlander 3fcc5ae
Add exit 1 to Alpine sample
richlander 1ed2a9d
Fix typo
richlander fce2e85
Add PowerShell syntax to README
richlander f8eb923
Update README.samples.md
richlander 81dee81
Update samples/aspnetapp/README.md
richlander e1af588
Add arg to support 1809
richlander 08bdd9a
Specific TAG value
richlander File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,30 @@ | ||
# https://hub.docker.com/_/microsoft-dotnet | ||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY aspnetapp/*.csproj . | ||
RUN dotnet restore --use-current-runtime /p:PublishReadyToRun=true | ||
|
||
# copy everything else and build app | ||
COPY aspnetapp/. . | ||
RUN dotnet publish -c Release -o /app --use-current-runtime --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
|
||
# This port needs to match the port being used | ||
HEALTHCHECK CMD wget -qO- -t1 http://localhost:80/healthz || exit 1 | ||
ENTRYPOINT ["./aspnetapp"] | ||
|
||
# See: https://github.com/dotnet/announcements/issues/20 | ||
# Uncomment to enable globalization APIs (or delete) | ||
# ENV \ | ||
# DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ | ||
# LC_ALL=en_US.UTF-8 \ | ||
# LANG=en_US.UTF-8 | ||
# RUN apk add --no-cache \ | ||
# icu-data-full \ | ||
# icu-libs |
This file contains hidden or 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,26 @@ | ||
# escape=` | ||
|
||
# https://hub.docker.com/_/microsoft-dotnet | ||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY aspnetapp/*.csproj . | ||
RUN dotnet restore --use-current-runtime /p:PublishReadyToRun=true | ||
|
||
# copy everything else and build app | ||
COPY aspnetapp/. . | ||
RUN dotnet publish -c Release -o /app --use-current-runtime --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
HEALTHCHECK CMD curl -sf --show-error http://localhost:80/healthz || exit 1 | ||
ENV ` | ||
# Configure web servers to bind to port 80 when present | ||
ASPNETCORE_URLS=http://+:80 ` | ||
# Enable detection of running in a container | ||
DOTNET_RUNNING_IN_CONTAINER=true | ||
|
||
ENTRYPOINT ["aspnetapp"] |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.