From 3797c10a841ecf2bc0174216ccafbba4b99ca002 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:45:56 +0000 Subject: [PATCH] Expose host.docker.internal correctly in GHA --- .github/workflows/tests.yaml | 4 ---- internal/deploy/deploy.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3542207..4344253 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -113,10 +113,6 @@ jobs: COMPLEMENT_SHARE_ENV_PREFIX: PASS_ PASS_SYNAPSE_COMPLEMENT_DATABASE: sqlite DOCKER_BUILDKIT: 1 - - - run: | - docker ps | grep mitm | grep -Eo '[^ ]*$' | xargs docker logs - name: Debugging - name: Upload logs uses: actions/upload-artifact@v2 diff --git a/internal/deploy/deploy.go b/internal/deploy/deploy.go index 817acb8..45af62b 100644 --- a/internal/deploy/deploy.go +++ b/internal/deploy/deploy.go @@ -12,11 +12,13 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "sync" "testing" "time" + "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" "github.com/matrix-org/complement" "github.com/matrix-org/complement/must" @@ -167,6 +169,15 @@ func RunNewDeployment(t *testing.T, shouldTCPDump bool) *SlidingSyncDeployment { Mounts: testcontainers.Mounts( testcontainers.BindMount(filepath.Join(workingDir, "addons"), "/addons"), ), + HostConfigModifier: func(hc *container.HostConfig) { + if runtime.GOOS == "linux" { // Specifically useful for GHA + // Ensure that the container can contact the host, so they can + // interact with a complement-controlled test server. + // Note: this feature of docker landed in Docker 20.10, + // see https://github.com/moby/moby/pull/40007 + hc.ExtraHosts = []string{"host.docker.internal:host-gateway"} + } + }, }, Started: true, })