From 46e5a042aeeb989c37aea9a65940b4f8c2a9ac18 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Wed, 3 Mar 2021 07:33:50 -0600 Subject: [PATCH] adding s6-overlay and running jsmpeg --- Makefile | 11 +++++++---- docker-compose.yml | 2 +- docker/Dockerfile.base | 16 ++++++++++++---- docker/Dockerfile.jsmpeg | 3 +-- docker/rootfs/etc/services.d/jsmpeg/finish | 5 +++++ docker/rootfs/etc/services.d/jsmpeg/run | 2 ++ docker/rootfs/etc/services.d/nginx/finish | 5 +++++ docker/rootfs/etc/services.d/nginx/run | 2 ++ .../rootfs/usr/local/nginx/conf}/nginx.conf | 1 + run.sh | 4 ---- 10 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 docker/rootfs/etc/services.d/jsmpeg/finish create mode 100644 docker/rootfs/etc/services.d/jsmpeg/run create mode 100644 docker/rootfs/etc/services.d/nginx/finish create mode 100644 docker/rootfs/etc/services.d/nginx/run rename {nginx => docker/rootfs/usr/local/nginx/conf}/nginx.conf (99%) delete mode 100644 run.sh diff --git a/Makefile b/Makefile index 845024f59..c28d0c824 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ version: web: docker build --tag frigate-web --file docker/Dockerfile.web web/ +jsmpeg: + docker build --tag frigate-jsmpeg --file docker/Dockerfile.jsmpeg jsmpeg/ + amd64_wheels: docker build --tag blakeblackshear/frigate-wheels:1.0.3-amd64 --file docker/Dockerfile.wheels . @@ -17,7 +20,7 @@ amd64_ffmpeg: nginx_frigate: docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag blakeblackshear/frigate-nginx:1.0.0 --file docker/Dockerfile.nginx . -amd64_frigate: version web +amd64_frigate: version web jsmpeg docker build --tag frigate-base --build-arg ARCH=amd64 --build-arg FFMPEG_VERSION=1.1.0 --build-arg WHEELS_VERSION=1.0.3 --build-arg NGINX_VERSION=1.0.0 --file docker/Dockerfile.base . docker build --tag frigate --file docker/Dockerfile.amd64 . @@ -29,7 +32,7 @@ amd64nvidia_wheels: amd64nvidia_ffmpeg: docker build --tag blakeblackshear/frigate-ffmpeg:1.0.0-amd64nvidia --file docker/Dockerfile.ffmpeg.amd64nvidia . -amd64nvidia_frigate: version web +amd64nvidia_frigate: version web jsmpeg docker build --tag frigate-base --build-arg ARCH=amd64nvidia --build-arg FFMPEG_VERSION=1.0.0 --build-arg WHEELS_VERSION=1.0.3 --build-arg NGINX_VERSION=1.0.0 --file docker/Dockerfile.base . docker build --tag frigate --file docker/Dockerfile.amd64nvidia . @@ -41,7 +44,7 @@ aarch64_wheels: aarch64_ffmpeg: docker build --tag blakeblackshear/frigate-ffmpeg:1.0.0-aarch64 --file docker/Dockerfile.ffmpeg.aarch64 . -aarch64_frigate: version web +aarch64_frigate: version web jsmpeg docker build --tag frigate-base --build-arg ARCH=aarch64 --build-arg FFMPEG_VERSION=1.0.0 --build-arg WHEELS_VERSION=1.0.3 --build-arg NGINX_VERSION=1.0.0 --file docker/Dockerfile.base . docker build --tag frigate --file docker/Dockerfile.aarch64 . @@ -53,7 +56,7 @@ armv7_wheels: armv7_ffmpeg: docker build --tag blakeblackshear/frigate-ffmpeg:1.0.0-armv7 --file docker/Dockerfile.ffmpeg.armv7 . -armv7_frigate: version web +armv7_frigate: version web jsmpeg docker build --tag frigate-base --build-arg ARCH=armv7 --build-arg FFMPEG_VERSION=1.0.0 --build-arg WHEELS_VERSION=1.0.3 --build-arg NGINX_VERSION=1.0.0 --file docker/Dockerfile.base . docker build --tag frigate --file docker/Dockerfile.armv7 . diff --git a/docker-compose.yml b/docker-compose.yml index 7f1624f1a..96e7024d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: - "5000:5000" - "5001:5001" - "8080:8080" - command: /bin/sh -c "sudo /usr/local/nginx/sbin/nginx; while sleep 1000; do :; done" + command: /bin/sh -c "while sleep 1000; do :; done" mqtt: container_name: mqtt image: eclipse-mosquitto:1.6 diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index 0c8b5ebf4..65cd9d20f 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -6,10 +6,15 @@ FROM blakeblackshear/frigate-wheels:${WHEELS_VERSION}-${ARCH} as wheels FROM blakeblackshear/frigate-ffmpeg:${FFMPEG_VERSION}-${ARCH} as ffmpeg FROM blakeblackshear/frigate-nginx:${NGINX_VERSION} as nginx FROM frigate-web as web +FROM frigate-jsmpeg as jsmpeg FROM ubuntu:20.04 LABEL maintainer "blakeb@blakeshome.com" +# s6-overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.1/s6-overlay-amd64-installer /tmp/ +RUN chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / + COPY --from=ffmpeg /usr/local /usr/local/ COPY --from=wheels /wheels/. /wheels/ @@ -39,7 +44,6 @@ RUN pip3 install \ gevent-websocket COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/ -COPY nginx/nginx.conf /usr/local/nginx/conf/nginx.conf # get model and labels COPY labelmap.txt /labelmap.txt @@ -52,10 +56,14 @@ ADD migrations migrations/ COPY --from=web /opt/frigate/build web/ -COPY run.sh /run.sh -RUN chmod +x /run.sh +COPY --from=jsmpeg /opt/build jsmpeg/ +COPY --from=jsmpeg /usr/local/bin/node /usr/local/bin/node + +COPY docker/rootfs/ / EXPOSE 5000 EXPOSE 1935 -CMD ["/run.sh"] +ENTRYPOINT ["/init"] + +CMD ["python3", "-u", "-m", "frigate"] diff --git a/docker/Dockerfile.jsmpeg b/docker/Dockerfile.jsmpeg index c97e2d7ad..68d5f5afe 100644 --- a/docker/Dockerfile.jsmpeg +++ b/docker/Dockerfile.jsmpeg @@ -4,8 +4,7 @@ FROM node:${NODE_VERSION} WORKDIR /opt/build -COPY jsmpeg/. . +COPY . . RUN npm install --no-progress && \ - npm run build && \ npm prune --production --ignore-scripts --prefer-offline diff --git a/docker/rootfs/etc/services.d/jsmpeg/finish b/docker/rootfs/etc/services.d/jsmpeg/finish new file mode 100644 index 000000000..24482e77f --- /dev/null +++ b/docker/rootfs/etc/services.d/jsmpeg/finish @@ -0,0 +1,5 @@ +#!/usr/bin/execlineb -S1 +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services \ No newline at end of file diff --git a/docker/rootfs/etc/services.d/jsmpeg/run b/docker/rootfs/etc/services.d/jsmpeg/run new file mode 100644 index 000000000..b47110b81 --- /dev/null +++ b/docker/rootfs/etc/services.d/jsmpeg/run @@ -0,0 +1,2 @@ +#!/usr/bin/execlineb -P +/usr/local/bin/node /opt/frigate/jsmpeg/relay.js 8081 8082 \ No newline at end of file diff --git a/docker/rootfs/etc/services.d/nginx/finish b/docker/rootfs/etc/services.d/nginx/finish new file mode 100644 index 000000000..24482e77f --- /dev/null +++ b/docker/rootfs/etc/services.d/nginx/finish @@ -0,0 +1,5 @@ +#!/usr/bin/execlineb -S1 +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services \ No newline at end of file diff --git a/docker/rootfs/etc/services.d/nginx/run b/docker/rootfs/etc/services.d/nginx/run new file mode 100644 index 000000000..5aba51c91 --- /dev/null +++ b/docker/rootfs/etc/services.d/nginx/run @@ -0,0 +1,2 @@ +#!/usr/bin/execlineb -P +/usr/local/nginx/sbin/nginx \ No newline at end of file diff --git a/nginx/nginx.conf b/docker/rootfs/usr/local/nginx/conf/nginx.conf similarity index 99% rename from nginx/nginx.conf rename to docker/rootfs/usr/local/nginx/conf/nginx.conf index 689d081a0..3c5ccec3c 100644 --- a/nginx/nginx.conf +++ b/docker/rootfs/usr/local/nginx/conf/nginx.conf @@ -1,3 +1,4 @@ +daemon off; worker_processes 1; error_log /usr/local/nginx/logs/error.log warn; diff --git a/run.sh b/run.sh deleted file mode 100644 index 6387d421c..000000000 --- a/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -/usr/local/nginx/sbin/nginx -exec python3 -u -m frigate \ No newline at end of file