testcontainers / testcontainers/testcontainers-dotnet

[Enhancement]: Environment Variables for Named Image Paths

Open
#1,517 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
4.4k
Forks
357
Avg merge
14h 42m
Merged PRs (30d)
16

Description

Problem

If an image is not available, e.g. due to a bug, the simplest workaround recommended today is to add .WithImage("docker-registry-url-path-to-image") to the code.

Solution

Ideally, image builders would have names, and those names would be able to specify via environment variable an alternative url to the ones hardcoded in TestContainers packages.

Benefit

C# code is not directly edited, and changes can be flipped via command line environment variables, such as in Runners (GitHub Actions, AZP, etc). This would also facilitate other user stories, such as using The GitHub Actions matrix strategy to run the job with multiple images.

Alternatives
  1. Lots of commits to my GitHub repository's /src/ or /tests/ folders that have nothing to do with the actual purpose of the repository, or than to alter dependencies.
  2. Implement my own environment variables for the images I care about, and do:
    var sqlServerImage = Environment.GetEnvironmentVariable("FM_TestContainers_SqlServer_RemoteUri");
    if (sqlServerImage != null)
      builder = builder.WithImage(sqlServerImage);
    
Would you like to help contributing this enhancement?

No

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the .WithImage(...) entry point and inspect the repository's /src/ and /tests/ areas to find how image builders currently store image paths. Define the named-image and environment-variable behavior, then verify it with tests under /tests/; done means callers can override hardcoded image URLs without editing C# code.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker
Domain
devops, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.