Repository navigation
Replies: 3 comments 6 replies
|
What about follow the same approach as our tests, where we read the version number from a Dockerfile: |
The idea is to address exactly this. Define the image in a Dockerfile that Renovate or Dependabot can update, and have the tests read the image value directly from that file. The services can then detect version updates and update the Dockerfile accordingly. |
|
Not wanted by the maintainer. The recommendation is to adapt this pattern by c&p the necessary bits into the custom project configuration. In my case, I will have to create a small NuGet package to avoid duplicating the necessary code within my 15 apps. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation
Module builders (
PostgreSqlBuilder,PlaywrightBuilder, etc.) now require callers to pass the image explicitly — the parameterless constructors with a baked-in default image are deprecated (see discussion #1470). That's a good change: it makes image selection explicit and caller-owned. But it reintroduces a problem the baked-in defaults used to hide: the image reference now lives as a string literal in test source code, which most dependency-update bots (Renovate, Dependabot, …) cannot see or update, since they only scan manifest-like files (.csproj,Dockerfile,docker-compose.yml, …), not arbitrary C#.Concretely, in my project I had:
Renovate has no built-in manager for this. I ended up building my own convention:
testcontainers.jsonfixture file listing every image I use, withimage/tagsplit into separate fields (so a generic extraction query doesn't need per-image tag-format regex):{ "postgres": { "image": "postgres", "tag": "18-alpine" }, "playwright": { "image": "mcr.microsoft.com/playwright", "tag": "v1.63.0-noble" }, "wiremock": { "image": "sheyenrath/wiremock.net-alpine", "tag": "2.14.0" } }GetImageReference(name) => "{image}:{tag}", used at the builder call sites instead of hardcoded strings.jsonatacustom manager (not regex) that matches any file namedtestcontainers.jsonand extractsdepName/currentValuepairs for the docker datasource — reusable across any repo that adopts the convention, with zero per-repo Renovate config needed beyond including the shared preset.Working example (both pieces, real commits, public repos):
Proposal
Would there be interest in standardizing this pattern at the
testcontainers-dotnetlevel? Possibly cross-language too — I checkedtestcontainers-java'sPostgreSQLContainer, and its parameterless constructor is@Deprecatedfor the same reason, so at least Java is facing/addressing the identical problem. I haven't checked Go/Python/Node/Rust, so I can't claim they all do the same, but it seems plausible this isn't .NET-specific.Concretely, that could mean:
~/.testcontainers.properties, something liketestcontainers.images.jsonmight be clearer than my ad-hoctestcontainers.json).TestcontainersImages.Get("postgres")) shipped in the core package, so consumers don't need to hand-roll the loader.Open questions / things I'm genuinely unsure about
Happy to contribute the schema/helper/docs if there's interest — this is already running in production for me, just in userland rather than upstream.
This proposal was drafted with AI assistance (GitHub Copilot CLI) based on a real-world implementation I built; I've reviewed and verified its factual claims before posting.
All reactions