├── .circleci └── config.yml ├── .env ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── LICENSE ├── PUBLISHING.md ├── README.md ├── assets ├── Publishing - Buildx - Enable Windows Docker Experimental Features - 01.jpg ├── Publishing - Buildx - Enable Windows Docker Experimental Features - 02.jpg └── Publishing - Buildx - Searching the Supported Architectures for a Docker Image.jpg ├── docker-compose.local.yml ├── docker-compose.yml ├── mariadb ├── Dockerfile ├── docker-entrypoint-initdb.d │ ├── .gitignore │ └── createdb.sql.example └── my.cnf ├── phpmyadmin └── Dockerfile └── shinobi ├── Dockerfile ├── config ├── conf.sample.json ├── motion.conf.sample.json └── super.sample.json ├── docker-entrypoint.sh └── pm2Shinobi.yml /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | defaults: &defaults 4 | working_directory: ~/repo 5 | docker: 6 | - image: cimg/base:stable 7 | 8 | commands: 9 | docker_base_prep: 10 | description: "Checkout, docker build & login" 11 | steps: 12 | - checkout 13 | # For more information on what this special docker step does, see: 14 | # https://circleci.com/docs/2.0/building-docker-images/#overview 15 | - setup_remote_docker 16 | - run: 17 | name: Enable Docker CLI experimental features 18 | command: echo 'export DOCKER_CLI_EXPERIMENTAL=enabled' >> $BASH_ENV 19 | - run: 20 | name: Configure multi-arch builder 21 | command: | 22 | # Registers binfmt for ARM support when doing multi-arch builds 23 | # For more information, see https://www.docker.com/blog/getting-started-with-docker-for-arm-on-linux/ 24 | docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64 25 | # Creates and uses the multi-arch builder, as default 26 | # builder doesn't allow for multi-arch builds 27 | docker context create node-multiarchbuilder 28 | docker buildx create --use --name multiarchbuilder node-multiarchbuilder 29 | - run: 30 | name: List supported architecture for multi-arch builder 31 | command: docker buildx inspect --bootstrap 32 | - run: 33 | name: Validate docker-compose setup 34 | command: docker-compose -f "docker-compose.yml" -f "docker-compose.local.yml" build 35 | 36 | jobs: 37 | build-master: 38 | <<: *defaults 39 | 40 | steps: 41 | - docker_base_prep 42 | - run: 43 | name: Build & push Shinobi as latest multi-arch docker image 44 | command: | 45 | echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username "$DOCKER_REGISTRY_USER" --password-stdin 46 | cd shinobi 47 | # Build with multi-arch build, with logging set to 'plain' 48 | # to avoid logging issues with the CI service. 49 | docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 -t "$DOCKER_REGISTRY_USER/shinobi:latest" --progress plain --push . 50 | 51 | build: 52 | <<: *defaults 53 | 54 | steps: 55 | - docker_base_prep 56 | - run: 57 | name: Build & push Shinobi as multi-arch docker image 58 | command: | 59 | echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username "$DOCKER_REGISTRY_USER" --password-stdin 60 | cd shinobi 61 | docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 -t "$DOCKER_REGISTRY_USER/shinobi:$CIRCLE_SHA1" --progress plain --push . 62 | 63 | workflows: 64 | version: 2 65 | build-publish: 66 | jobs: 67 | - build-master: 68 | filters: 69 | branches: 70 | only: 71 | - master 72 | - build: 73 | filters: 74 | branches: 75 | ignore: 76 | - master -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | # General Setup 3 | ########################################################### 4 | 5 | ### Data Path ########################################################################################################## 6 | # Choose storage path on your machine. For all storage systems. 7 | 8 | DATA_SAVE_PATH=./.data 9 | 10 | ######################################################################################################################## 11 | 12 | ########################################################### 13 | # Containers Customization 14 | ########################################################### 15 | 16 | SHINOBI_IMAGE=mtran0011/shinobi:latest 17 | SHINOBI_DB_USER=root 18 | SHINOBI_DB_PASSWORD=root 19 | SHINOBI_DB_PORT=3306 20 | 21 | ### MARIADB ############################################################################################################ 22 | 23 | MARIADB_IMAGE=mariadb:latest 24 | MARIADB_DATABASE=default 25 | MARIADB_USER=default 26 | MARIADB_PASSWORD=default 27 | MARIADB_PORT=3306 28 | MARIADB_ROOT_PASSWORD=root 29 | MARIADB_ENTRYPOINT_INITDB=./mariadb/docker-entrypoint-initdb.d 30 | 31 | ### PHP MY ADMIN ####################################################################################################### 32 | 33 | PMA_IMAGE=phpmyadmin/phpmyadmin:latest 34 | PMA_PORT=8888 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Note: for support questions, please use stackoverflow**. This repository's issues are reserved for feature requests and bug reports. 2 | 3 | * **I'm submitting a ...** 4 | - [ ] bug report 5 | - [ ] feature request 6 | - [ ] support request => Please do not submit support request here, see note at the top of this template. 7 | 8 | 9 | * **Do you want to request a *feature* or report a *bug*?** 10 | 11 | 12 | 13 | * **What is the current behavior?** 14 | 15 | 16 | 17 | * **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** via 18 | https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5). 19 | 20 | 21 | 22 | * **What is the expected behavior?** 23 | 24 | 25 | 26 | * **What is the motivation / use case for changing the behavior?** 27 | 28 | 29 | 30 | * **Please tell us about your environment:** 31 | 32 | - Version: 2.0.0-beta.X 33 | - Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] 34 | - Language: [all | TypeScript X.X | ES6/7 | ES5 | Dart] 35 | 36 | 37 | * **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc) 38 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * **Please check if the PR fulfills these requirements** 2 | - [ ] The commit message follows our guidelines 3 | - [ ] Tests for the changes have been added (for bug fixes / features) 4 | - [ ] Docs have been added / updated (for bug fixes / features) 5 | 6 | 7 | * **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) 8 | 9 | 10 | 11 | * **What is the current behavior?** (You can also link to an open issue here) 12 | 13 | 14 | 15 | * **What is the new behavior (if this is a feature change)?** 16 | 17 | 18 | 19 | * **Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?) 20 | 21 | 22 | 23 | * **Other information**: 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .data -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Michael Tran 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PUBLISHING.md: -------------------------------------------------------------------------------- 1 | # Publishing 2 | 3 | This repository uses `buildx` to build and publish the docker image. 4 | At time of writing, multi-architectural builds with `buildx` is an experimental feature. You'd need to enable the experimental features for docker. 5 | 6 | To enable experimental features on Windows `Docker Desktop`: 7 | 1. Right click on the docker icon on the bottom right tray. 8 | 2. Click on `Settings`. 9 | ![Settings Context Menu](/assets/Publishing%20-%20Buildx%20-%20Enable%20Windows%20Docker%20Experimental%20Features%20-%2001.jpg) 10 | 3. Click on the `Enable Experimental Features` switch under the `Command Line` tab. 11 | 4. ![Command Line Experimental Features Switch](/assets/Publishing%20-%20Buildx%20-%20Enable%20Windows%20Docker%20Experimental%20Features%20-%2002.jpg) 12 | 5. Click `Apply and Restart`. 13 | 14 | Now to build a docker image, we'll use the new docker command line tool called `buildx`. 15 | 16 | 1. Navigate to where you `Dockerfile` resides. 17 | ```powershell 18 | cd 19 | ``` 20 | 2. You need to create your custom builder, and use it. You can't use the default docker builder as it doesn't support multi-architectural builds. 21 | ```powershell 22 | docker buildx create --name 23 | docker buildx use 24 | ``` 25 | 3. Login to your docker image repository. This will prompt you for your username and password if you haven't logged in before. 26 | ```powershell 27 | docker login 28 | ``` 29 | 4. Now to do the actual build using `buildx`. For the most part, `buildx` is just an extension to the `build` command, meaning it has the same syntax, just a few extended flags and features, such as `--platform` which we can use for multi-architectural builds. 30 | ```powershell 31 | docker buildx build --platform -t "/:" --push . 32 | ``` 33 | > The `` is a string of CPU architectures to support, delimited by comma (e.g. `linux/amd64,linux/arm/v6,linux/arm64/v8`). The CPU architectures that can be supported depends on: 34 | > 1. The base image you're using in the `Dockerfile`. It must support the architecture you've provided. You can check what CPU architecture your base image supports through finding the image in [DockerHub](https://hub.docker.com/), click on the image, and then click on the `Tags` tab. There, you'd be able to see a list of `OS/Arch` it supports. Your list of supported CPU architectures must be a subset of that list. 35 | > ![Searching the Supported Architecture for Docker Image](/assets/Publishing%20-%20Buildx%20-%20Searching%20the%20Supported%20Architectures%20for%20a%20Docker%20Image.jpg) 36 | > 2. The architecture that's supported by your installed software & architecture. You can find what is supported through running the below command: 37 | > ```powershell 38 | > docker buildx inspect --bootstrap 39 | > ``` 40 | 41 | Here's an example with putting everything together: 42 | 43 | ```powershell 44 | cd shinobi 45 | docker buildx create --name shinobibuilder 46 | docker buildx use shinobibuilder 47 | docker login 48 | docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 -t mtran0011/shinobi --push . 49 | ``` 50 | 51 | If you'd like to remove your custom builder, you can use: 52 | 53 | ```powershell 54 | docker buildx use default 55 | docker buildx rm shinobibuilder 56 | ``` 57 | 58 | For more information, see: 59 | * [https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408](https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408) 60 | * [https://dev.to/arturklauser/building-multi-architecture-docker-images-with-buildx-1mii](https://dev.to/arturklauser/building-multi-architecture-docker-images-with-buildx-1mii) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shinobi CCTV on Docker 2 | 3 | This is based on the official [Shinobi docker image](https://gitlab.com/Shinobi-Systems/ShinobiDocker). 4 | 5 | This uses a `docker-compose` setup where the Shinobi image and the MariaDB is not in the same image. This keeps things easy to maintain and swap the database out. 6 | 7 | The database can even be on a separate server machine, or not even dockerised. 8 | 9 | The hosted [Shinobi Docker image](https://hub.docker.com/repository/docker/mtran0011/shinobi) is built from this repository. 10 | 11 | ### Features 12 | 13 | * Shinobi & MariaDB image are two separate containers. 14 | * You can easily swap out MariaDB for another DB image, such as MySQL, or change the MariaDB version. 15 | * You can even decide to have a DB sitting directly on a physical machine, rather then as a container. 16 | * Multi-arch builds, which means the Shinobi image is compatible with different CPU architectures. 17 | * Such as ARM used by Raspberry Pis, etc. 18 | * `PHP My Admin` is included, so you can manage the data in your database, simply by browsing to `http://xxx.xxx.xxx.xxx:8888`. This gives you an easy way to export/import your Shinobi database via a GUI! 19 | 20 | ### How to Dock Shinobi 21 | 22 | > `docker-compose` should already be installed. 23 | 24 | 1. Clone the Repo and enter the `docker-shinobi` directory. 25 | ```bash 26 | git clone https://github.com/deltoss/ShinobiDocker.git ShinobiDocker && cd ShinobiDocker 27 | ``` 28 | 29 | 2. Spark one up. 30 | ```bash 31 | docker-compose up -d 32 | ``` 33 | 34 | 3. Open your computer's IP address in your web browser on port `8080`. Open the superuser panel to create an account. 35 | ``` 36 | Web Address : http://xxx.xxx.xxx.xxx:8080/super 37 | Username : admin@shinobi.video 38 | Password : admin 39 | ``` 40 | 41 | 4. After account creation head on over to the main `Web Address` and start using Shinobi! 42 | ``` 43 | http://xxx.xxx.xxx.xxx:8080 44 | ``` 45 | 46 | 5. Enjoy! 47 | 48 | ### Working on the Raspberry Pi 49 | 50 | Raspberry Pi 3 & 4 uses the ARMv7 32-bit architecture. This Shinobi image supports ARMv7 architecture, however the official MariaDB docker image does not. At time of writing, it only supports ARM64 51 | 52 | Thus, you could either make your own image, and build it to support ARMv7, or use a non-official MariaDB image which supports ARMv7. 53 | 54 | To change both the `MariaDB` image & the `PHPMyAdmin` image. To do this, you can simply change the values for the following keys in the `.env` file: 55 | * `MARIADB_IMAGE` 56 | * `PMA_IMAGE` 57 | 58 | For example, change this: 59 | 60 | ```env 61 | MARIADB_IMAGE=mariadb:latest 62 | # ... 63 | PMA_IMAGE=phpmyadmin/phpmyadmin:latest 64 | ``` 65 | 66 | To this: 67 | 68 | ```env 69 | MARIADB_IMAGE=yobasystems/alpine-mariadb:latest 70 | # ... 71 | PMA_IMAGE=jackgruber/phpmyadmin:latest 72 | ``` 73 | 74 | [yobasystems/alpine-mariadb](https://hub.docker.com/r/yobasystems/alpine-mariadb/) and [jackgruber/phpmyadmin](https://hub.docker.com/r/jackgruber/phpmyadmin) are third-party images which supports ARMv7. 75 | -------------------------------------------------------------------------------- /assets/Publishing - Buildx - Enable Windows Docker Experimental Features - 01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltoss/ShinobiDocker/387a1876a6e48dfcffd4e604918e89182017b421/assets/Publishing - Buildx - Enable Windows Docker Experimental Features - 01.jpg -------------------------------------------------------------------------------- /assets/Publishing - Buildx - Enable Windows Docker Experimental Features - 02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltoss/ShinobiDocker/387a1876a6e48dfcffd4e604918e89182017b421/assets/Publishing - Buildx - Enable Windows Docker Experimental Features - 02.jpg -------------------------------------------------------------------------------- /assets/Publishing - Buildx - Searching the Supported Architectures for a Docker Image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deltoss/ShinobiDocker/387a1876a6e48dfcffd4e604918e89182017b421/assets/Publishing - Buildx - Searching the Supported Architectures for a Docker Image.jpg -------------------------------------------------------------------------------- /docker-compose.local.yml: -------------------------------------------------------------------------------- 1 | # docker-compose override file for building images for testing 2 | # the Shinobi Docker image locally. 3 | # 4 | # To build and run the docker-compose set up locally with 5 | # the Shinobi image built from the Dockerfile, run below commands: 6 | # docker-compose -f "docker-compose.yml" -f "docker-compose.local.yml" build 7 | # docker-compose -f "docker-compose.yml" -f "docker-compose.local.yml" up 8 | # Alternatively, with a single line: 9 | # docker-compose -f "docker-compose.yml" -f "docker-compose.local.yml" up --build 10 | version: '3.7' 11 | 12 | services: 13 | 14 | ### Shinobi Container ####################################### 15 | 16 | shinobi: 17 | image: shinobi 18 | build: ./shinobi -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | 5 | ### MariaDB Container ####################################### 6 | 7 | mariadb: 8 | build: 9 | context: ./mariadb 10 | args: 11 | MARIADB_IMAGE: ${MARIADB_IMAGE} 12 | volumes: 13 | - mariadb:/var/lib/mysql 14 | - ${MARIADB_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d 15 | ports: 16 | - "${MARIADB_PORT}:3306" 17 | environment: 18 | - MYSQL_DATABASE=${MARIADB_DATABASE} 19 | - MYSQL_USER=${MARIADB_USER} 20 | - MYSQL_PASSWORD=${MARIADB_PASSWORD} 21 | - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD} 22 | restart: unless-stopped 23 | 24 | ### phpMyAdmin Container #################################### 25 | 26 | phpmyadmin: 27 | build: 28 | context: ./phpmyadmin 29 | args: 30 | PMA_IMAGE: ${PMA_IMAGE} 31 | environment: 32 | - PMA_ARBITRARY=1 33 | ports: 34 | - "${PMA_PORT}:80" 35 | depends_on: 36 | - "mariadb" 37 | restart: unless-stopped 38 | 39 | ### Shinobi Container ####################################### 40 | 41 | shinobi: 42 | image: ${SHINOBI_IMAGE} 43 | depends_on: 44 | - "mariadb" 45 | ports: 46 | - "8080:8080" 47 | environment: 48 | - DATABASE_HOST=mariadb 49 | - DATABASE_USER=${SHINOBI_DB_USER} 50 | - DATABASE_PASSWORD=${SHINOBI_DB_PASSWORD} 51 | - DATABASE_PORT=${SHINOBI_DB_PORT} 52 | volumes: 53 | - ${DATA_SAVE_PATH}/shinobi/config:/config 54 | - ${DATA_SAVE_PATH}/shinobi/videos:/opt/shinobi/videos 55 | - ${DATA_SAVE_PATH}/shinobi/datadir:/var/lib/mysql 56 | restart: unless-stopped 57 | 58 | 59 | ### Volumes Setup ############################################# 60 | 61 | volumes: 62 | mariadb: -------------------------------------------------------------------------------- /mariadb/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG MARIADB_IMAGE=mariadb:latest 2 | FROM $MARIADB_IMAGE 3 | 4 | ADD my.cnf /etc/mysql/conf.d/my.cnf 5 | 6 | EXPOSE 3306 7 | -------------------------------------------------------------------------------- /mariadb/docker-entrypoint-initdb.d/.gitignore: -------------------------------------------------------------------------------- 1 | *.sql 2 | -------------------------------------------------------------------------------- /mariadb/docker-entrypoint-initdb.d/createdb.sql.example: -------------------------------------------------------------------------------- 1 | ### 2 | ### Copy createdb.sql.example to createdb.sql 3 | ### then uncomment then set database name and username to create you need databases 4 | # 5 | # example: .env MYSQL_USER=appuser and need db name is myshop_db 6 | # 7 | # CREATE DATABASE IF NOT EXISTS `myshop_db` ; 8 | # GRANT ALL ON `myshop_db`.* TO 'appuser'@'%' ; 9 | # 10 | ### 11 | ### this sql script is auto run when mariadb container start and $DATA_SAVE_PATH/mariadb not exists. 12 | ### 13 | ### if your $DATA_SAVE_PATH/mariadb is exists and you do not want to delete it, you can run by manual execution: 14 | ### 15 | ### docker-compose exec mariadb bash 16 | ### mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql 17 | ### 18 | 19 | #CREATE DATABASE IF NOT EXISTS `dev_db_1` COLLATE 'utf8_general_ci' ; 20 | #GRANT ALL ON `dev_db_1`.* TO 'default'@'%' ; 21 | 22 | #CREATE DATABASE IF NOT EXISTS `dev_db_2` COLLATE 'utf8_general_ci' ; 23 | #GRANT ALL ON `dev_db_2`.* TO 'default'@'%' ; 24 | 25 | #CREATE DATABASE IF NOT EXISTS `dev_db_3` COLLATE 'utf8_general_ci' ; 26 | #GRANT ALL ON `dev_db_3`.* TO 'default'@'%' ; 27 | 28 | FLUSH PRIVILEGES ; 29 | -------------------------------------------------------------------------------- /mariadb/my.cnf: -------------------------------------------------------------------------------- 1 | # MariaDB database server configuration file. 2 | # 3 | # You can use this file to overwrite the default configuration 4 | # 5 | # For explanations see 6 | # http://dev.mysql.com/doc/mysql/en/server-system-variables.html 7 | [mysqld] 8 | innodb_flush_method=O_DSYNC -------------------------------------------------------------------------------- /phpmyadmin/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PMA_IMAGE=phpmyadmin/phpmyadmin:latest 2 | FROM $PMA_IMAGE 3 | 4 | # Add volume to allow session persistence 5 | VOLUME /sessions 6 | 7 | EXPOSE 80 8 | -------------------------------------------------------------------------------- /shinobi/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine3.11 2 | 3 | LABEL Author="Deltoss, MiGoller, mrproper, pschmitt & moeiscool" 4 | 5 | # Set environment variables to default values 6 | # ADMIN_USER : the super user login name 7 | # ADMIN_PASSWORD : the super user login password 8 | # PLUGINKEY_MOTION : motion plugin connection key 9 | # PLUGINKEY_OPENCV : opencv plugin connection key 10 | # PLUGINKEY_OPENALPR : openalpr plugin connection key 11 | ENV ADMIN_USER=admin@shinobi.video \ 12 | ADMIN_PASSWORD=admin \ 13 | CRON_KEY=fd6c7849-904d-47ea-922b-5143358ba0de \ 14 | PLUGINKEY_MOTION=b7502fd9-506c-4dda-9b56-8e699a6bc41c \ 15 | PLUGINKEY_OPENCV=f078bcfe-c39a-4eb5-bd52-9382ca828e8a \ 16 | PLUGINKEY_OPENALPR=dbff574e-9d4a-44c1-b578-3dc0f1944a3c \ 17 | DATABASE_HOST=mariadb \ 18 | DATABASE_USER=root \ 19 | DATABASE_PASSWORD=root \ 20 | DATABASE_PORT=3306 21 | 22 | # Create additional directories for: Custom configuration, working directory, database directory 23 | RUN mkdir -p \ 24 | /config \ 25 | /opt/shinobi 26 | 27 | # Install package dependencies 28 | RUN apk update && \ 29 | apk add --no-cache \ 30 | freetype-dev \ 31 | gnutls-dev \ 32 | lame-dev \ 33 | libass-dev \ 34 | libogg-dev \ 35 | libtheora-dev \ 36 | libvorbis-dev \ 37 | libvpx-dev \ 38 | libwebp-dev \ 39 | libssh2 \ 40 | opus-dev \ 41 | rtmpdump-dev \ 42 | x264-dev \ 43 | x265-dev \ 44 | yasm-dev && \ 45 | apk add --no-cache \ 46 | build-base \ 47 | bzip2 \ 48 | coreutils \ 49 | gnutls \ 50 | nasm \ 51 | tar \ 52 | x264 53 | 54 | # Install additional packages 55 | RUN apk update && \ 56 | apk add --no-cache \ 57 | ffmpeg \ 58 | git \ 59 | make \ 60 | mariadb-client \ 61 | openrc \ 62 | pkgconfig \ 63 | python \ 64 | wget \ 65 | tar \ 66 | xz 67 | 68 | WORKDIR /opt/shinobi 69 | 70 | # Clone the Shinobi CCTV PRO repo and install Shinobi app including NodeJS dependencies 71 | RUN git clone https://gitlab.com/Shinobi-Systems/Shinobi.git /opt/shinobi && \ 72 | npm i npm@latest -g && \ 73 | npm install pm2 -g && \ 74 | npm install 75 | 76 | # Copy code 77 | COPY docker-entrypoint.sh pm2Shinobi.yml ./ 78 | RUN chmod -f +x ./*.sh 79 | 80 | # Copy default configuration files 81 | COPY ./config/conf.sample.json ./config/super.sample.json /opt/shinobi/ 82 | 83 | VOLUME ["/opt/shinobi/videos"] 84 | VOLUME ["/config"] 85 | 86 | EXPOSE 8080 87 | 88 | ENTRYPOINT ["/opt/shinobi/docker-entrypoint.sh"] 89 | 90 | CMD ["pm2-docker", "pm2Shinobi.yml"] -------------------------------------------------------------------------------- /shinobi/config/conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 8080, 3 | "addStorage": [ 4 | {"name":"second","path":"__DIR__/videos2"} 5 | ], 6 | "db": { 7 | "host": "optionally_replace_this_with_db_host", 8 | "user": "optionally_replace_this_with_db_user", 9 | "password": "optionally_replace_this_with_db_password", 10 | "database": "ccio", 11 | "port": "optionally_replace_this_with_db_port" 12 | }, 13 | "mail":{ 14 | "service": "gmail", 15 | "auth": { 16 | "user": "your_email@gmail.com", 17 | "pass": "your_password_or_app_specific_password" 18 | } 19 | }, 20 | "cron":{ 21 | "key":"73ffd716-16ab-40f4-8c2e-aecbd3bc1d30" 22 | }, 23 | "pluginKeys":{ 24 | "Motion":"d4b5feb4-8f9c-4b91-bfec-277c641fc5e3", 25 | "OpenCV":"644bb8aa-8066-44b6-955a-073e6a745c74", 26 | "OpenALPR":"9973e390-f6cd-44a4-86d7-954df863cea0" 27 | }, 28 | "productType":"Pro" 29 | } -------------------------------------------------------------------------------- /shinobi/config/motion.conf.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "plug":"Motion", 3 | "host":"localhost", 4 | "port":8080, 5 | "key":"d4b5feb4-8f9c-4b91-bfec-277c641fc5e3", 6 | "notice":"Looks like you have the Motion plugin running. Don't forget to enable Send Frames to start pushing frames to be read." 7 | } -------------------------------------------------------------------------------- /shinobi/config/super.sample.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "mail":"admin@shinobi.video", 4 | "pass":"21232f297a57a5a743894a0e4a801fc3" 5 | } 6 | ] -------------------------------------------------------------------------------- /shinobi/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # Copy existing custom configuration files 5 | echo "Copy custom configuration files ..." 6 | if [ -d /config ]; then 7 | cp -R -f "/config/"* /opt/shinobi || echo "No custom config files found." 8 | else 9 | echo "Folder /config doesn't exist - not copying custom config files" 10 | fi 11 | 12 | # Create default configurations files from samples if not existing 13 | if [ ! -f /opt/shinobi/conf.json ]; then 14 | echo "Create default config file /opt/shinobi/conf.json ..." 15 | cp /opt/shinobi/conf.sample.json /opt/shinobi/conf.json 16 | fi 17 | 18 | if [ ! -f /opt/shinobi/super.json ]; then 19 | echo "Create default config file /opt/shinobi/super.json ..." 20 | cp /opt/shinobi/super.sample.json /opt/shinobi/super.json 21 | fi 22 | 23 | if [ ! -f /opt/shinobi/plugins/motion/conf.json ]; then 24 | echo "Create default config file /opt/shinobi/plugins/motion/conf.json ..." 25 | cp /opt/shinobi/plugins/motion/conf.sample.json /opt/shinobi/plugins/motion/conf.json 26 | fi 27 | 28 | # Wait for the database to be available 29 | if [ -n "${DATABASE_HOST}" ]; then 30 | echo "Wait for MySQL server" ... 31 | while ! mysqladmin ping -h "$DATABASE_HOST" -P $DATABASE_PORT -u "$DATABASE_USER" --password="$DATABASE_PASSWORD"; do 32 | sleep 1 33 | done 34 | fi 35 | 36 | echo "Setting up MySQL database if it does not exists ..." 37 | 38 | echo "Create database schema if it does not exists ..." 39 | mysql -h "$DATABASE_HOST" -P $DATABASE_PORT -u "$DATABASE_USER" --password="$DATABASE_PASSWORD" -e "source /opt/shinobi/sql/framework.sql" || true 40 | 41 | echo "Set keys for CRON and PLUGINS from environment variables ..." 42 | sed -i -e 's/"key":"73ffd716-16ab-40f4-8c2e-aecbd3bc1d30"/"key":"'"${CRON_KEY}"'"/g' \ 43 | -e 's/"Motion":"d4b5feb4-8f9c-4b91-bfec-277c641fc5e3"/"Motion":"'"${PLUGINKEY_MOTION}"'"/g' \ 44 | -e 's/"OpenCV":"644bb8aa-8066-44b6-955a-073e6a745c74"/"OpenCV":"'"${PLUGINKEY_OPENCV}"'"/g' \ 45 | -e 's/"OpenALPR":"9973e390-f6cd-44a4-86d7-954df863cea0"/"OpenALPR":"'"${PLUGINKEY_OPENALPR}"'"/g' \ 46 | -e "s/optionally_replace_this_with_db_host/${DATABASE_HOST}/g" \ 47 | -e "s/optionally_replace_this_with_db_user/${DATABASE_USER}/g" \ 48 | -e "s/optionally_replace_this_with_db_password/${DATABASE_PASSWORD}/g" \ 49 | -e "s/optionally_replace_this_with_db_port/${DATABASE_PORT}/g" \ 50 | "/opt/shinobi/conf.json" 51 | 52 | # Set the admin password 53 | if [ -n "${ADMIN_USER}" ]; then 54 | if [ -n "${ADMIN_PASSWORD_MD5}" ]; then 55 | sed -i -e 's/"mail":"admin@shinobi.video"/"mail":"'"${ADMIN_USER}"'"/g' \ 56 | -e "s/21232f297a57a5a743894a0e4a801fc3/${ADMIN_PASSWORD_MD5}/g" \ 57 | "/opt/shinobi/super.json" 58 | fi 59 | fi 60 | 61 | # Change the uid/gid of the node user 62 | if [ -n "${GID}" ]; then 63 | if [ -n "${UID}" ]; then 64 | groupmod -g ${GID} node && usermod -u ${UID} -g ${GID} node 65 | fi 66 | fi 67 | 68 | cd /opt/shinobi 69 | node tools/modifyConfiguration.js cpuUsageMarker=CPU 70 | echo "Getting Latest Shinobi Master ..." 71 | git reset --hard 72 | git pull 73 | npm install 74 | # Execute Command 75 | echo "Starting Shinobi ..." 76 | exec "$@" -------------------------------------------------------------------------------- /shinobi/pm2Shinobi.yml: -------------------------------------------------------------------------------- 1 | apps: 2 | - script : '/opt/shinobi/camera.js' 3 | name : 'Camera-App' 4 | kill_timeout : 5000 5 | - script : '/opt/shinobi/cron.js' 6 | name : 'Cron-App' 7 | kill_timeout : 5000 8 | --------------------------------------------------------------------------------