From 9b977ac87861a66c543d27f523859fd6c0db1d2d Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Mon, 5 Oct 2020 17:03:34 +0200 Subject: [PATCH] combine docker operations into docker.sh --- build.sh | 21 ------------ docker.sh | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ manifest.sh | 14 -------- push.sh | 7 ---- 4 files changed, 97 insertions(+), 42 deletions(-) delete mode 100755 build.sh create mode 100755 docker.sh delete mode 100755 manifest.sh delete mode 100755 push.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index 14bc247..0000000 --- a/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -euxo pipefail -. docker/env - -docker build --pull -t openwebrx-base:$ARCHTAG -f docker/Dockerfiles/Dockerfile-base . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-rtlsdr:$ARCHTAG -f docker/Dockerfiles/Dockerfile-rtlsdr . -docker build --build-arg ARCHTAG=$ARCHTAG -t openwebrx-soapysdr-base:$ARCHTAG -f docker/Dockerfiles/Dockerfile-soapysdr . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-sdrplay:$ARCHTAG -f docker/Dockerfiles/Dockerfile-sdrplay . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-hackrf:$ARCHTAG -f docker/Dockerfiles/Dockerfile-hackrf . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-airspy:$ARCHTAG -f docker/Dockerfiles/Dockerfile-airspy . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-rtlsdr-soapy:$ARCHTAG -f docker/Dockerfiles/Dockerfile-rtlsdr-soapy . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-plutosdr:$ARCHTAG -f docker/Dockerfiles/Dockerfile-plutosdr . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-limesdr:$ARCHTAG -f docker/Dockerfiles/Dockerfile-limesdr . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-soapyremote:$ARCHTAG -f docker/Dockerfiles/Dockerfile-soapyremote . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-perseus:$ARCHTAG -f docker/Dockerfiles/Dockerfile-perseus . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-fcdpp:$ARCHTAG -f docker/Dockerfiles/Dockerfile-fcdpp . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-radioberry:$ARCHTAG -f docker/Dockerfiles/Dockerfile-radioberry . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-uhd:$ARCHTAG -f docker/Dockerfiles/Dockerfile-uhd . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-redpitaya:$ARCHTAG -f docker/Dockerfiles/Dockerfile-redpitaya . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-rtltcp:$ARCHTAG -f docker/Dockerfiles/Dockerfile-rtltcp . -docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-full:$ARCHTAG -t jketterl/openwebrx:$ARCHTAG -f docker/Dockerfiles/Dockerfile-full . diff --git a/docker.sh b/docker.sh new file mode 100755 index 0000000..eda1ad0 --- /dev/null +++ b/docker.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +set -euo pipefail + +ARCH=$(uname -m) +IMAGES="openwebrx-rtlsdr openwebrx-sdrplay openwebrx-hackrf openwebrx-airspy openwebrx-rtlsdr-soapy openwebrx-plutosdr openwebrx-limesdr openwebrx-soapyremote openwebrx-perseus openwebrx-fcdpp openwebrx-radioberry openwebrx-uhd openwebrx-redpitaya openwebrx-rtltcp 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 \ No newline at end of file diff --git a/manifest.sh b/manifest.sh deleted file mode 100755 index 333a00d..0000000 --- a/manifest.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail -. docker/env - -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 diff --git a/push.sh b/push.sh deleted file mode 100755 index bca5cca..0000000 --- a/push.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -euxo pipefail -. docker/env - -for image in ${IMAGES}; do - docker push jketterl/$image:$ARCHTAG -done \ No newline at end of file