Newer
Older
#!/bin/bash
trap 'exit 1' ERR
if ! which docker > /dev/null 2>&1
then
echo 'Can not find Docker. Make sure it is installed.' >&2
if [ "$1" = "test" ]
then
tag="test"
class="test"
else
tag="latest"
class="prod"
name="bfanodo"
vd="${HOME}/dockers/volumes/${name},home,bfa,bfa,${netdir},node,geth"
mounts="-v ${vd}:/home/bfa/bfa/${netdir}/node/geth"
if [ "$UID" = "0" ]
then
chown -R 30303:30303 ${vd}
else
# This is a bit slower, but works
docker run --rm $mounts -u root alpine chown -R 30303:30303 /home/bfa/bfa/${netdir}
# Run this just a single time.
# Docker itself makes sure it autostarts if it crashes or the server reboots.
docker run \
--detach \
--restart=unless-stopped \
--memory 4g \
$mounts \
-p 8545:8545 \
-p 8546:8546 \
-p 30303:30303 \
--name ${name} \
rlegene/bfanode:${tag}