Skip to content

Docker.DotNet → Testcontainers migration - #1149

Open
louis-z wants to merge 4 commits into
mainfrom
docker-dotnet-testcontainers-migration
Open

louis-z wants to merge 4 commits into
mainfrom
docker-dotnet-testcontainers-migration

Conversation

@louis-z

@louis-z louis-z commented Sep 16, 2026

Copy link
Copy Markdown
Member
  • Replace the Docker.DotNet package (unmaintained) with Docker.DotNet.Enhanced (its actively maintained fork, now owned by the Testcontainers org).
  • Add the Testcontainers package.
  • GitLabDockerContainer.SpawnLocalDockerContainerAsync (used for local test runs) now creates/starts the GitLab container via Testcontainers' ContainerBuilder, instead of ~90 lines of manual container lookup/create/start/health-polling code.
  • Credential generation (RunGitLabRailsRunnerAsync) now runs the gitlab-rails runner command differently depending on how the container came to exist:
    • Local runs: execs directly into the container object Testcontainers already holds a reference to.
    • CI runs: GitLab is started by GitHub Actions as a service container, not by our code, so we still use a raw Docker Engine API client (via Docker.DotNet.Enhanced) to find that container and exec into it.

Rationale

  • Docker.DotNet has had no releases or fixes in a long time; staying on it was a growing maintenance risk.
  • Testcontainers is the purpose-built library for "spin up a container for tests, wait until it's ready, tear it down"; it replaces our hand-rolled orchestration/health-check code instead of just swapping the underlying HTTP client.
  • Testcontainers can't attach to a container it didn't create itself, so the CI path (which execs into a pre-existing GitHub Actions service container) still needs a low-level Docker API client. Docker.DotNet.Enhanced fills that one remaining need, and since Testcontainers depends on it internally too, there's no duplicate/conflicting dependency.

Trade-off to know about

  • The old code auto-detected when the local GitLab image version changed and removed the stale container before creating a new one.
  • The new code uses Testcontainers' WithReuse(true) to keep the container running across local test runs (GitLab takes minutes to boot), but reuse matching is based on name + config.
  • If you bump LocalGitLabDockerVersion, you now need to manually remove the old container first:
    docker rm -f NGitLabClientTests
    

@louis-z
louis-z force-pushed the docker-dotnet-testcontainers-migration branch from fcae0b9 to 94c0f83 Compare September 17, 2026 13:47
@louis-z
louis-z marked this pull request as ready for review September 17, 2026 15:07
@louis-z
louis-z requested a review from a team as a code owner September 17, 2026 15:07
@louis-z
louis-z requested review from msrouchou and removed request for a team September 17, 2026 15:07
@louis-z
louis-z marked this pull request as draft September 17, 2026 17:05
@louis-z
louis-z marked this pull request as ready for review September 17, 2026 17:56
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