-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·61 lines (47 loc) · 1.29 KB
/
build.sh
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
#!/bin/bash
function usage() {
cat <<EOF
Usage: $0
[--version]
required arguments:
--version Specify the version for image
EOF
exit 1
}
function handle_parameters() {
version=""
until [ -z $1 ]; do
case $1 in
--version )
version="$2"
shift
;;
esac
shift
done
if [ "$version" == "" ]; then
echo "version is missing"
usage
fi
}
# ========== Start main script ============
handle_parameters $*
image="akeyless/akeyless-csi-provider"
docker_repo="docker.io"
arc='amd64'
os='linux'
versionVar="akeyless.io/akeyless-csi-provider/internal/version.Version=$version"
buildDateVar="akeyless.io/akeyless-csi-provider/go/src/internal/version.BuildDate=$(date -u +%Y%m%d.%H%M%S)"
goVer="github.com/akeylesslabs/akeyless-csi-provider/internal/version.GoVersion=$(go version)"
GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build \
-ldflags "-w -s -X $versionVar -X $buildDateVar" \
-o dist/ \
.
echo "Building $image:latest docker image"
docker build --load --build-arg PRODUCT_VERSION="$version" --no-cache -t $image:latest .
docker tag "$image":latest "$docker_repo/$image":"$version"
docker login
echo "Docker login Succeeded"
#Push image
docker push "$docker_repo/$image"
rm -rf dist/