forked from luarvique/openwebrx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·169 lines (146 loc) · 5.4 KB
/
docker.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env bash
set -euo pipefail
export DH_PROJECT="openwebrxplus"
export DH_USERNAME="slechev"
export NIGHTLY_BUILD=$(date +%F)
ARCH=$(uname -m)
#IMAGES="${DH_PROJECT}-rtlsdr ${DH_PROJECT}-sdrplay ${DH_PROJECT}-hackrf ${DH_PROJECT}-airspy ${DH_PROJECT}-rtlsdr-soapy ${DH_PROJECT}-plutosdr ${DH_PROJECT}-limesdr ${DH_PROJECT}-soapyremote ${DH_PROJECT}-perseus ${DH_PROJECT}-fcdpp ${DH_PROJECT}-radioberry ${DH_PROJECT}-uhd ${DH_PROJECT}-rtltcp ${DH_PROJECT}-runds ${DH_PROJECT}-hpsdr ${DH_PROJECT}-bladerf ${DH_PROJECT}-full ${DH_PROJECT}"
IMAGES="${DH_PROJECT}-full ${DH_PROJECT}"
ALL_ARCHS="x86_64 armv7l aarch64"
TAG=${TAG:-"latest"}
ARCHTAG="${TAG}-${ARCH}"
usage () {
echo "Usage: ${0} [command]"
echo "Available commands:"
echo " help Show this usage information"
echo " buildn Build full docker nightly image"
echo " buildr Build full docker release image"
echo " pushn Push built docker nightly image to the docker hub"
echo " pushr Push built docker release image to the docker hub"
echo " manifest Compile the docker hub manifest (combines arm and x86 tags into one)"
echo " tag Tag a release"
}
buildn () {
# build the base images
echo -ne "\n\nBuilding the base image.\n\n"
time docker build --pull -t ${DH_PROJECT}-base:${ARCHTAG} -f docker/Dockerfiles/Dockerfile-base .
# AF: uncomment next 2 lines if you're building all images
#echo -ne "\n\nBuilding soapysdr image.\n\n"
#docker build --build-arg ARCHTAG=${ARCHTAG} --build-arg PROJECT=${DH_PROJECT} -t ${DH_PROJECT}-soapysdr-base:${ARCHTAG} -f docker/Dockerfiles/Dockerfile-soapysdr .
GIT_HASH=$(git rev-parse --short master)
for image in ${IMAGES}; do
i=$(echo ${image} | rev | cut -d- -f1 | rev)
# "openwebrx" is a special image that gets tag-aliased later on
if [[ ! -z "${i}" && "${i}" != "${DH_PROJECT}" ]] ; then
echo -ne "\n\nBuilding ${i} image.\n\n"
docker build --build-arg GIT_HASH=${GIT_HASH} --build-arg ARCHTAG=$ARCHTAG --build-arg PROJECT=${DH_PROJECT} -t ${DH_USERNAME}/${image}:${ARCHTAG} -f docker/Dockerfiles/Dockerfile-${i} .
fi
done
# tag openwebrx alias image
docker tag ${DH_USERNAME}/${DH_PROJECT}-full:${ARCHTAG} ${DH_USERNAME}/${DH_PROJECT}:${ARCHTAG}
docker tag ${DH_USERNAME}/${DH_PROJECT}-full:${ARCHTAG} ${DH_USERNAME}/${DH_PROJECT}-full
docker tag ${DH_USERNAME}/${DH_PROJECT}-full ${DH_USERNAME}/${DH_PROJECT}-nightly:${NIGHTLY_BUILD}
docker tag ${DH_USERNAME}/${DH_PROJECT}-full ${DH_USERNAME}/${DH_PROJECT}-nightly
}
pushn () {
#for image in ${IMAGES}; do
# docker push ${DH_USERNAME}/${image}:${ARCHTAG}
#done
docker push ${DH_USERNAME}/${DH_PROJECT}-nightly:${NIGHTLY_BUILD}
docker push ${DH_USERNAME}/${DH_PROJECT}-nightly
}
buildr () {
if [[ -z ${1:-} ]] ; then
echo "Usage: ${0} buildr [version]"
echo "NOTE: The version will be used for tagging."
echo "The image will be build from the current packages in the apt-repo."
echo; echo;
return
fi
echo -ne "\n\nBuilding release image: $1.\n\n"
docker build --pull --build-arg VERSION=$1 -t ${DH_USERNAME}/${DH_PROJECT}:${1} -f docker/deb_based/Dockerfile .
docker tag ${DH_USERNAME}/${DH_PROJECT}:${1} ${DH_USERNAME}/${DH_PROJECT}
}
pushr () {
if [[ -z ${1:-} ]] ; then
echo "Usage: ${0} pushr [version]"
echo; echo;
return
fi
docker push ${DH_USERNAME}/${DH_PROJECT}:${1}
docker push ${DH_USERNAME}/${DH_PROJECT}
}
manifest () {
for image in ${IMAGES}; do
# there's no docker manifest rm command, and the create --amend does not work, so we have to clean up manually
rm -rf "${HOME}/.docker/manifests/docker.io_${DH_USERNAME}_${image}-${TAG}"
IMAGE_LIST=""
for a in ${ALL_ARCHS}; do
IMAGE_LIST="${IMAGE_LIST} ${DH_USERNAME}/${image}:${TAG}-${a}"
done
docker manifest create ${DH_USERNAME}/${image}:${TAG} ${IMAGE_LIST}
docker manifest push --purge ${DH_USERNAME}/${image}:${TAG}
done
}
tag () {
if [[ -x ${1:-} || -z ${2:-} ]] ; then
echo "Usage: ${0} tag [SRC_TAG] [TARGET_TAG]"
return
fi
local SRC_TAG=${1}
local TARGET_TAG=${2}
for image in ${IMAGES}; do
# there's no docker manifest rm command, and the create --amend does not work, so we have to clean up manually
rm -rf "${HOME}/.docker/manifests/docker.io_${DH_USERNAME}_${image}-${TARGET_TAG}"
IMAGE_LIST=""
for a in ${ALL_ARCHS}; do
docker pull ${DH_USERNAME}/${image}:${SRC_TAG}-${a}
docker tag ${DH_USERNAME}/${image}:${SRC_TAG}-${a} ${DH_USERNAME}/${image}:${TARGET_TAG}-${a}
docker push ${DH_USERNAME}/${image}:${TARGET_TAG}-${a}
IMAGE_LIST="${IMAGE_LIST} ${DH_USERNAME}/${image}:${TARGET_TAG}-${a}"
done
docker manifest create ${DH_USERNAME}/${image}:${TARGET_TAG} ${IMAGE_LIST}
docker manifest push --purge ${DH_USERNAME}/${image}:${TARGET_TAG}
docker pull ${DH_USERNAME}/${image}:${TARGET_TAG}
done
}
dev () {
if [[ -z ${1:-} ]] ; then
echo "Usage: ${0} dev [ImageId]"; echo; echo;
docker image ls
return
fi
docker run --rm -it --entrypoint /bin/bash -p 8073:8073 --device /dev/bus/usb ${1}
}
run () {
docker run --rm -it -p 8073:8073 --device /dev/bus/usb openwebrxplus-full:latest-x86_64
}
case ${1:-} in
buildn)
buildn
;;
pushn)
pushn
;;
buildr)
buildr ${@:2}
;;
pushr)
pushr ${@:2}
;;
manifest)
manifest
;;
tag)
tag ${@:2}
;;
dev)
dev ${@:2}
;;
run)
run
;;
*)
usage
;;
esac