docker_deployment_notes/shinobi
2021-01-09 14:22:41 -08:00
..
ShinobiHub - Article How to use Additional Input Feeds_files Shinobi. Added Reolink RLC-410-5MP specific Notes 2020-10-22 17:42:08 -07:00
ShinobiHub - Article How to use FTP-based Event Triggering in Shinobi_files Shinobi. Added Reolink RLC-410-5MP specific Notes 2020-10-22 17:42:08 -07:00
README.md Edit Formatting To Be more consistent 2021-01-09 14:22:41 -08:00
RLC-410-5MP_647_20031401.zip Shinobi. Added Reolink RLC-410-5MP specific Notes 2020-10-22 17:42:08 -07:00
ShinobiHub - Article How to use Additional Input Feeds.htm Shinobi. Added Reolink RLC-410-5MP specific Notes 2020-10-22 17:42:08 -07:00
ShinobiHub - Article How to use FTP-based Event Triggering in Shinobi.htm Shinobi. Added Reolink RLC-410-5MP specific Notes 2020-10-22 17:42:08 -07:00

It is recommended to do a native install or on a VM for shinobiCCTV using "The Shinobi Way" script.

But if you want to give docker a shot these are my notes for the installation.

The docker-compose.yml was generated by the follow script below. If you're going to docker you should install shinobi via the ShinobiInstall.sh below. The docker-compose.yml shown below is just an example and may not work for you.

ShinobiInstall.sh

#!/bin/bash
if ! [ -x "$(command -v docker)" ]; then
    echo "You are missing Docker"
    echo "docker not found!"
    echo "Get it here : https://docs.docker.com/engine/install/"
    exit 1
else
    docker -v
fi
if ! [ -x "$(command -v docker-compose)" ]; then
    echo "You are missing Docker Compose"
    echo "docker-compose not found!"
    echo "Get it here : https://docs.docker.com/compose/install/"
    exit 1
else
    docker-compose -v
fi

PLUGIN_LIST=''
PLUGIN_YMLS=();

SSL_TOGGLE="$(echo "$1" | awk '{print tolower($0)}')"
if [ "$SSL_TOGGLE" = "true" ]; then
    SSL_TOGGLE='true'
else
    SSL_TOGGLE='false'
fi

echo "Shinobi - Do you want to Install Object Detection? (TensorFlow.js)"
echo "(y)es or (N)o"
read -r TENSORFLOW_PLUGIN_DOCKER_ADDON_AGREE
TENSORFLOW_PLUGIN_DOCKER_ADDON_AGREE="$(echo "$TENSORFLOW_PLUGIN_DOCKER_ADDON_AGREE" | awk '{print tolower($0)}')"
if [ "$TENSORFLOW_PLUGIN_DOCKER_ADDON_AGREE" = "y" ]; then
    TENSORFLOW_PLUGIN_KEY=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}')
    PLUGIN_YMLS+=('"Tensorflow":"'$TENSORFLOW_PLUGIN_KEY'"')
    PLUGIN_LIST+=$(cat <<-END

    shinobiplugintensorflow:
        image: shinobisystems/shinobi-tensorflow:latest
        container_name: shinobi-tensorflow
        environment:
          - PLUGIN_KEY=$TENSORFLOW_PLUGIN_KEY
          - PLUGIN_HOST=Shinobi
        volumes:
          - $HOME/Shinobi/docker-plugins/tensorflow:/config
        restart: unless-stopped
END
    )
fi

# Join Plugin Keys
PLUGIN_YMLS=$(printf ",%s" "${PLUGIN_YMLS[@]}")
PLUGIN_YMLS=${PLUGIN_YMLS:1}
PLUGIN_YMLS="{$PLUGIN_YMLS}"
cat > docker-compose.yml <<- EOM
version: "3"
services:
    shinobi:
        image: shinobisystems/shinobi:dev
        container_name: Shinobi
        environment:
           - PLUGIN_KEYS=$PLUGIN_YMLS
#          - SSL_ENABLED=$SSL_TOGGLE
        volumes:
           - ./config:/config
           - ./customAutoLoad:/home/Shinobi/libs/customAutoLoad
           - ./database:/var/lib/mysql
           - ./videos:/home/Shinobi/videos
           - ./plugins:/home/Shinobi/plugins
           - /dev/shm/Shinobi/streams:/dev/shm/streams
           - /etc/localtime:/etc/localtime:ro
#        ports:
#           - 8080:8080
        restart: unless-stopped

$PLUGIN_LIST

networks:
  default:
    external:
      name: caddy_net
EOM
cat docker-compose.yml
docker-compose up -d
# rm docker-compose.yml

Minimum File Structure

/home/
└── ~/
    └── docker/
        └── shinobi/
            ├── docker-compose.yml

Add to Caddyfile (from ~/docker/caddy)

Remember to docker exec -w /etc/caddy caddy caddy reload after editing your Caddyfile.

shinobi.yourdomain.com {
    reverse_proxy shinobi:8080
}

docker-compose.yml

Notes: No tensorflow option. Use script above if you want that feature.

version: "3"
services:
    shinobi:
        image: shinobisystems/shinobi:dev
        container_name: shinobi
        volumes:
           - ./config:/config
           - ./customAutoLoad:/home/Shinobi/libs/customAutoLoad
           - ./database:/var/lib/mysql
           - ./videos:/home/Shinobi/videos
           - ./plugins:/home/Shinobi/plugins
           - /dev/shm/Shinobi/streams:/dev/shm/streams
           - /etc/localtime:/etc/localtime:ro
        restart: unless-stopped
        ports:
           - "521:521"

networks:
  default:
    external:
      name: caddy_net

Why port 521 Open?

Why did I do ports 521:521? Well I wanted to enable FTP inside the docker with port 521 open (see below). You don't have to choose 521 this is arbitrary make sure your conf.json matches.. I will assume no port forward is needed on the router because Cameras and Shinobi NVR is on the sane LAN.

shinobi/config/conf.json

Here I added the following lines to conf.json to enable FTP.

   "dropInEventServer": true,
   "ftpServer": true,
   "ftpServerPort": 521,
   "dropInEventsDir": "/dev/shm/streams/dropInEvents",
   "thisIsDocker": true,

Camera specific notes

You may need to port forward RTSP or RTMP ports for your cameras.

RTMP Main Stream (High Bit Rate 1024Kbps ~ 8192Kbps)

rtmp://[USERNAME]:[PASSWORD]@CAMERAIPADDRESS:PORT/bcs/channel0_main.bcs?token=sdasdasc&channel=0&stream=0&user=[USERNAME]&password=[PASSWORD] Token value entered doesn't matter just need to put something. Only lines before /bcs and after user= need to be changed.

RTMP Sub Stream (Lower Bit Rate 64Kbps ~ 512Kbps)

rtmp://[USERNAME]:[PASSWORD]@CAMERAIPADDRESS:PORT/bcs/channel0_sub.bcs?token=sdasdasc&channel=0&stream=0&user=[USERNAME]&password=[PASSWORD]

You can use the main stream for recording while using the sub stream for streaming both at the same time in shinobi. This still hasn't worked for me and I've been trying to figure this one out ever since. If you know a solution let me know. I can't get split LQ stream and HQ recording right, for the life of me. Reference: https://hub.shinobi.video/articles/view/w8azEAI2peYeNul

Gotcha #1 RMTP FTP Motion Detection

You can also designate motion detection to the cameras instead of shinobi to reduce load. Reference: https://hub.shinobi.video/articles/view/LyCI3yQsUTouSAJ

ONE BIG GOTCHA... It took me a long time to figure out, but in order for FTP to work with Reolink Cameras. In your Reolink Client when setting up FTP there is an an option called Transport Mode. Make sure you select PORT instead of AUTO otherwise FTP won't work.

Gotcha #2 Multiple input feeds. Low Q Stream + High Q Recording

This is a work around that allows for multiple input feeds.

For context. Input 0 = LQ Sub Stream Input 1 = HQ Main Stream.

Under Input: Primary Input to 0:v Under Stream: Input Feed Map to 0:v Under Traditional Recording: Input Feed Map to 1:v ... Then Press + sign, add another Input Feed Map to 1:a

The order of inputs matters. The reason is because Primary Input seems to only work when it is set to 0:v, meaning input 0 will have no audio. This is perfect because we want to stream in LQ without audio. For recording we want HQ video and audio so input 1:v and 1:a so the Main Stream should be set as input 1.