diff --git a/podman-peerjs/10_install.sh b/podman-peerjs/10_install.sh index ce93bfe..71a7ad0 100755 --- a/podman-peerjs/10_install.sh +++ b/podman-peerjs/10_install.sh @@ -9,6 +9,8 @@ ensure_not_root ensure_container_not_exists ${container_name} +source ${ABSDIR}/zz_build-images.sh + podman run --name ${container_name} --user nobody -p ${listen_if}:${listen_port}:9000 -d ${upstream_images}:${version} && ( podman logs -f peerjs-server 2>&1 & ) | grep -q 'Started PeerServer' && podman stop ${container_name} && diff --git a/podman-peerjs/50_update.sh b/podman-peerjs/50_update.sh index 4b3a71c..4bcd19d 100755 --- a/podman-peerjs/50_update.sh +++ b/podman-peerjs/50_update.sh @@ -19,8 +19,8 @@ fi echo Rebuilding container ${container_name} with image ${upstream_imageversion} -# pull first for minimal downtime -podman pull ${upstream_imageversion} +# build first for minimal downtime +source ${ABSDIR}/zz_build-images.sh ${ABSDIR}/40_stop.sh ${ABSDIR}/80_destroy.sh diff --git a/podman-peerjs/vars.sh b/podman-peerjs/vars.sh index ce23fb1..6675c8a 100644 --- a/podman-peerjs/vars.sh +++ b/podman-peerjs/vars.sh @@ -4,5 +4,5 @@ container_name='peerjs-server' service_name="container-${container_name}.service" listen_if="${GARBAYE_PEERJS_ENV_LISTENIF:-127.0.0.1}" listen_port="${GARBAYE_PEERJS_ENV_LISTENPORT:-8081}" -upstream_images='docker.io/peerjs/peerjs-server' +upstream_images='localhost/peerjs/peerjs-server' version='0.6.1' diff --git a/podman-peerjs/zz_build-images.sh b/podman-peerjs/zz_build-images.sh new file mode 100755 index 0000000..bc5ae87 --- /dev/null +++ b/podman-peerjs/zz_build-images.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +buildfolder=/tmp/peerjs-server-$$ + +if ! podman image exists ${upstream_images}:${version}; then + mkdir -p ${buildfolder} && + curl -sSfL -- "https://github.com/peers/peerjs-server/archive/refs/tags/v${version}.tar.gz" | \tar xz --strip-components 1 -C ${buildfolder}/ && + sed_in_place "^FROM node:alpine" "FROM docker.io/library/node:alpine" ${buildfolder}/Dockerfile + podman build -t ${upstream_images}:${version} ${buildfolder}/ + podman rmi docker.io/library/node:alpine + rm -rf ${buildfolder} +fi