Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/.pkgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
name: Set pkgs output
id: set
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
# offload builds from a private source tree and is built from its own repo.
DISABLED_PACKAGES: offload
Comment on lines +24 to +26

Copy link
Copy Markdown
Member

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/

with:
script: |
const fs = require('fs');
Expand Down
16 changes: 15 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ variable "PKG_PLATFORMS_BASE" {
model = ["darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64", "linux/arm/v7", "windows/amd64", "windows/arm64"]
# https://github.com/docker/docker-agent/blob/5b9feaabe743a5ad577f2247ed55d5dcb2678e8b/Taskfile.yml#L79
agent = ["darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64", "windows/amd64", "windows/arm64"]
# Linux packages only; darwin and windows ship through the source repo.
offload = ["linux/amd64", "linux/arm64"]
}
}

Expand All @@ -102,7 +104,8 @@ variable "PKG_PLATFORMS_EXTRA" {
variable "PKG_DISTROS" {
description = "Package-specific distro mapping. Packages omitted here build for all DISTROS."
default = {
docker = ["static"]
docker = ["static"]
offload = ["ubuntu2404", "ubuntu2604", "rockylinux8"]
}
}

Expand Down Expand Up @@ -693,6 +696,17 @@ target "_pkg-agent" {
}
}

# The source repo is private, so there is no PKG_REPO/PKG_REF clone. Offload is not in PKGS_BASE.
# The offload repo adds it through PKGS_EXTRA in a remote override, and sets the VERSION, COMMIT,
# BUILD and DATE args, the build-env secret and the src named context there.
target "_pkg-offload" {
args = {
PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-offload-plugin"
GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "trixie"
PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : ""
}
}

# Returns the list of supported platforms for a given package.
function "pkgPlatforms" {
params = [pkg]
Expand Down
115 changes: 115 additions & 0 deletions pkg/offload/Dockerfile
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 /
16 changes: 16 additions & 0 deletions pkg/offload/deb/control
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/
8 changes: 8 additions & 0 deletions pkg/offload/deb/copyright
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.
25 changes: 25 additions & 0 deletions pkg/offload/deb/rules
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 $@
1 change: 1 addition & 0 deletions pkg/offload/deb/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
41 changes: 41 additions & 0 deletions pkg/offload/rpm/docker-offload-plugin.spec
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}
Comment thread
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
89 changes: 89 additions & 0 deletions pkg/offload/scripts/pkg-deb-build.sh
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}"/
Loading
Loading