From 24bb2a2ee08e28f7577770cd57f19f91a6f16b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Tue, 5 Aug 2025 12:16:17 +0200 Subject: [PATCH] Use Go modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- deb/common/rules | 5 ++++- deb/debian-bookworm/Dockerfile | 2 +- deb/debian-bullseye/Dockerfile | 2 +- deb/debian-trixie/Dockerfile | 2 +- deb/raspbian-bookworm/Dockerfile | 2 +- deb/raspbian-bullseye/Dockerfile | 2 +- deb/ubuntu-jammy/Dockerfile | 2 +- deb/ubuntu-noble/Dockerfile | 2 +- deb/ubuntu-oracular/Dockerfile | 2 +- deb/ubuntu-plucky/Dockerfile | 2 +- rpm/SPECS/docker-ce.spec | 12 +++++++++++- rpm/centos-10/Dockerfile | 2 +- rpm/centos-9/Dockerfile | 2 +- rpm/fedora-41/Dockerfile | 2 +- rpm/fedora-42/Dockerfile | 2 +- rpm/rhel-8/Dockerfile | 2 +- rpm/rhel-9/Dockerfile | 2 +- 17 files changed, 30 insertions(+), 17 deletions(-) diff --git a/deb/common/rules b/deb/common/rules index 5a3acca432..71fca9ade8 100755 --- a/deb/common/rules +++ b/deb/common/rules @@ -20,9 +20,12 @@ export PKG_REVISION override_dh_builddeb: dh_builddeb -- -Zxz +# Determine the Go module mode based on the presence of vendor.mod or go.mod +override_dh_auto_build: GOMOD := $(if $(wildcard engine/vendor.mod),off,$(if $(wildcard engine/go.mod),on,$(error "No go.mod or vendor.mod found in engine directory"))) +# Override the default dh_auto_build target override_dh_auto_build: # Build the daemon and dependencies - cd engine && DOCKER_GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary + cd engine && GO111MODULE=$(GOMOD) DOCKER_GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh tini cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh rootlesskit dynamic diff --git a/deb/debian-bookworm/Dockerfile b/deb/debian-bookworm/Dockerfile index b9125f0a05..3c1c3de441 100644 --- a/deb/debian-bookworm/Dockerfile +++ b/deb/debian-bookworm/Dockerfile @@ -14,7 +14,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/debian-bullseye/Dockerfile b/deb/debian-bullseye/Dockerfile index 83e723e9c5..c997d24c8e 100644 --- a/deb/debian-bullseye/Dockerfile +++ b/deb/debian-bullseye/Dockerfile @@ -14,7 +14,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/debian-trixie/Dockerfile b/deb/debian-trixie/Dockerfile index 174bcb40b3..82d645c829 100644 --- a/deb/debian-trixie/Dockerfile +++ b/deb/debian-trixie/Dockerfile @@ -14,7 +14,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/raspbian-bookworm/Dockerfile b/deb/raspbian-bookworm/Dockerfile index 18595a36ea..a67888e342 100644 --- a/deb/raspbian-bookworm/Dockerfile +++ b/deb/raspbian-bookworm/Dockerfile @@ -14,7 +14,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/raspbian-bullseye/Dockerfile b/deb/raspbian-bullseye/Dockerfile index b8a5722a2e..fbf3e75ad1 100644 --- a/deb/raspbian-bullseye/Dockerfile +++ b/deb/raspbian-bullseye/Dockerfile @@ -14,7 +14,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/ubuntu-jammy/Dockerfile b/deb/ubuntu-jammy/Dockerfile index f3a46868a2..87930ab2be 100644 --- a/deb/ubuntu-jammy/Dockerfile +++ b/deb/ubuntu-jammy/Dockerfile @@ -20,7 +20,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/ubuntu-noble/Dockerfile b/deb/ubuntu-noble/Dockerfile index c2aaecc029..bf6f8e515d 100644 --- a/deb/ubuntu-noble/Dockerfile +++ b/deb/ubuntu-noble/Dockerfile @@ -20,7 +20,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/ubuntu-oracular/Dockerfile b/deb/ubuntu-oracular/Dockerfile index bfc467e8e7..b1567aec41 100644 --- a/deb/ubuntu-oracular/Dockerfile +++ b/deb/ubuntu-oracular/Dockerfile @@ -20,7 +20,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/deb/ubuntu-plucky/Dockerfile b/deb/ubuntu-plucky/Dockerfile index ebbfbadd67..5adf08e82f 100644 --- a/deb/ubuntu-plucky/Dockerfile +++ b/deb/ubuntu-plucky/Dockerfile @@ -20,7 +20,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y curl devscripts equivs git ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/rpm/SPECS/docker-ce.spec b/rpm/SPECS/docker-ce.spec index d3b7217885..4e77be601b 100644 --- a/rpm/SPECS/docker-ce.spec +++ b/rpm/SPECS/docker-ce.spec @@ -68,7 +68,17 @@ ln -snf ${RPM_BUILD_DIR}/src/engine /go/src/github.com/docker/docker pushd ${RPM_BUILD_DIR}/src/engine TMP_GOPATH="/go" hack/dockerfile/install/install.sh tini -VERSION=%{_origversion} PRODUCT=docker hack/make.sh dynbinary + +# Determine Go module mode based on file presence +if [ -f vendor.mod ]; then + GOMOD=off +elif [ -f go.mod ]; then + GOMOD=on +else + echo "No go.mod or vendor.mod found in engine directory" + exit 1 +fi +GO111MODULE=$GOMOD VERSION=%{_origversion} PRODUCT=docker hack/make.sh dynbinary popd # build man-pages diff --git a/rpm/centos-10/Dockerfile b/rpm/centos-10/Dockerfile index dd12cfb485..a924369f8a 100644 --- a/rpm/centos-10/Dockerfile +++ b/rpm/centos-10/Dockerfile @@ -9,7 +9,7 @@ FROM ${GO_IMAGE} AS golang FROM ${BUILD_IMAGE} ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/rpm/centos-9/Dockerfile b/rpm/centos-9/Dockerfile index c04299c12f..3843c34d66 100644 --- a/rpm/centos-9/Dockerfile +++ b/rpm/centos-9/Dockerfile @@ -9,7 +9,7 @@ FROM ${GO_IMAGE} AS golang FROM ${BUILD_IMAGE} ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/rpm/fedora-41/Dockerfile b/rpm/fedora-41/Dockerfile index 322184bfc1..bcfcc36502 100644 --- a/rpm/fedora-41/Dockerfile +++ b/rpm/fedora-41/Dockerfile @@ -9,7 +9,7 @@ FROM ${GO_IMAGE} AS golang FROM ${BUILD_IMAGE} ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/rpm/fedora-42/Dockerfile b/rpm/fedora-42/Dockerfile index 5863826321..3a9ce8dae5 100644 --- a/rpm/fedora-42/Dockerfile +++ b/rpm/fedora-42/Dockerfile @@ -9,7 +9,7 @@ FROM ${GO_IMAGE} AS golang FROM ${BUILD_IMAGE} ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/rpm/rhel-8/Dockerfile b/rpm/rhel-8/Dockerfile index 13d256594d..99bb7492c8 100644 --- a/rpm/rhel-8/Dockerfile +++ b/rpm/rhel-8/Dockerfile @@ -26,7 +26,7 @@ EOT FROM subscribed-image ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin diff --git a/rpm/rhel-9/Dockerfile b/rpm/rhel-9/Dockerfile index c9a198ef2d..9266d750ce 100644 --- a/rpm/rhel-9/Dockerfile +++ b/rpm/rhel-9/Dockerfile @@ -26,7 +26,7 @@ EOT FROM subscribed-image ENV GOPROXY=https://proxy.golang.org|direct -ENV GO111MODULE=off +ENV GO111MODULE=on ENV GOPATH=/go ENV GOTOOLCHAIN=local ENV PATH=$PATH:/usr/local/go/bin:$GOPATH/bin