Add scripts for automating image builds

This commit is contained in:
Andrey Beletsky 2019-01-29 19:01:05 +07:00
parent 6a483b4a5c
commit 10ef601b4b
5 changed files with 64 additions and 4 deletions

View file

@ -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

View file

@ -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

13
scripts/get_release.sh Executable file
View file

@ -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

28
scripts/publish.sh Executable file
View file

@ -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

View file

@ -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