basic docker installation from main repo
parent
9b87f5255b
commit
d61aaa8c96
|
|
@ -0,0 +1,57 @@
|
|||
# Install Shinobi with Docker
|
||||
|
||||
1. Download Repo
|
||||
|
||||
```
|
||||
git clone https://gitlab.com/Shinobi-Systems/Shinobi.git ShinobiSource
|
||||
```
|
||||
|
||||
2. Enter Repo and Build Image.
|
||||
|
||||
```
|
||||
cd ShinobiSource
|
||||
docker build --tag shinobi-image:1.0 .
|
||||
```
|
||||
|
||||
3. This command only works on Linux because of the temporary directory used. This location must exist in RAM. `-v "/dev/shm/shinobiStreams":'/dev/shm/streams':'rw'`.
|
||||
|
||||
```
|
||||
docker run -d --name='Shinobi' -p '8080:8080/tcp' -v "/dev/shm/shinobiStreams":'/dev/shm/streams':'rw' \
|
||||
-v "$HOME/shinobiConfig":'/config':'rw' \
|
||||
-v "$HOME/shinobiCustomAutoLoad":'/home/Shinobi/libs/customAutoLoad':'rw' \
|
||||
-v "$HOME/shinobiDatabase":'/var/lib/mysql':'rw' \
|
||||
-v "$HOME/shinobiVideos":'/home/Shinobi/videos':'rw' \
|
||||
-v "$HOME/shinobiPlugins":'/home/Shinobi/plugins':'rw' \
|
||||
shinobi-image:1.0
|
||||
```
|
||||
|
||||
### Volumes
|
||||
|
||||
| Volumes | Description |
|
||||
|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| /dev/shm/shinobiStreams | **IMPORTANT!** This must be mapped to somewhere in the host's RAM. When running this image on Windows you will need to select a different location. |
|
||||
| $HOME/shinobiConfig | Put `conf.json` or `super.json` files in here to override default values. |
|
||||
| $HOME/shinobiCustomAutoLoad | Maps to the `libs/customAutoLoad` folder for loading your own modules into Shinobi. |
|
||||
| $HOME/shinobiDatabase | A map to `/var/lib/mysql` in the container. This is the database's core files. |
|
||||
| $HOME/shinobiVideos | A map to `/home/Shinobi/videos`. The storage location of your recorded videos. |
|
||||
| $HOME/shinobiPlugins | A map to `/home/Shinobi/plugins`. Mapped so that plugins can easily be modified or swapped. |
|
||||
|
||||
### Tips
|
||||
|
||||
Modifying `conf.json` or Superuser credentials.
|
||||
> Please read **Volumes** table in this README. conf.json is for general configuration. super.json is for Superuser credential management.
|
||||
|
||||
Get Docker Containers
|
||||
```
|
||||
docker ps -a
|
||||
```
|
||||
|
||||
Get Images
|
||||
```
|
||||
docker images
|
||||
```
|
||||
|
||||
Container Logs
|
||||
```
|
||||
docker logs CONTAINER_ID
|
||||
```
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "MariaDB Directory ..."
|
||||
ls /var/lib/mysql
|
||||
|
||||
if [ ! -f /var/lib/mysql/ibdata1 ]; then
|
||||
echo "Installing MariaDB ..."
|
||||
mysql_install_db --user=mysql --datadir=/var/lib/mysql --silent
|
||||
fi
|
||||
echo "Starting MariaDB ..."
|
||||
/usr/bin/mysqld_safe --user=mysql &
|
||||
sleep 5s
|
||||
|
||||
chown -R mysql /var/lib/mysql
|
||||
|
||||
if [ ! -f /var/lib/mysql/ibdata1 ]; then
|
||||
mysql -u root --password="" <<-EOSQL
|
||||
SET @@SESSION.SQL_LOG_BIN=0;
|
||||
USE mysql;
|
||||
DELETE FROM mysql.user ;
|
||||
DROP USER IF EXISTS 'root'@'%','root'@'localhost','${DB_USER}'@'localhost','${DB_USER}'@'%';
|
||||
CREATE USER 'root'@'%' IDENTIFIED BY '${DB_PASS}' ;
|
||||
CREATE USER 'root'@'localhost' IDENTIFIED BY '${DB_PASS}' ;
|
||||
CREATE USER '${DB_USER}'@'%' IDENTIFIED BY '${DB_PASS}' ;
|
||||
CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}' ;
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION ;
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION ;
|
||||
GRANT ALL PRIVILEGES ON *.* TO '${DB_USER}'@'%' WITH GRANT OPTION ;
|
||||
GRANT ALL PRIVILEGES ON *.* TO '${DB_USER}'@'localhost' WITH GRANT OPTION ;
|
||||
DROP DATABASE IF EXISTS test ;
|
||||
FLUSH PRIVILEGES ;
|
||||
EOSQL
|
||||
fi
|
||||
|
||||
# Create MySQL database if it does not exists
|
||||
if [ -n "${DB_HOST}" ]; then
|
||||
echo "Wait for MySQL server" ...
|
||||
while ! mysqladmin ping -h"$DB_HOST"; do
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
echo "Setting up MySQL database if it does not exists ..."
|
||||
|
||||
echo "Create database schema if it does not exists ..."
|
||||
mysql -e "source /home/Shinobi/sql/framework.sql" || true
|
||||
|
||||
echo "Create database user if it does not exists ..."
|
||||
mysql -e "source /home/Shinobi/sql/user.sql" || true
|
||||
|
||||
|
||||
cd /home/Shinobi
|
||||
mkdir -p libs/customAutoLoad
|
||||
if [ -e "/config/conf.json" ]; then
|
||||
cp /config/conf.json conf.json
|
||||
#Generate a random Cron key for the config file
|
||||
cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}')
|
||||
#Insert key into conf.json
|
||||
sudo sed -i -e 's/change_this_to_something_very_random__just_anything_other_than_this/'"$cronKey"'/g' conf.json
|
||||
fi
|
||||
#create super.json
|
||||
if [ -e "/config/super.json" ]; then
|
||||
echo "============="
|
||||
echo "Default Superuser : admin@shinobi.video"
|
||||
echo "Default Password : admin"
|
||||
echo "* You can edit these settings in \"super.json\" located in the Shinobi directory."
|
||||
cp /config/super.json super.json
|
||||
fi
|
||||
|
||||
if [ ! -e "./conf.json" ]; then
|
||||
sudo cp conf.sample.json conf.json
|
||||
sudo cp conf.sample.json /config/conf.json
|
||||
#Generate a random Cron key for the config file
|
||||
cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}')
|
||||
#Insert key into conf.json
|
||||
sudo sed -i -e 's/change_this_to_something_very_random__just_anything_other_than_this/'"$cronKey"'/g' conf.json
|
||||
fi
|
||||
#create super.json
|
||||
if [ ! -e "./super.json" ]; then
|
||||
echo "============="
|
||||
echo "Default Superuser : admin@shinobi.video"
|
||||
echo "Default Password : admin"
|
||||
echo "* You can edit these settings in \"super.json\" located in the Shinobi directory."
|
||||
sudo cp super.sample.json super.json
|
||||
sudo cp super.sample.json /config/super.json
|
||||
fi
|
||||
touch thisIsDocker.txt
|
||||
node tools/modifyConfiguration.js cpuUsageMarker=CPU
|
||||
echo "Getting Latest Shinobi Master ..."
|
||||
# Execute Command
|
||||
echo "Starting Shinobi ..."
|
||||
exec "$@"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
apps:
|
||||
- script : '/home/Shinobi/camera.js'
|
||||
name : 'camera'
|
||||
kill_timeout : 5000
|
||||
- script : '/home/Shinobi/cron.js'
|
||||
name : 'cron'
|
||||
kill_timeout : 5000
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
FROM ubuntu:bionic
|
||||
|
||||
ENV ADMIN_USER=admin@shinobi.video \
|
||||
ADMIN_PASSWORD=admin \
|
||||
CRON_KEY=fd6c7849-904d-47ea-922b-5143358ba0de \
|
||||
PLUGINKEY_MOTION=b7502fd9-506c-4dda-9b56-8e699a6bc41c \
|
||||
PLUGINKEY_OPENCV=f078bcfe-c39a-4eb5-bd52-9382ca828e8a \
|
||||
PLUGINKEY_OPENALPR=dbff574e-9d4a-44c1-b578-3dc0f1944a3c \
|
||||
#leave these ENVs alone unless you know what you are doing
|
||||
DB_USER=majesticflame \
|
||||
DB_PASSWORD=mizukagesbluedress \
|
||||
DB_HOST=localhost \
|
||||
DB_DATABASE=ccio \
|
||||
DB_ROOT_PASSWORD=mizukagesbluedress \
|
||||
DB_ROOT_USER=root
|
||||
|
||||
RUN mkdir -p /home/Shinobi /config /var/lib/mysql
|
||||
|
||||
RUN apt update -y
|
||||
RUN apt install wget curl net-tools -y
|
||||
|
||||
# Install Node.js
|
||||
RUN wget https://deb.nodesource.com/setup_12.x
|
||||
RUN chmod +x setup_12.x
|
||||
RUN ./setup_12.x
|
||||
RUN apt install nodejs -y
|
||||
RUN rm setup_12.x
|
||||
|
||||
# Install MariaDB server... the debian way
|
||||
RUN set -ex; \
|
||||
{ \
|
||||
echo "mariadb-server" mysql-server/root_password password '${DB_ROOT_PASSWORD}'; \
|
||||
echo "mariadb-server" mysql-server/root_password_again password '${DB_ROOT_PASSWORD}'; \
|
||||
} | debconf-set-selections; \
|
||||
apt-get update; \
|
||||
apt-get install -y \
|
||||
"mariadb-server" \
|
||||
socat \
|
||||
; \
|
||||
find /etc/mysql/ -name '*.cnf' -print0 \
|
||||
| xargs -0 grep -lZE '^(bind-address|log)' \
|
||||
| xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/'
|
||||
|
||||
RUN sed -ie "s/^bind-address\s*=\s*127\.0\.0\.1$/#bind-address = 0.0.0.0/" /etc/mysql/my.cnf
|
||||
|
||||
# Install FFmpeg
|
||||
|
||||
RUN apt install -y software-properties-common \
|
||||
libfreetype6-dev \
|
||||
libgnutls28-dev \
|
||||
libmp3lame-dev \
|
||||
libass-dev \
|
||||
libogg-dev \
|
||||
libtheora-dev \
|
||||
libvorbis-dev \
|
||||
libvpx-dev \
|
||||
libwebp-dev \
|
||||
libssh2-1-dev \
|
||||
libopus-dev \
|
||||
librtmp-dev \
|
||||
libx264-dev \
|
||||
libx265-dev \
|
||||
yasm && \
|
||||
apt install -y \
|
||||
build-essential \
|
||||
bzip2 \
|
||||
coreutils \
|
||||
gnutls-bin \
|
||||
nasm \
|
||||
tar \
|
||||
x264
|
||||
|
||||
RUN apt install -y \
|
||||
ffmpeg \
|
||||
git \
|
||||
make \
|
||||
g++ \
|
||||
gcc \
|
||||
pkg-config \
|
||||
python3 \
|
||||
wget \
|
||||
tar \
|
||||
sudo \
|
||||
xz-utils
|
||||
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 800 --slave /usr/bin/g++ g++ /usr/bin/g++-7
|
||||
|
||||
####
|
||||
|
||||
|
||||
WORKDIR /home/Shinobi
|
||||
COPY . .
|
||||
RUN npm i npm@latest -g && \
|
||||
npm install pm2 -g && \
|
||||
npm install --unsafe-perm && \
|
||||
npm audit fix --force
|
||||
COPY ./Docker/pm2.yml ./
|
||||
|
||||
# Copy default configuration files
|
||||
# COPY ./config/conf.json ./config/super.json /home/Shinobi/
|
||||
RUN chmod -f +x /home/Shinobi/Docker/init.sh
|
||||
|
||||
VOLUME ["/home/Shinobi/videos"]
|
||||
VOLUME ["/home/Shinobi/plugins"]
|
||||
VOLUME ["/config"]
|
||||
VOLUME ["/customAutoLoad"]
|
||||
VOLUME ["/var/lib/mysql"]
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/home/Shinobi/Docker/init.sh"]
|
||||
|
||||
CMD [ "pm2-docker", "pm2.yml" ]
|
||||
Loading…
Reference in New Issue