-
Notifications
You must be signed in to change notification settings - Fork 0
Containerize Notification service (hardened image + health/ready probes) #83
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| **/bin/ | ||
| **/obj/ | ||
| **/out/ | ||
| **/publish/ | ||
| **/.vs/ | ||
| **/.vscode/ | ||
| **/.idea/ | ||
| **/*.user | ||
| **/.git/ | ||
| **/.gitignore | ||
| **/Dockerfile* | ||
| **/.dockerignore | ||
| **/docker-compose*.yml | ||
| **/.env | ||
| **/.env.* | ||
| **/appsettings.*.local.json | ||
| **/secrets.json | ||
| **/*.log | ||
| **/.DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,32 @@ | ||
| FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base | ||
| WORKDIR /app | ||
| EXPOSE 5005 | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # ---- Build stage ---- | ||
| FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build | ||
| WORKDIR /src | ||
| # Copy ONLY .csproj files first (one COPY per referenced project) for layer-cached restore | ||
| COPY ["Services/Notification/Notification.API/Notification.API.csproj", "Services/Notification/Notification.API/"] | ||
| COPY ["Services/Notification/Notification.Domain/Notification.Domain.csproj", "Services/Notification/Notification.Domain/"] | ||
| COPY ["Services/Notification/Notification.Infrastructure/Notification.Infrastructure.csproj", "Services/Notification/Notification.Infrastructure/"] | ||
| COPY ["Shared/Shared.Contracts/Shared.Contracts.csproj", "Shared/Shared.Contracts/"] | ||
| COPY ["Shared/Shared.Infrastructure/Shared.Infrastructure.csproj", "Shared/Shared.Infrastructure/"] | ||
| RUN dotnet restore "Services/Notification/Notification.API/Notification.API.csproj" | ||
| COPY . . | ||
| WORKDIR "/src/Services/Notification/Notification.API" | ||
| RUN dotnet build -c Release -o /app/build | ||
| RUN dotnet publish "Services/Notification/Notification.API/Notification.API.csproj" \ | ||
| -c Release -o /app/publish /p:UseAppHost=false | ||
|
|
||
| FROM build AS publish | ||
| RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false | ||
|
|
||
| FROM base AS final | ||
| # ---- Runtime stage ---- | ||
| FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final | ||
| WORKDIR /app | ||
| COPY --from=publish /app/publish . | ||
| # curl is required by the HEALTHCHECK below and is NOT in the aspnet image | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| # Fixed container-internal port; nothing host/secret specific is baked in. | ||
| # Remap externally with `docker run -p <host>:5005`. | ||
| ENV ASPNETCORE_URLS=http://+:5005 | ||
| EXPOSE 5005 | ||
| COPY --from=build /app/publish . | ||
| USER $APP_UID | ||
| HEALTHCHECK --interval=30s --timeout=3s --start-period=15s --retries=3 \ | ||
| CMD curl -fsS "http://localhost:5005/health" || exit 1 | ||
| ENTRYPOINT ["dotnet", "Notification.API.dll"] |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Default connection string removed only for Notification service, inconsistent with other services The Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional — the goal here is externalizing config so no credentials are baked into the image; the connection string comes from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Shared project reference path fix is correct but other services still have the broken path
The change from
..\..\Shared\...to..\..\..\Shared\...is a genuine fix. Fromsrc/Services/Notification/Notification.API/, the old path../../Sharedresolves tosrc/Services/Shared/which does not exist — the actual location issrc/Shared/. The new three-level-up path correctly resolves tosrc/Shared/. However, all other services (Order, Customer, Product, Identity) still use the two-level..\..\Shared\...path in their.csprojfiles (e.g.src/Services/Order/Order.API/Order.API.csproj:10-11). Those references are equally broken. It's possible the solution file or aDirectory.Build.propswas masking this, but the paths are objectively wrong for both local and Docker builds.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, and intentional. This PR is deliberately scoped to containerizing Notification only, so I fixed only
Notification.API.csproj— that fix is required because the Notification image can't build otherwise. The other services (Order, Customer, Product, Identity) have the same broken..\..\Shared\...path but were already containerized in prior PRs and building, so I left them untouched to keep this PR scoped. Fixing them belongs in a separate change.