forked from ha7ilm/openwebrx
-
Notifications
You must be signed in to change notification settings - Fork 146
/
docker.sh
executable file
·97 lines (86 loc) · 3.05 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
#!/usr/bin/env bash
set -euo pipefail
ARCH=$(uname -m)
IMAGES="openwebrx-rtlsdr openwebrx-sdrplay openwebrx-hackrf openwebrx-airspy openwebrx-afedri openwebrx-rtlsdr-soapy openwebrx-plutosdr openwebrx-limesdr openwebrx-soapyremote openwebrx-perseus openwebrx-fcdpp openwebrx-radioberry openwebrx-uhd openwebrx-rtltcp openwebrx-runds openwebrx-hpsdr openwebrx-bladerf openwebrx-full openwebrx"
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 " build Build all docker images"
echo " push Push built docker images to the docker hub"
echo " manifest Compile the docker hub manifest (combines arm and x86 tags into one)"
echo " tag Tag a release"
}
build () {
# build the base images
docker build --pull -t openwebrx-base:${ARCHTAG} -f docker/Dockerfiles/Dockerfile-base .
docker build --build-arg ARCHTAG=${ARCHTAG} -t openwebrx-soapysdr-base:${ARCHTAG} -f docker/Dockerfiles/Dockerfile-soapysdr .
for image in ${IMAGES}; do
i=${image:10}
# "openwebrx" is a special image that gets tag-aliased later on
if [[ ! -z "${i}" ]] ; then
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/${image}:${ARCHTAG} -f docker/Dockerfiles/Dockerfile-${i} .
fi
done
# tag openwebrx alias image
docker tag jketterl/openwebrx-full:${ARCHTAG} jketterl/openwebrx:${ARCHTAG}
}
push () {
for image in ${IMAGES}; do
docker push jketterl/${image}:${ARCHTAG}
done
}
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_jketterl_${image}-${TAG}"
IMAGE_LIST=""
for a in ${ALL_ARCHS}; do
IMAGE_LIST="${IMAGE_LIST} jketterl/${image}:${TAG}-${a}"
done
docker manifest create jketterl/${image}:${TAG} ${IMAGE_LIST}
docker manifest push --purge jketterl/${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_jketterl_${image}-${TARGET_TAG}"
IMAGE_LIST=""
for a in ${ALL_ARCHS}; do
docker pull jketterl/${image}:${SRC_TAG}-${a}
docker tag jketterl/${image}:${SRC_TAG}-${a} jketterl/${image}:${TARGET_TAG}-${a}
docker push jketterl/${image}:${TARGET_TAG}-${a}
IMAGE_LIST="${IMAGE_LIST} jketterl/${image}:${TARGET_TAG}-${a}"
done
docker manifest create jketterl/${image}:${TARGET_TAG} ${IMAGE_LIST}
docker manifest push --purge jketterl/${image}:${TARGET_TAG}
docker pull jketterl/${image}:${TARGET_TAG}
done
}
case ${1:-} in
build)
build
;;
push)
push
;;
manifest)
manifest
;;
tag)
tag ${@:2}
;;
*)
usage
;;
esac