Skip to content

Containerize Product service (multi-stage build, /health & /ready, env config)#84

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783961686-containerize-product
Open

Containerize Product service (multi-stage build, /health & /ready, env config)#84
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783961686-containerize-product

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Makes the Product service container-ready: hardened multi-stage image, distinct liveness/readiness endpoints, and fully externalized configuration.

Health endpoints (Program.cs) — replaced the single /healthz with two:

  • /health — liveness, no dependency checks (Predicate = _ => false), always 200 while the process is up.
  • /ready — readiness, runs AddDbContextCheck<ProductDbContext> tagged ready; 200 when Postgres is reachable, 503 otherwise.

Adds Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore for the DB check.

Config externalization — removed the hardcoded connection string from appsettings.json (was Host=localhost;...;Password=postgres); the connection string now comes only from env (ConnectionStrings__DefaultConnection). No hosts/credentials baked into the image.

Dockerfile — multi-stage (SDK build → aspnet runtime), restore-then-copy layer caching, runs as the base image's non-root $APP_UID, listens on 8080 via ASPNETCORE_HTTP_PORTS (no hardcoded URLs), ASPNETCORE_ENVIRONMENT=Production default.

.dockerignore (build context src/) — excludes bin/, obj/, .git/, IDE files, Dockerfiles, and local/secret config.

docker-compose.yml product-service updated to map 5004:8080 and set ASPNETCORE_HTTP_PORTS.

Verification

docker build -f Services/Product/Product.API/Dockerfile -t product-service:test .   # succeeds
# container + postgres on a shared network:
GET /health  -> 200 Healthy
GET /ready   -> 200 Healthy         (db up)
GET /health  -> 200                 (db down; liveness unaffected)
GET /ready   -> 503                 (db down; readiness fails)
id -> uid=1654(app)                 (non-root)

Companion Helm changes: quickapp-iac product-service chart (/health + /ready probes, env/secret config).

Note: the pre-existing Shared.* project-reference warning is unchanged by this PR.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/3d95e4a548134c9e9f8ee60fd2657ba0
Requested by: @mbatchelor81

@mbatchelor81 mbatchelor81 self-assigned this Jul 13, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant