-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
executable file
·115 lines (98 loc) · 2.56 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
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
#!/usr/bin/env bash
set -e
op=$1
IMAGE_NAME=gohomeio/server
IMAGE_VERSION=${TRAVIS_TAG}
ALPINE_DOCKER=debian:jessie-slim
docker_login(){
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
}
docker_build(){
docker build --no-cache -t ${IMAGE_NAME}:${ARCH}-${IMAGE_VERSION} \
--build-arg TRAVIS=${TRAVIS} \
--build-arg TRAVIS_JOB_ID=${TRAVIS_JOB_ID} \
--build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} \
--build-arg TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} \
--build-arg BUILD_IMAGE=${BUILD_IMAGE} \
--build-arg RUN_IMAGE=${RUN_IMAGE} \
--build-arg NODE_IMAGE=${NODE_IMAGE} \
--build-arg LINT=${LINT} \
--build-arg GOARCH=${GOARCH} \
--build-arg GOARM=${GOARM} \
--build-arg GOOS=${GOOS} \
--build-arg TRAVIS_TAG=${TRAVIS_TAG} \
--build-arg BINTRAY_API_USER=${BINTRAY_API_USER} \
--build-arg BINTRAY_API_KEY=${BINTRAY_API_KEY} \
--build-arg C_TOKEN=${C_TOKEN} .
}
docker_push(){
docker push ${IMAGE_NAME}:${ARCH}-${IMAGE_VERSION}
}
build_amd64(){
RUN_IMAGE=${ALPINE_DOCKER}
LINT=false
ARCH=amd64
GOARCH=amd64
GOARM=
GOOS=linux
docker_build
docker_push
}
build_arm32v7(){
RUN_IMAGE=arm32v7/${ALPINE_DOCKER}
LINT=false
ARCH=arm32v7
GOARCH=arm
GOARM=7
GOOS=linux
docker_build
docker_push
}
update_docker_configuration() {
sudo apt update -y
sudo apt install --only-upgrade docker-ce -y
mkdir -p ${HOME}/.docker
touch ${HOME}/.docker/config.json
echo '{
"experimental": "enabled"
}' | sudo tee ${HOME}/.docker/config.json
sudo service docker restart
}
build_manifest(){
docker pull ${IMAGE_NAME}:arm32v7-${IMAGE_VERSION}
docker pull ${IMAGE_NAME}:amd64-${IMAGE_VERSION}
docker manifest create ${IMAGE_NAME}:${IMAGE_VERSION} ${IMAGE_NAME}:arm32v7-${IMAGE_VERSION} ${IMAGE_NAME}:amd64-${IMAGE_VERSION} --amend
docker manifest annotate ${IMAGE_NAME}:${IMAGE_VERSION} ${IMAGE_NAME}:arm32v7-${IMAGE_VERSION} --os linux --arch arm
docker manifest push ${IMAGE_NAME}:${IMAGE_VERSION}
}
case ${op} in
ci*)
RUN_IMAGE=${ALPINE_DOCKER}
LINT=true
ARCH=ci
docker_build
;;
amd64*)
docker_login
build_amd64
;;
arm32v7*)
docker_login
build_arm32v7
;;
docker*)
update_docker_configuration
docker_login
build_amd64
build_arm32v7
build_manifest
;;
manifest*)
update_docker_configuration
docker_login
build_manifest
;;
*)
echo "Wrong command"
exit 1
esac