Repository navigation
feat(offload): add docker-offload-plugin deb/rpm packaging #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+520
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # Copyright 2026 Docker Packaging authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| ARG XX_VERSION="1.10.0" | ||
|
|
||
| ARG DISTRO_NAME="debian13" | ||
| ARG DISTRO_TYPE="deb" | ||
| ARG DISTRO_RELEASE="debian" | ||
| ARG DISTRO_SUITE="trixie" | ||
| ARG DISTRO_ID="13" | ||
| ARG DISTRO_IMAGE="debian:trixie" | ||
|
|
||
| ARG PKG_NAME="docker-offload-plugin" | ||
|
|
||
| ARG GO_IMAGE="golang" | ||
| # Must be the exact Go version of the release build, so the package build reproduces it. | ||
| ARG GO_VERSION="1.27.3" | ||
| ARG GO_IMAGE_VARIANT="trixie" | ||
|
|
||
| # stage used as named context that mounts hack/scripts | ||
| # see pkg target in docker-bake.hcl | ||
| FROM scratch AS scripts | ||
|
|
||
| # The source tree is private and is passed in by the caller as the src named context, with | ||
| # Go dependencies already vendored. There is no git clone fallback. | ||
| FROM scratch AS src | ||
|
|
||
| # cross compilation helper | ||
| FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx | ||
|
|
||
| # go base image to retrieve /usr/local/go | ||
| FROM ${GO_IMAGE}:${GO_VERSION}-${GO_IMAGE_VARIANT} AS go | ||
|
|
||
| # deb | ||
| FROM ${DISTRO_IMAGE} AS builder-deb | ||
| COPY --from=xx / / | ||
| ENV GOPATH="/go" | ||
| ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin" | ||
| ENV GOTOOLCHAIN="local" | ||
| ARG DISTRO_NAME | ||
| RUN apt-get update && apt-get install -y --no-install-recommends apt-utils bash ca-certificates devscripts equivs | ||
| COPY deb /root/package/debian | ||
| ARG TARGETPLATFORM | ||
| RUN mk-build-deps -t "xx-apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/package/debian/control | ||
| WORKDIR /root/package | ||
| ARG VERSION | ||
| ARG COMMIT | ||
| ARG BUILD | ||
| ARG DATE | ||
| ARG DISTRO_RELEASE | ||
| ARG DISTRO_ID | ||
| ARG DISTRO_SUITE | ||
| ARG PKG_NAME | ||
| ARG PKG_PACKAGER | ||
| ARG PKG_DEB_BUILDFLAGS | ||
| ARG PKG_DEB_REVISION | ||
| ARG PKG_DEB_EPOCH | ||
| ARG SOURCE_DATE_EPOCH | ||
| RUN --mount=type=bind,source=scripts/pkg-deb-build.sh,target=/usr/local/bin/pkg-deb-build \ | ||
| --mount=type=bind,from=scripts,source=gen-deb-changelog.sh,target=/usr/local/bin/gen-deb-changelog \ | ||
| --mount=type=bind,from=src,target=/root/package/offload,rw \ | ||
| --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ | ||
| --mount=type=secret,id=build-env,target=/run/secrets/build-env \ | ||
| OUTDIR=/out SRCDIR=./offload BUILD_ENV_FILE=/run/secrets/build-env pkg-deb-build | ||
|
|
||
| # rpm | ||
| FROM ${DISTRO_IMAGE} AS builder-rpm | ||
| COPY --from=xx / / | ||
| ENV GOPATH="/go" | ||
| ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin" | ||
| ENV GOTOOLCHAIN="local" | ||
| ARG DISTRO_NAME | ||
| RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \ | ||
| rpm-init $DISTRO_NAME | ||
| COPY rpm /root/rpmbuild/SPECS | ||
| ARG TARGETPLATFORM | ||
| RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \ | ||
| rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS | ||
| WORKDIR /root/rpmbuild | ||
| ARG VERSION | ||
| ARG COMMIT | ||
| ARG BUILD | ||
| ARG DATE | ||
| ARG DISTRO_RELEASE | ||
| ARG DISTRO_ID | ||
| ARG DISTRO_SUITE | ||
| ARG PKG_NAME | ||
| ARG PKG_PACKAGER | ||
| ARG PKG_RPM_BUILDFLAGS | ||
| ARG PKG_RPM_RELEASE | ||
| ARG SOURCE_DATE_EPOCH | ||
| RUN --mount=type=bind,source=scripts/pkg-rpm-build.sh,target=/usr/local/bin/pkg-rpm-build \ | ||
| --mount=type=bind,from=src,target=/usr/local/src/offload,rw \ | ||
| --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ | ||
| --mount=type=secret,id=build-env,target=/run/secrets/build-env \ | ||
| OUTDIR=/out SRCDIR=/usr/local/src/offload BUILD_ENV_FILE=/run/secrets/build-env pkg-rpm-build | ||
|
|
||
| FROM builder-${DISTRO_TYPE} AS build-pkg | ||
| ARG BUILDKIT_SBOM_SCAN_STAGE=true | ||
|
|
||
| FROM scratch AS pkg | ||
| COPY --from=build-pkg /out / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Source: docker-offload-plugin | ||
| Section: admin | ||
| Priority: optional | ||
| Maintainer: Docker <support@docker.com> | ||
| Homepage: https://www.docker.com | ||
| Standards-Version: 3.9.6 | ||
| Build-Depends: bash, | ||
| debhelper-compat (= 13), | ||
| make | ||
|
|
||
| Package: docker-offload-plugin | ||
| Priority: optional | ||
| Architecture: linux-any | ||
| Enhances: docker-ce-cli | ||
| Description: Docker Offload plugin for the Docker CLI. | ||
| Homepage: https://docs.docker.com/offload/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
| Upstream-Name: docker-offload-plugin | ||
| Source: https://docs.docker.com/offload/ | ||
|
|
||
| Files: * | ||
| Copyright: Docker, Inc. | ||
| License: Proprietary | ||
| All rights reserved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/make -f | ||
|
|
||
| # force packages to be built with xz compression, as Ubuntu 21.10 and up use | ||
| # zstd compression, which is non-standard, and breaks 'dpkg-sig --verify' | ||
| override_dh_builddeb: | ||
| dh_builddeb -- -Zxz | ||
|
|
||
| override_dh_auto_build: | ||
| make -C $(CURDIR)/offload ce-release VERSION=$(VERSION) COMMIT=$(COMMIT) BUILD=$(BUILD) DATE=$(DATE) BUILD_ENV_FILE=$(BUILD_ENV_FILE) | ||
|
|
||
| override_dh_auto_test: | ||
| ver="$$($(CURDIR)/offload/dist/docker-offload docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \ | ||
| test "$$ver" = "$(VERSION)" && echo "PASS: docker-offload version OK" || (echo "FAIL: docker-offload version ($$ver) did not match $(VERSION)" && exit 1) | ||
|
|
||
| # The build is reproducible, and the packaged binary is checked against the release | ||
| # checksums, so do not strip or otherwise rewrite it after the build. | ||
| override_dh_strip: | ||
|
|
||
| override_dh_dwz: | ||
|
|
||
| override_dh_auto_install: | ||
| install -D -p -m 0755 $(CURDIR)/offload/dist/docker-offload debian/docker-offload-plugin/usr/libexec/docker/cli-plugins/docker-offload | ||
|
|
||
| %: | ||
| dh $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| %global debug_package %{nil} | ||
| # The build is reproducible, and the packaged binary is checked against the release | ||
| # checksums, so do not strip the binary or rewrite its ELF notes after the build. | ||
| %global __brp_strip %{nil} | ||
| %global __brp_strip_comment_note %{nil} | ||
|
nicksieger marked this conversation as resolved.
Resolved
|
||
|
|
||
| Name: docker-offload-plugin | ||
| Version: %{_version} | ||
| Release: %{_release}%{?dist} | ||
| Epoch: 0 | ||
| Summary: Docker Offload plugin for the Docker CLI | ||
| Group: Tools/Docker | ||
| License: Proprietary | ||
| URL: https://docs.docker.com/offload/ | ||
| Vendor: Docker | ||
| Packager: Docker <support@docker.com> | ||
|
|
||
| Enhances: docker-ce-cli | ||
|
|
||
| BuildRequires: bash | ||
| BuildRequires: make | ||
|
|
||
| %description | ||
| Docker Offload plugin for the Docker CLI. | ||
|
|
||
| %prep | ||
|
|
||
| %build | ||
| make -C %{_srcdir} ce-release VERSION=%{_origversion} COMMIT=%{_commit} BUILD=%{_buildnum} DATE=%{_date} BUILD_ENV_FILE=%{_buildenvfile} | ||
|
|
||
| %check | ||
| ver="$(%{_srcdir}/dist/docker-offload docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }')" | ||
| test "$ver" = "%{_origversion}" && echo "PASS: docker-offload version OK" || { echo "FAIL: docker-offload version ($ver) did not match %{_origversion}"; exit 1; } | ||
|
|
||
| %install | ||
| install -D -p -m 0755 %{_srcdir}/dist/docker-offload ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-offload | ||
|
|
||
| %files | ||
| %{_libexecdir}/docker/cli-plugins/docker-offload | ||
|
|
||
| %changelog | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright 2026 Docker Packaging authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| : "${VERSION=}" | ||
| : "${COMMIT=}" | ||
| : "${BUILD=}" | ||
| : "${DATE=}" | ||
|
|
||
| : "${DISTRO_NAME=}" | ||
| : "${DISTRO_RELEASE=}" | ||
| : "${DISTRO_ID=}" | ||
| : "${DISTRO_SUITE=}" | ||
|
|
||
| : "${PKG_NAME=}" | ||
| : "${PKG_PACKAGER=}" | ||
| : "${PKG_VENDOR=}" | ||
|
|
||
| : "${PKG_DEB_REVISION=}" | ||
| : "${PKG_DEB_EPOCH=}" | ||
|
|
||
| : "${SOURCE_DATE_EPOCH=}" | ||
| : "${SRCDIR=./offload}" | ||
| : "${OUTDIR=/out}" | ||
| : "${BUILD_ENV_FILE=}" | ||
|
|
||
| set -e | ||
|
|
||
| if [ -z "$VERSION" ]; then | ||
| echo >&2 "error: VERSION is required" | ||
| exit 1 | ||
| fi | ||
| case "$VERSION" in | ||
| v*) ;; | ||
| *) echo >&2 "error: VERSION must start with v, got $VERSION"; exit 1 ;; | ||
| esac | ||
| if [ -z "$DISTRO_NAME" ]; then | ||
| echo >&2 "error: DISTRO_NAME is required" | ||
| exit 1 | ||
| fi | ||
| if [ -z "$OUTDIR" ]; then | ||
| echo >&2 "error: OUTDIR is required" | ||
| exit 1 | ||
| fi | ||
| if [ ! -f "${SRCDIR}/Makefile" ]; then | ||
| echo >&2 "error: no Makefile in ${SRCDIR}; pass the source tree as the src named context" | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p "$OUTDIR" | ||
|
|
||
| if ! command -v xx-info &> /dev/null; then | ||
| echo >&2 "error: xx cross compilation helper is required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Derive deb-compatible package version from VERSION. | ||
| # Tagged pre-release versions use ~ so they sort lower: | ||
| # v0.1.0-beta.1 -> 0.1.0~beta.1 | ||
| tilde='~' | ||
| pkgVersion="${VERSION#v}" | ||
| pkgVersion="${pkgVersion//-/$tilde}" | ||
|
|
||
| gen-deb-changelog "$VERSION" "$pkgVersion" "$DISTRO_RELEASE" "$DISTRO_ID" "$DISTRO_SUITE" "$PKG_DEB_REVISION" "$PKG_DEB_EPOCH" | ||
|
|
||
| pkgoutput="${OUTDIR}/${DISTRO_RELEASE}/${DISTRO_SUITE}/$(xx-info arch)" | ||
| if [ -n "$(xx-info variant)" ]; then | ||
| pkgoutput="${pkgoutput}/$(xx-info variant)" | ||
| fi | ||
| mkdir -p "${pkgoutput}" | ||
|
|
||
| set -x | ||
|
|
||
| chmod -x debian/control debian/copyright | ||
| VERSION=${VERSION} COMMIT=${COMMIT} BUILD=${BUILD} DATE=${DATE} BUILD_ENV_FILE=${BUILD_ENV_FILE} \ | ||
| dpkg-buildpackage $PKG_DEB_BUILDFLAGS --host-arch $(xx-info debian-arch) --target-arch $(xx-info debian-arch) | ||
| cp /root/docker-* "${pkgoutput}"/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR but we could derive package list from Bake instead of scanning
pkg/