forked from dotmesh-io/dotmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild_without_bazel.sh
executable file
·131 lines (90 loc) · 3.73 KB
/
rebuild_without_bazel.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
## setup
set -ex
if [ x$1 == x--push ]
then
PUSH=YES
shift
fi
OS=Linux
if [ -n "$1" ]
then
OS=$1
fi
if [ x$CI_DOCKER_TAG == x ]
then
# Non-CI build
CI_DOCKER_TAG=latest
fi
LOWERCASE_OS=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
export GOOS="$LOWERCASE_OS"
OUTPUT_DIR="`pwd`/binaries/$OS"
mkdir -p $OUTPUT_DIR
VERSION=$(cd cmd/versioner && go run versioner.go)
HOSTNAME=${HOSTNAME:=$(hostname).local}
export STABLE_CI_DOCKER_SERVER_IMAGE=${STABLE_CI_DOCKER_SERVER_IMAGE:=$HOSTNAME:80/dotmesh/dotmesh-server:latest}
export CI_DOCKER_PROVISIONER_IMAGE=${CI_DOCKER_PROVISIONER_IMAGE:=$HOSTNAME:80/dotmesh/dotmesh-dynamic-provisioner:latest}
export CI_DOCKER_DIND_PROVISIONER_IMAGE=${CI_DOCKER_DIND_PROVISIONER_IMAGE:=$HOSTNAME:80/dotmesh/dind-dynamic-provisioner:latest}
export CI_DOCKER_OPERATOR_IMAGE=${CI_DOCKER_OPERATOR_IMAGE:=$HOSTNAME:80/dotmesh/dotmesh-operator:latest}
export GOCACHE=`pwd`/.gocache
mkdir -p $GOCACHE
rm -rf target/* || true
## client
CGO_ENABLED=0 go build -ldflags "-X main.clientVersion=${VERSION} -X main.dockerTag=$CI_DOCKER_TAG -s" -o $OUTPUT_DIR/dm ./cmd/dm
if [ -z "${SKIP_K8S}" ]
then
## flexvolume
go build -o ./target/flexvolume ./cmd/flexvolume
## operator
go build -ldflags "-linkmode external -extldflags \"-static\" -X main.DOTMESH_VERSION=${VERSION} -X main.DOTMESH_IMAGE=${STABLE_CI_DOCKER_SERVER_IMAGE} " -o ./target/operator ./cmd/operator
echo "building image: ${CI_DOCKER_OPERATOR_IMAGE}"
echo 'FROM scratch' > target/Dockerfile
echo 'COPY ./operator /' >> target/Dockerfile
echo 'CMD ["/operator"]' >> target/Dockerfile
docker build -f target/Dockerfile -t "${CI_DOCKER_OPERATOR_IMAGE}" target
if [ -n "${PUSH}" ]; then
echo "pushing image"
docker push ${CI_DOCKER_OPERATOR_IMAGE}
fi
## provisioner
go build -pkgdir /go/pkg -ldflags '-linkmode external -extldflags "-static"' -o ./target/dm-provisioner ./cmd/dynamic-provisioner
echo "building image: ${CI_DOCKER_PROVISIONER_IMAGE}"
echo 'FROM scratch' > target/Dockerfile
echo 'COPY ./dm-provisioner /' >> target/Dockerfile
echo 'CMD ["/dm-provisioner"]' >> target/Dockerfile
docker build -f target/Dockerfile -t "${CI_DOCKER_PROVISIONER_IMAGE}" target
if [ -n "${PUSH}" ]; then
echo "pushing image"
docker push ${CI_DOCKER_PROVISIONER_IMAGE}
fi
## yaml
(cd kubernetes; ./rebuild.sh)
## dind-flexvolume
go build -o ./target/dind-flexvolume ./cmd/dotmesh-server/pkg/dind-flexvolume
## dind-provisioner
go build -ldflags '-linkmode external -extldflags "-static"' -o ./target/dind-provisioner ./cmd/dotmesh-server/pkg/dind-dynamic-provisioning
echo "building image: ${CI_DOCKER_DIND_PROVISIONER_IMAGE}"
echo 'FROM scratch' > target/Dockerfile
echo 'COPY ./dind-provisioner /' >> target/Dockerfile
echo 'CMD ["/dind-provisioner"]' >> target/Dockerfile
docker build -f target/Dockerfile -t "${CI_DOCKER_DIND_PROVISIONER_IMAGE}" target
if [ -n "${PUSH}" ]; then
echo "pushing image"
docker push ${CI_DOCKER_DIND_PROVISIONER_IMAGE}
fi
fi
if [ -z "${SKIP_SERVER}" ]
then
## server
go build -ldflags "-X main.serverVersion=${VERSION}" -o ./target/dotmesh-server ./cmd/dotmesh-server
cp ./cmd/dotmesh-server/require_zfs.sh ./target
echo "building image: ${STABLE_CI_DOCKER_SERVER_IMAGE}"
cp cmd/dotmesh-server/Dockerfile target/Dockerfile
echo 'COPY ./flexvolume /usr/local/bin/' >> target/Dockerfile
echo 'COPY ./dotmesh-server /usr/local/bin/' >> target/Dockerfile
docker build -f target/Dockerfile -t "${STABLE_CI_DOCKER_SERVER_IMAGE}" target
fi
if [ -n "${PUSH}" ]; then
echo "pushing image"
docker push ${STABLE_CI_DOCKER_SERVER_IMAGE}
fi