From f410dbda88630d392a92b4c394fc0c820c3b541a Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 13 Mar 2025 14:29:30 +0100 Subject: [PATCH] dockerfile: dind target to build docker image for testing Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ Dockerfile | 9 +++++++++ docker-bake.hcl | 11 +++++++++++ 3 files changed, 40 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8d321e728..3ce3a5313d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,3 +154,23 @@ jobs: uses: github/codeql-action/upload-sarif@v3 with: sarif_file: ${{ env.DESTDIR }}/govulncheck.out + + build-dind: + runs-on: ubuntu-24.04 + needs: + - validate-dco + steps: + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + version: ${{ env.SETUP_BUILDX_VERSION }} + driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }} + buildkitd-flags: --debug + - + name: Build dind image + uses: docker/bake-action@v6 + with: + targets: dind + set: | + *.output=type=cacheonly diff --git a/Dockerfile b/Dockerfile index 66a0855e74..dfd6fc2608 100644 --- a/Dockerfile +++ b/Dockerfile @@ -657,6 +657,15 @@ FROM dev-base AS devcontainer COPY --link . . COPY --link --from=gopls /build/ /usr/local/bin/ +# usage: +# > docker buildx bake dind +# > docker run -d --restart always --privileged --name devdind -p 12375:2375 docker-dind --debug --host=tcp://0.0.0.0:2375 --tlsverify=false +FROM docker:dind AS dind +COPY --link --from=dockercli /build/docker /usr/local/bin/ +COPY --link --from=buildx /buildx /usr/local/libexec/docker/cli-plugins/docker-buildx +COPY --link --from=compose /docker-compose /usr/local/libexec/docker/cli-plugins/docker-compose +COPY --link --from=all / /usr/local/bin/ + # usage: # > make shell # > SYSTEMD=true make shell diff --git a/docker-bake.hcl b/docker-bake.hcl index 9c7c33c8cd..195768e83a 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -164,6 +164,17 @@ target "bin-image-cross" { ] } +# +# dind +# + +target "dind" { + inherits = ["_common"] + target = "dind" + tags = ["docker-dind"] + output = ["type=docker"] +} + # # dev #