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
2 changes: 2 additions & 0 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
vars: |
PKG_REPO=${{ inputs.engine-repo }}
PKG_REF=${{ inputs.engine-ref }}
DOCKER_VERSION=${{ inputs.version }}
PKG_DEB_REVISION=${{ inputs.revision }}
PKG_RPM_RELEASE=${{ inputs.revision }}
dockerhub_username: dockereng
Expand All @@ -87,6 +88,7 @@ jobs:
vars: |
PKG_REPO=${{ inputs.cli-repo }}
PKG_REF=${{ inputs.cli-ref }}
DOCKER_VERSION=${{ inputs.version }}
PKG_DEB_REVISION=${{ inputs.revision }}
PKG_RPM_RELEASE=${{ inputs.revision }}
dockerhub_username: dockereng
Expand Down
4 changes: 3 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ variable "CLI_REF" {
default = null
}
variable "DOCKER_VERSION" {
description = "Docker version to use for the combined Docker static package. If empty, the Engine source version is used."
description = "Version for Docker, Engine, and CLI packages. If empty, versions are derived from source; combined archives use the Engine version."
default = null
}
variable "RUNC_REF" {
Expand Down Expand Up @@ -622,6 +622,7 @@ target "_pkg-docker-cli" {
PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-ce-cli"
PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/cli.git"
PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "master"
DOCKER_VERSION = DOCKER_VERSION
GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.26.8" # https://github.com/docker/cli/blob/master/Dockerfile
GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm"
PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "5"
Expand All @@ -634,6 +635,7 @@ target "_pkg-docker-engine" {
PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-ce"
PKG_REPO = PKG_REPO != null && PKG_REPO != "" ? PKG_REPO : "https://github.com/docker/docker.git"
PKG_REF = PKG_REF != null && PKG_REF != "" ? PKG_REF : "master"
DOCKER_VERSION = DOCKER_VERSION
GO_VERSION = GO_VERSION != null && GO_VERSION != "" ? GO_VERSION : "1.26.8" # https://github.com/moby/moby/blob/master/Dockerfile
GO_IMAGE_VARIANT = GO_IMAGE_VARIANT != null && GO_IMAGE_VARIANT != "" ? GO_IMAGE_VARIANT : "bookworm"
PKG_DEB_EPOCH = PKG_DEB_EPOCH != null && PKG_DEB_EPOCH != "" ? PKG_DEB_EPOCH : "5"
Expand Down
25 changes: 14 additions & 11 deletions hack/scripts/gen-ver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ set -x

srcdir="$1"
if [ -z "$srcdir" ]; then
echo "usage: ./gen-ver <srcdir>" >&2
echo "usage: ./gen-ver <srcdir> [version]" >&2
exit 1
fi

tagregex="${TAGPREFIX}v[0-9]*"
version=$(git -C "${srcdir}" describe --match "$tagregex" --tags)
version="${2:-}"
if [ -n "$version" ]; then
version="v${version#v}"
else
tagregex="${TAGPREFIX}v[0-9]*"
version=$(git -C "${srcdir}" describe --match "$tagregex" --tags)
if [ -n "$TAGPREFIX" ]; then
version="${version#$TAGPREFIX}"
fi
fi
commit="$(git --git-dir "${srcdir}/.git" rev-parse HEAD)"
commitShort=${commit:0:7}

if [ -n "$TAGPREFIX" ]; then
version="${version#$TAGPREFIX}"
fi

# rpm "Release:" field ($rpmRelease) is used to set the "_release" macro, which
# is an incremental number for builds of the same release (Version: / #rpmVersion).
#
Expand Down Expand Up @@ -66,10 +70,9 @@ fi
# Docker 22.06.0-dev: version=0.0.0~YYYYMMDDHHMMSS.gitHASH, release=0
rpmRelease=1

# if NIGHTLY_BUILD=1, or we have a "-dev" suffix or a commit not pointing to a
# tag, this is a nightly build, and we'll create a pseudo version based on
# commit-date and -sha.
if [[ "$NIGHTLY_BUILD" == "1" ]] || [[ "$version" == *-dev ]] || [[ -z "$(git -C "${srcdir}" tag --points-at HEAD --sort -version:refname)" ]]; then
# NIGHTLY_BUILD=1 always forces a pseudo version. Without an explicit version,
# a "-dev" suffix or a commit not pointing to a tag also denotes a nightly.
if [[ "$NIGHTLY_BUILD" == "1" || ( -z "${2:-}" && ( "$version" == *-dev || -z "$(git -C "${srcdir}" tag --points-at HEAD --sort -version:refname)" ) ) ]]; then
# based on golang's pseudo-version: https://groups.google.com/forum/#!topic/golang-dev/a5PqQuBljF4
#
# using a "pseudo-version" of the form v0.0.0-yyyymmddhhmmss-abcdefa,
Expand Down
7 changes: 6 additions & 1 deletion pkg/docker-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ RUN --mount=from=src,source=/src,target=/cli \
FROM src-base AS metadata-builder
ARG PKG_REPO
ARG PKG_REF
ARG DOCKER_VERSION
ARG NIGHTLY_BUILD
RUN --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \
--mount=type=bind,from=src,source=/src,target=/src <<EOT
set -e
mkdir -p /out
for l in $(gen-ver "/src"); do
for l in $(gen-ver "/src" "${DOCKER_VERSION}"); do
export "${l?}"
done
cat > "/out/metadata.env" <<-EOF
Expand Down Expand Up @@ -111,6 +112,7 @@ 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 DOCKER_VERSION
ARG NIGHTLY_BUILD
ARG DISTRO_RELEASE
ARG DISTRO_ID
Expand Down Expand Up @@ -148,6 +150,7 @@ 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 DOCKER_VERSION
ARG NIGHTLY_BUILD
ARG DISTRO_RELEASE
ARG DISTRO_ID
Expand Down Expand Up @@ -184,6 +187,7 @@ RUN --mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw

FROM build-base-static AS builder-static-nosdk
RUN apt-get install -y --no-install-recommends dpkg-dev clang lld llvm make pkg-config
ARG DOCKER_VERSION
ARG PKG_NAME
ARG PKG_REF
ARG NIGHTLY_BUILD
Expand All @@ -204,6 +208,7 @@ FROM builder-static-nosdk AS builder-static-windows

FROM build-base-static AS builder-static-darwin
RUN apt-get install -y --no-install-recommends dpkg-dev clang lld llvm make pkg-config
ARG DOCKER_VERSION
ARG PKG_NAME
ARG PKG_REF
ARG NIGHTLY_BUILD
Expand Down
2 changes: 1 addition & 1 deletion pkg/docker-cli/scripts/pkg-deb-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if ! command -v xx-info &> /dev/null; then
exit 1
fi

for l in $(gen-ver "${SRCDIR}"); do
for l in $(gen-ver "${SRCDIR}" "${DOCKER_VERSION:-}"); do
export "${l?}"
done

Expand Down
2 changes: 1 addition & 1 deletion pkg/docker-cli/scripts/pkg-rpm-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if ! command -v xx-info &> /dev/null; then
exit 1
fi

for l in $(gen-ver "${SRCDIR}"); do
for l in $(gen-ver "${SRCDIR}" "${DOCKER_VERSION:-}"); do
export "${l?}"
done

Expand Down
2 changes: 1 addition & 1 deletion pkg/docker-cli/scripts/pkg-static-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if ! command -v xx-info &> /dev/null; then
exit 1
fi

for l in $(gen-ver "${SRCDIR}"); do
for l in $(gen-ver "${SRCDIR}" "${DOCKER_VERSION:-}"); do
export "${l?}"
done

Expand Down
6 changes: 5 additions & 1 deletion pkg/docker-engine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ RUN --mount=from=src,source=/src,target=/engine \
FROM src-base AS metadata-builder
ARG PKG_REPO
ARG PKG_REF
ARG DOCKER_VERSION
ARG NIGHTLY_BUILD
ARG TAGPREFIX
RUN --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \
--mount=type=bind,from=src,source=/src,target=/src <<EOT
set -e
mkdir -p /out
for l in $(gen-ver "/src"); do
for l in $(gen-ver "/src" "${DOCKER_VERSION}"); do
export "${l?}"
done
cat > "/out/metadata.env" <<-EOF
Expand Down Expand Up @@ -112,6 +113,7 @@ 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 DOCKER_VERSION
ARG NIGHTLY_BUILD
ARG DISTRO_RELEASE
ARG DISTRO_ID
Expand Down Expand Up @@ -160,6 +162,7 @@ RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS --define "_no_libnftables ${no_libnftables}"
EOT
WORKDIR /root/rpmbuild
ARG DOCKER_VERSION
ARG NIGHTLY_BUILD
ARG DISTRO_RELEASE
ARG DISTRO_ID
Expand Down Expand Up @@ -197,6 +200,7 @@ RUN --mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw

FROM build-base-static AS builder-static
RUN apt-get install -y --no-install-recommends clang cmake gcc libc6-dev lld llvm make pkg-config
ARG DOCKER_VERSION
ARG PKG_NAME
ARG PKG_REF
ARG NIGHTLY_BUILD
Expand Down
2 changes: 1 addition & 1 deletion pkg/docker-engine/scripts/pkg-deb-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if ! command -v xx-info &> /dev/null; then
exit 1
fi

for l in $(gen-ver "${SRCDIR}"); do
for l in $(gen-ver "${SRCDIR}" "${DOCKER_VERSION:-}"); do
export "${l?}"
done

Expand Down
2 changes: 1 addition & 1 deletion pkg/docker-engine/scripts/pkg-rpm-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if ! command -v xx-info &> /dev/null; then
exit 1
fi

for l in $(gen-ver "${SRCDIR}"); do
for l in $(gen-ver "${SRCDIR}" "${DOCKER_VERSION:-}"); do
export "${l?}"
done

Expand Down
2 changes: 1 addition & 1 deletion pkg/docker-engine/scripts/pkg-static-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if ! command -v xx-info &> /dev/null; then
exit 1
fi

for l in $(gen-ver "${SRCDIR}"); do
for l in $(gen-ver "${SRCDIR}" "${DOCKER_VERSION:-}"); do
export "${l?}"
done

Expand Down
Loading