File docker-buildx.spec of Package docker-buildx
%define realname buildx
%define realver 0.11.2
%define srcext tar.gz
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
# Common info
Name: docker-%{realname}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: Apache-2.0
Group: System/Management
URL: https://github.com/docker/buildx
Summary: Docker CLI plugin for extended build capabilities with BuildKit
# Install-time parameters
Requires: docker
# Build-time parameters
BuildRequires: go >= 1.20
Source: https://codeload.github.com/docker/buildx/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{version}%{?extraver}.%{srcext}
# go mod vendor -v; tar -Jcvf ../vendor-mods.tar.xz vendor; rm -rf vendor
Source11: vendor-mods.tar.xz
%description
buildx is a Docker CLI plugin for extended build capabilities with BuildKit.
Key features:
* Familiar UI from docker build
* Full BuildKit capabilities with container driver
* Multiple builder instance support
* Multi-node builds for cross-platform images
* Compose build support
* High-level build constructs (bake)
* In-container driver support (both Docker and Kubernetes)
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a11
# Build step (compile/build binaries, documentation, etc)
%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
export GOPATH=$(pwd -P)/.gomodules
export GOCACHE=$(pwd -P)/.gocache
export GOTRACEBACK=crash
export CGO_ENABLED=1
export CGO_CFLAGS="$_CFLAGS"
export CGO_LDFLAGS="$_LDFLAGS"
# Build static assets
go build \
-v \
-mod=vendor \
-buildmode=pie \
-gcflags=all='-dwarf=false' \
-ldflags=all='-s -w -X github.com/docker/buildx.version.Version=%{version} -X github.com/docker/buildx.version.Revision=v%{version} -X github.com/docker/buildx.version.Package=github.com/docker/buildx' \
-trimpath \
-o bin/docker-buildx \
./cmd/buildx
# Install built stuff
%install
# Install executable
%{__install} -D -m0755 bin/docker-buildx %{buildroot}%{_libexecdir}/docker/cli-plugins/docker-buildx
# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
# Files list
%files
%defattr(-,root,root)
%license LICENSE
%doc docs/reference/*.md
%doc README.md
%dir %{_libexecdir}/docker/cli-plugins
%dir %{_libexecdir}/docker
%{_libexecdir}/docker/cli-plugins/docker-buildx
%changelog