diff --git a/Makefile b/Makefile index 7de2c4c..33d0194 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,11 @@ get_release: .PHONY: build build: - docker build -t sayplastic/lbrynet . + docker build -t sayplastic/lbrynet:$(VERSION) . .PHONY: publish publish: - docker push sayplastic/lbrynet + scripts/publish.sh clean: rm -rf lbrynet lbrynet-linux.zip diff --git a/README.md b/README.md index 4ca98dd..45b18c3 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ## Image usage +Put this in your docker-compose file: + ``` version: '3.2' @@ -21,9 +23,22 @@ services: target: /storage ``` -## Building +## Updating, building and publishing + +#### Using the provided Makefile + +This is the preferred method because it also checks if our newly built container can actually run. ``` +make get_release +VERSION=0.30.5 make build +VERSION=0.30.5 make publish +``` + +#### Manually + +``` +make get_release docker build -t sayplastic/lbrynet:0.30rc6 . docker tag sayplastic/lbrynet:0.30rc6 sayplastic/lbrynet:latest docker push sayplastic/lbrynet diff --git a/scripts/get_release.sh b/scripts/get_release.sh new file mode 100755 index 0000000..d9ef78b --- /dev/null +++ b/scripts/get_release.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +URL=$( + curl -si https://api.github.com/repos/lbryio/lbry/releases/latest| + grep browser_download_url| + sed -E 's/.*"([^"]+)".*/\1/'| + grep linux +) + +echo "Getting the latest release from $URL..." +curl -sOL $URL +unzip lbrynet-linux.zip +rm lbrynet-linux.zip diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..fe672de --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set +x +set -e + +WAIT=5 +BASE_IMAGE_NAME=sayplastic/lbrynet + +if [ -z ${VERSION+x} ]; then + echo "Please provide sayplastic/lbrynet version as \$VERSION variable." + exit 1 +fi + +echo "Launching daemon container for ${BASE_IMAGE_NAME}:${VERSION} and giving it ${WAIT} secs..." + +ID=$(docker run --detach --rm $BASE_IMAGE_NAME:$VERSION) +sleep $WAIT + +if [[ -z "${ID+x}" || ! $(docker top "$ID") ]]; then + echo "Container crashed unexpectedly, aborting" + exit 1 +fi + +echo "Container launched successfully, stopping it" +docker kill $ID + +echo "Pushing to Docker Hub..." +docker push sayplastic/lbrynet:$VERSION diff --git a/start.sh b/start.sh index f2a9dac..2271bc7 100644 --- a/start.sh +++ b/start.sh @@ -7,4 +7,8 @@ if [ ! -d "$LBRY_DOWNLOAD_DIRECTORY" ]; then mkdir $LBRY_DOWNLOAD_DIRECTORY fi -./lbrynet start +if [ -z ${LBRY_DOCKER_CONFIG+x} ]; then + ./lbrynet start --config=/daemon/daemon_settings.yml +else + ./lbrynet start --config=$LBRY_DOCKER_CONFIG +fi