forked from minio/minio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-buildx.sh
More file actions
executable file
·69 lines (54 loc) · 1.9 KB
/
docker-buildx.sh
File metadata and controls
executable file
·69 lines (54 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -ex
function _init() {
## All binaries are static make sure to disable CGO.
export CGO_ENABLED=0
export CRED_DIR="/media/${USER}/minio"
## List of architectures and OS to test coss compilation.
SUPPORTED_OSARCH="linux/ppc64le linux/amd64 linux/arm64"
remote=$(git remote get-url upstream)
if test "$remote" != "git@github.com:minio/minio.git"; then
echo "Script requires that the 'upstream' remote is set to git@github.com:minio/minio.git"
exit 1
fi
git remote update upstream && git checkout master && git rebase upstream/master
release=$(git describe --abbrev=0 --tags)
export release
}
function _build() {
local osarch=$1
IFS=/ read -r -a arr <<<"$osarch"
os="${arr[0]}"
arch="${arr[1]}"
package=$(go list -f '{{.ImportPath}}')
printf -- "--> %15s:%s\n" "${osarch}" "${package}"
# go build -trimpath to build the binary.
export GOOS=$os
export GOARCH=$arch
export MINIO_RELEASE=RELEASE
LDFLAGS=$(go run buildscripts/gen-ldflags.go)
go build -tags kqueue -trimpath --ldflags "${LDFLAGS}" -o ./minio-${arch}.${release}
minisign -qQSm ./minio-${arch}.${release} -s "$CRED_DIR/minisign.key" <"$CRED_DIR/minisign-passphrase"
sha256sum_str=$(sha256sum <./minio-${arch}.${release})
rc=$?
if [ "$rc" -ne 0 ]; then
abort "unable to generate sha256sum for ${1}"
fi
echo "${sha256sum_str// -/minio.${release}}" >./minio-${arch}.${release}.sha256sum
}
function main() {
echo "Testing builds for OS/Arch: ${SUPPORTED_OSARCH}"
for each_osarch in ${SUPPORTED_OSARCH}; do
_build "${each_osarch}"
done
sudo sysctl net.ipv6.conf.all.disable_ipv6=0
docker buildx build --push --no-cache \
--build-arg RELEASE="${release}" \
-t "registry.min.dev/community/minio:latest" \
-t "registry.min.dev/community/minio:${release}" \
--platform=linux/arm64,linux/amd64,linux/ppc64le \
-f Dockerfile .
docker buildx prune -f
sudo sysctl net.ipv6.conf.all.disable_ipv6=0
}
_init && main "$@"