diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e3a08114eb4eb1238b66540ae7e3ae2d1510447d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/Dockerfile b/Dockerfile index 4a05766e946e5471f56ec3cd1f661127e9113283..9c7e54e8d0bfdbb901fe22d13fd40b2b1236a494 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,106 +1,113 @@ -# -# Builds a custom docker image for ShinobiCCTV Pro -# -FROM node:8-alpine - -LABEL Author="MiGoller, mrproper, pschmitt & moeiscool" - -# Set environment variables to default values -# ADMIN_USER : the super user login name -# ADMIN_PASSWORD : the super user login password -# PLUGINKEY_MOTION : motion plugin connection key -# PLUGINKEY_OPENCV : opencv plugin connection key -# PLUGINKEY_OPENALPR : openalpr plugin connection key -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 - MYSQL_USER=majesticflame \ - MYSQL_PASSWORD=password \ - MYSQL_HOST=localhost \ - MYSQL_DATABASE=ccio \ - MYSQL_ROOT_PASSWORD=blubsblawoot \ - MYSQL_ROOT_USER=root - - -# Create the custom configuration dir -RUN mkdir -p /config - -# Create the working dir -RUN mkdir -p /opt/shinobi - - -# Install package dependencies -RUN apk update && \ -apk upgrade && \ -apk --no-cache add freetype-dev \ - gnutls-dev \ - lame-dev \ - libass-dev \ - libogg-dev \ - libtheora-dev \ - libvorbis-dev \ - libvpx-dev \ - libwebp-dev \ - libssh2 \ - opus-dev \ - rtmpdump-dev \ - x264-dev \ - x265-dev \ - yasm-dev && \ -apk add --no-cache --virtual \ - .build-dependencies \ - build-base \ - bzip2 \ - coreutils \ - gnutls \ - nasm \ - tar \ - x264 - -RUN apk add --update --no-cache python make ffmpeg pkgconfig git mariadb mariadb-client wget tar xz openrc -RUN sed -ie "s/^bind-address\s*=\s*127\.0\.0\.1$/#bind-address = 0.0.0.0/" /etc/mysql/my.cnf - -# Install ffmpeg static build version from cdn.shinobi.video -RUN wget https://cdn.shinobi.video/installers/ffmpeg-release-64bit-static.tar.xz - -RUN tar xpvf ./ffmpeg-release-64bit-static.tar.xz -C ./ \ - && cp -f ./ffmpeg-3.3.4-64bit-static/ff* /usr/bin/ \ - && chmod +x /usr/bin/ff* - -RUN rm -f ffmpeg-release-64bit-static.tar.xz \ - && rm -rf ./ffmpeg-3.3.4-64bit-static - -WORKDIR /opt/shinobi - -# Clone the Shinobi CCTV PRO repo -RUN git clone https://gitlab.com/Shinobi-Systems/Shinobi.git /opt/shinobi - -# Install NodeJS dependencies -RUN npm i npm@latest -g - -RUN npm install pm2 -g - -RUN npm install - -# Copy code -COPY docker-entrypoint.sh . -COPY pm2Shinobi.yml . -RUN chmod -f +x ./*.sh - -# Copy default configuration files -COPY ./config/conf.sample.json /opt/shinobi/conf.sample.json -COPY ./config/super.sample.json /opt/shinobi/super.sample.json - -VOLUME ["/opt/shinobi/videos"] -VOLUME ["/config"] -VOLUME ["/var/lib/mysql"] - -EXPOSE 8080 - -ENTRYPOINT ["/opt/shinobi/docker-entrypoint.sh"] - -CMD ["pm2-docker", "pm2Shinobi.yml"] +# +# Builds a custom docker image for ShinobiCCTV Pro +# +FROM node:8-alpine + +LABEL Author="MiGoller, mrproper, pschmitt & moeiscool" + +# Set environment variables to default values +# ADMIN_USER : the super user login name +# ADMIN_PASSWORD : the super user login password +# PLUGINKEY_MOTION : motion plugin connection key +# PLUGINKEY_OPENCV : opencv plugin connection key +# PLUGINKEY_OPENALPR : openalpr plugin connection key +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 + MYSQL_USER=majesticflame \ + MYSQL_PASSWORD=password \ + MYSQL_HOST=localhost \ + MYSQL_DATABASE=ccio \ + MYSQL_ROOT_PASSWORD=blubsblawoot \ + MYSQL_ROOT_USER=root + + +# Create additional directories for: Custom configuration, working directory, database directory +RUN mkdir -p \ + /config \ + /opt/shinobi \ + /var/lib/mysql + + +# Install package dependencies +RUN apk update && \ + apk add --no-cache \ + freetype-dev \ + gnutls-dev \ + lame-dev \ + libass-dev \ + libogg-dev \ + libtheora-dev \ + libvorbis-dev \ + libvpx-dev \ + libwebp-dev \ + libssh2 \ + opus-dev \ + rtmpdump-dev \ + x264-dev \ + x265-dev \ + yasm-dev && \ + apk add --no-cache --virtual \ + .build-dependencies \ + build-base \ + bzip2 \ + coreutils \ + gnutls \ + nasm \ + tar \ + x264 + +# Install additional packages +RUN apk update && \ + apk add --no-cache \ + ffmpeg \ + git \ + make \ + mariadb \ + mariadb-client \ + openrc \ + pkgconfig \ + python \ + wget \ + tar \ + xz + +RUN sed -ie "s/^bind-address\s*=\s*127\.0\.0\.1$/#bind-address = 0.0.0.0/" /etc/mysql/my.cnf + +# Install ffmpeg static build version from cdn.shinobi.video +RUN wget https://cdn.shinobi.video/installers/ffmpeg-release-64bit-static.tar.xz && \ + tar xpvf ./ffmpeg-release-64bit-static.tar.xz -C ./ && \ + cp -f ./ffmpeg-3.3.4-64bit-static/ff* /usr/bin/ && \ + chmod +x /usr/bin/ff* && \ + rm -f ffmpeg-release-64bit-static.tar.xz && \ + rm -rf ./ffmpeg-3.3.4-64bit-static + +# Assign working directory +WORKDIR /opt/shinobi + +# Clone the Shinobi CCTV PRO repo and install Shinobi app including NodeJS dependencies +RUN git clone https://gitlab.com/Shinobi-Systems/Shinobi.git /opt/shinobi && \ + npm i npm@latest -g && \ + npm install pm2 -g && \ + npm install + +# Copy code +COPY docker-entrypoint.sh pm2Shinobi.yml ./ +RUN chmod -f +x ./*.sh + +# Copy default configuration files +COPY ./config/conf.sample.json ./config/super.sample.json /opt/shinobi/ + +VOLUME ["/opt/shinobi/videos"] +VOLUME ["/config"] +VOLUME ["/var/lib/mysql"] + +EXPOSE 8080 + +ENTRYPOINT ["/opt/shinobi/docker-entrypoint.sh"] + +CMD ["pm2-docker", "pm2Shinobi.yml"] diff --git a/debug-image.sh b/debug-image.sh new file mode 100644 index 0000000000000000000000000000000000000000..2777e1d1a06e49d4d225f1d95ff1ac24ed791c9a --- /dev/null +++ b/debug-image.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +if [ ! -d ./datadir ] +then + mkdir -p datadir + chmod -R 777 datadir +fi + +if [ ! -d ./videos ] +then + mkdir -p videos + chmod -R 777 videos +fi + +docker-compose up --build diff --git a/stop-image.sh b/stop-image.sh new file mode 100644 index 0000000000000000000000000000000000000000..68fa4532a54f21da59b39891538043be0daad672 --- /dev/null +++ b/stop-image.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +docker-compose down