diff --git a/docker/Dockerfile.common b/docker/Dockerfile.common index 7498d76ec..4772ce50a 100644 --- a/docker/Dockerfile.common +++ b/docker/Dockerfile.common @@ -1,56 +1,35 @@ -ARG BASE="16-bullseye" -FROM node:${BASE} +################################################################ +# THIS FILE IS GENERATED. DO NOT EDIT. +################################################################ +################################################################ +# Begin section generated from template/Dockerfile.common.header +# This common file will be used by both Docker and the linux +# install script. +################################################################ +FROM buildpack-deps:bullseye as common -### BEGIN S6 OVERLAY -### S6 overlay and ENTRYPOINT directive must be before everything else. -### The ENTRYPOINT directive signals the install-scrypted-dependencies-linux.sh -### script to start running. +# switch to nvm? +ARG NODE_VERSION=16 +RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - +RUN apt-get update +RUN apt-get install -y nodejs -# avahi advertiser support -RUN apt-get -y install \ - libnss-mdns \ - avahi-discover \ - libavahi-compat-libdnssd-dev - -# copy configurations and scripts -COPY fs / - -# s6 process supervisor -ARG S6_OVERLAY_VERSION=3.1.1.2 -ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 -RUN case "$(uname -m)" in \ - x86_64) S6_ARCH='x86_64';; \ - armv7l) S6_ARCH='armhf';; \ - aarch64) S6_ARCH='aarch64';; \ - *) echo "Your system architecture isn't supported."; exit 1 ;; \ - esac \ - && cd /tmp \ - && set -x \ - && curl -SLOf https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz \ - && tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \ - && curl -SLOf https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz \ - && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz - -ENTRYPOINT ["/init"] -### END S6 OVERLAY - - -# Coral Edge TPU sources.list +# Coral Edge TPU # https://coral.ai/docs/accelerator/get-started/#runtime-on-linux RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - - RUN apt-get -y update -RUN apt-get -y upgrade +RUN apt-get -y install libedgetpu1-std + RUN apt-get -y install software-properties-common apt-utils RUN apt-get -y update +RUN apt-get -y upgrade # base development stuff RUN apt-get -y install \ build-essential \ gcc \ gir1.2-gtk-3.0 \ - libavahi-compat-libdnssd-dev \ libcairo2-dev \ libgirepository1.0-dev \ libglib2.0-dev \ @@ -80,10 +59,6 @@ RUN apt-get -y install \ python3-skimage \ python3-wheel -# Coral Edge TPU -RUN apt-get -y install \ - libedgetpu1-std - # python pip RUN python3 -m pip install --upgrade pip RUN python3 -m pip install aiofiles debugpy typing_extensions typing @@ -92,3 +67,42 @@ ENV SCRYPTED_DOCKER_SERVE="true" ENV SCRYPTED_CAN_RESTART="true" ENV SCRYPTED_VOLUME="/server/volume" ENV SCRYPTED_INSTALL_PATH="/server" + +################################################################ +# End section generated from template/Dockerfile.common.header +################################################################ +################################################################ +# Begin section generated from template/Dockerfile.common.footer +################################################################ +FROM common + +# avahi advertiser support +RUN apt-get -y install \ + libnss-mdns \ + avahi-discover \ + libavahi-compat-libdnssd-dev + +# copy configurations and scripts +COPY fs / + +# s6 process supervisor +ARG S6_OVERLAY_VERSION=3.1.1.2 +ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 +RUN case "$(uname -m)" in \ + x86_64) S6_ARCH='x86_64';; \ + armv7l) S6_ARCH='armhf';; \ + aarch64) S6_ARCH='aarch64';; \ + *) echo "Your system architecture isn't supported."; exit 1 ;; \ + esac \ + && cd /tmp \ + && set -x \ + && curl -SLOf https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz \ + && tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \ + && curl -SLOf https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz \ + && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz + +ENTRYPOINT ["/init"] + +################################################################ +# End section generated from template/Dockerfile.common.footer +################################################################ diff --git a/docker/docker-build-local.sh b/docker/docker-build-local.sh index 646af2751..b0613c49c 100755 --- a/docker/docker-build-local.sh +++ b/docker/docker-build-local.sh @@ -1,2 +1,4 @@ +./template/generate-dockerfile.sh + docker build -t koush/scrypted-common -f Dockerfile.common . && \ docker build -t koush/scrypted -f Dockerfile.local . diff --git a/docker/docker-build.sh b/docker/docker-build.sh index df29ee47f..9b3cb133f 100755 --- a/docker/docker-build.sh +++ b/docker/docker-build.sh @@ -1,2 +1,4 @@ +./template/generate-dockerfile.sh + docker build -t koush/scrypted-common:16-bullseye -f Dockerfile.common --build-arg BASE=16-bullseye . && \ docker build -t koush/scrypted:16-bullseye -f Dockerfile --build-arg BASE=16-bullseye . diff --git a/docker/docker-buildx.sh b/docker/docker-buildx.sh index 51b53a930..43b8803b7 100755 --- a/docker/docker-buildx.sh +++ b/docker/docker-buildx.sh @@ -1,7 +1,7 @@ +./template/generate-dockerfile.sh # docker buildx create --name mybuild # docker buildx use mybuild docker buildx build -f Dockerfile.opencv --tag koush/node-opencv:16 --platform linux/amd64,linux/arm64,linux/armhf . docker buildx build -f Dockerfile.common --tag koush/scrypted-common:16 --platform linux/amd64,linux/arm64,linux/armhf . docker buildx build -f Dockerfile --tag koush/scrypted:16 --platform linux/amd64,linux/arm64,linux/armhf . - diff --git a/docker/install-scrypted-dependencies-linux.sh b/docker/install-scrypted-dependencies-linux.sh index f880007c1..c7db7deb3 100755 --- a/docker/install-scrypted-dependencies-linux.sh +++ b/docker/install-scrypted-dependencies-linux.sh @@ -12,11 +12,6 @@ systemctl stop scrypted.service # bad hack to run a dockerfile like a shell script. RUN() { - if [ -z "$ALLOW_RUN" ] - then - return - fi - # echo "Running: $@" $@ if [ $? -ne 0 ] @@ -37,21 +32,19 @@ COPY() { } FROM() { - echo 'Installing nodejs repo' - RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - - RUN apt-get update - RUN apt-get install -y nodejs + echo "ignoring FROM $1" } +# process ARG for script variables but ignore ENV ARG() { - echo "ignoring ARG $1" + $@ } ENV() { echo "ignoring ENV $1" } -source <(curl -s https://raw.githubusercontent.com/koush/scrypted/avahi/docker/Dockerfile.common) +source <(curl -s https://raw.githubusercontent.com/koush/scrypted/avahi/docker/template/Dockerfile.common.header) if [ -z "$SERVICE_USER" ] then diff --git a/docker/template/Dockerfile.common.footer b/docker/template/Dockerfile.common.footer new file mode 100644 index 000000000..630c4cca6 --- /dev/null +++ b/docker/template/Dockerfile.common.footer @@ -0,0 +1,35 @@ +################################################################ +# Begin section generated from template/Dockerfile.common.footer +################################################################ +FROM common + +# avahi advertiser support +RUN apt-get -y install \ + libnss-mdns \ + avahi-discover \ + libavahi-compat-libdnssd-dev + +# copy configurations and scripts +COPY fs / + +# s6 process supervisor +ARG S6_OVERLAY_VERSION=3.1.1.2 +ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 +RUN case "$(uname -m)" in \ + x86_64) S6_ARCH='x86_64';; \ + armv7l) S6_ARCH='armhf';; \ + aarch64) S6_ARCH='aarch64';; \ + *) echo "Your system architecture isn't supported."; exit 1 ;; \ + esac \ + && cd /tmp \ + && set -x \ + && curl -SLOf https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz \ + && tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \ + && curl -SLOf https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz \ + && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz + +ENTRYPOINT ["/init"] + +################################################################ +# End section generated from template/Dockerfile.common.footer +################################################################ diff --git a/docker/template/Dockerfile.common.header b/docker/template/Dockerfile.common.header new file mode 100644 index 000000000..c80a946c4 --- /dev/null +++ b/docker/template/Dockerfile.common.header @@ -0,0 +1,70 @@ +################################################################ +# Begin section generated from template/Dockerfile.common.header +# This common file will be used by both Docker and the linux +# install script. +################################################################ +FROM buildpack-deps:bullseye as common + +# switch to nvm? +ARG NODE_VERSION=16 +RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - +RUN apt-get update +RUN apt-get install -y nodejs + +# Coral Edge TPU +# https://coral.ai/docs/accelerator/get-started/#runtime-on-linux +RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - +RUN apt-get -y update +RUN apt-get -y install libedgetpu1-std + +RUN apt-get -y install software-properties-common apt-utils +RUN apt-get -y update +RUN apt-get -y upgrade + +# base development stuff +RUN apt-get -y install \ + build-essential \ + gcc \ + gir1.2-gtk-3.0 \ + libcairo2-dev \ + libgirepository1.0-dev \ + libglib2.0-dev \ + libjpeg-dev \ + libgif-dev \ + libopenjp2-7 \ + libpango1.0-dev \ + librsvg2-dev \ + pkg-config + +# gstreamer native https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c#install-gstreamer-on-ubuntu-or-debian +RUN apt-get -y install \ + gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-alsa + +# python native +RUN apt-get -y install \ + python3 \ + python3-dev \ + python3-gi \ + python3-gst-1.0 \ + python3-matplotlib \ + python3-numpy \ + python3-opencv \ + python3-pil \ + python3-pip \ + python3-setuptools \ + python3-skimage \ + python3-wheel + +# python pip +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install aiofiles debugpy typing_extensions typing + +ENV SCRYPTED_DOCKER_SERVE="true" +ENV SCRYPTED_CAN_RESTART="true" +ENV SCRYPTED_VOLUME="/server/volume" +ENV SCRYPTED_INSTALL_PATH="/server" + +################################################################ +# End section generated from template/Dockerfile.common.header +################################################################ diff --git a/docker/template/generate-dockerfile.sh b/docker/template/generate-dockerfile.sh new file mode 100755 index 000000000..cd34315de --- /dev/null +++ b/docker/template/generate-dockerfile.sh @@ -0,0 +1,2 @@ +cd $(dirname $0) +cat warning.sh Dockerfile.common.header Dockerfile.common.footer > ../Dockerfile.common diff --git a/docker/template/warning.sh b/docker/template/warning.sh new file mode 100644 index 000000000..6dfbe07b4 --- /dev/null +++ b/docker/template/warning.sh @@ -0,0 +1,3 @@ +################################################################ +# THIS FILE IS GENERATED. DO NOT EDIT. +################################################################