From e3838c5651b1e4fd698bf4f548eabda50d809efc Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Fri, 10 May 2024 22:22:07 -0500 Subject: [PATCH 01/45] add compose build --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index b71faba6..717f988f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,7 @@ -version: '3.8' services: wire-pod: hostname: escapepod + build: . image: ghcr.io/kercre123/wire-pod:main restart: unless-stopped ports: From c2051b06d795ad95e8435da79927cffc817d92d4 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sat, 11 May 2024 12:21:44 -0500 Subject: [PATCH 02/45] try sharing root netns for mDNS --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index 717f988f..e7e4c598 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,6 +2,7 @@ services: wire-pod: hostname: escapepod build: . + network_mode: host image: ghcr.io/kercre123/wire-pod:main restart: unless-stopped ports: From 41b12969f15787014e303b14d77feae52597239c Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 11:11:40 -0500 Subject: [PATCH 03/45] explicit platform - likely isn't needed --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index e7e4c598..a7764c6f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,6 +3,7 @@ services: hostname: escapepod build: . network_mode: host + platform: linux/arm64 image: ghcr.io/kercre123/wire-pod:main restart: unless-stopped ports: From 50db1adc83003823491844716e2ce08b18ab485b Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 11:14:22 -0500 Subject: [PATCH 04/45] fix readability of indent --- chipper/start.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chipper/start.sh b/chipper/start.sh index b97a3027..3c4180f9 100755 --- a/chipper/start.sh +++ b/chipper/start.sh @@ -41,25 +41,25 @@ if [[ ${STT_SERVICE} == "leopard" ]]; then else /usr/local/go/bin/go run -tags $GOTAGS cmd/leopard/main.go fi - elif [[ ${STT_SERVICE} == "rhino" ]]; then +elif [[ ${STT_SERVICE} == "rhino" ]]; then if [[ -f ./chipper ]]; then ./chipper else /usr/local/go/bin/go run -tags $GOTAGS cmd/experimental/rhino/main.go fi - elif [[ ${STT_SERVICE} == "houndify" ]]; then +elif [[ ${STT_SERVICE} == "houndify" ]]; then if [[ -f ./chipper ]]; then ./chipper else /usr/local/go/bin/go run -tags $GOTAGS cmd/experimental/houndify/main.go fi - elif [[ ${STT_SERVICE} == "whisper" ]]; then +elif [[ ${STT_SERVICE} == "whisper" ]]; then if [[ -f ./chipper ]]; then ./chipper else /usr/local/go/bin/go run -tags $GOTAGS cmd/experimental/whisper/main.go fi - elif [[ ${STT_SERVICE} == "whisper.cpp" ]]; then +elif [[ ${STT_SERVICE} == "whisper.cpp" ]]; then if [[ -f ./chipper ]]; then export C_INCLUDE_PATH="../whisper.cpp" export LIBRARY_PATH="../whisper.cpp" @@ -80,7 +80,7 @@ if [[ ${STT_SERVICE} == "leopard" ]]; then /usr/local/go/bin/go run -tags $GOTAGS cmd/experimental/whisper.cpp/main.go fi fi - elif [[ ${STT_SERVICE} == "vosk" ]]; then +elif [[ ${STT_SERVICE} == "vosk" ]]; then if [[ -f ./chipper ]]; then export CGO_ENABLED=1 export CGO_CFLAGS="-I/root/.vosk/libvosk" From 587c255a87314da9a461baf5d82f68eb95a7f840 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 11:18:25 -0500 Subject: [PATCH 05/45] indent --- setup.sh | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/setup.sh b/setup.sh index bacdf295..17447e18 100755 --- a/setup.sh +++ b/setup.sh @@ -26,13 +26,13 @@ if [[ ${UNAME} == *"Darwin"* ]]; then echo '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' exit 1 fi - elif [[ -f /usr/bin/apt ]]; then +elif [[ -f /usr/bin/apt ]]; then TARGET="debian" echo "Debian-based Linux detected." - elif [[ -f /usr/bin/pacman ]]; then +elif [[ -f /usr/bin/pacman ]]; then TARGET="arch" echo "Arch Linux detected." - elif [[ -f /usr/bin/dnf ]]; then +elif [[ -f /usr/bin/dnf ]]; then TARGET="fedora" echo "Fedora/openSUSE detected." else @@ -47,10 +47,10 @@ fi if [[ "${UNAME}" == *"x86_64"* ]]; then ARCH="x86_64" echo "amd64 architecture confirmed." - elif [[ "${UNAME}" == *"aarch64"* ]] || [[ "${UNAME}" == *"arm64"* ]]; then +elif [[ "${UNAME}" == *"aarch64"* ]] || [[ "${UNAME}" == *"arm64"* ]]; then ARCH="aarch64" echo "aarch64 architecture confirmed." - elif [[ "${UNAME}" == *"armv7l"* ]]; then +elif [[ "${UNAME}" == *"armv7l"* ]]; then ARCH="armv7l" echo "armv7l (32-bit) WARN: The Coqui and VOSK bindings are broken for this platform at the moment, so please choose Picovoice when the script asks. wire-pod is designed for 64-bit systems." STT="" @@ -91,13 +91,13 @@ function getPackages() { if [[ ${TARGET} == "debian" ]]; then apt update -y apt install -y wget openssl net-tools libsox-dev libopus-dev make iproute2 xz-utils libopusfile-dev pkg-config gcc curl g++ unzip avahi-daemon git libasound2-dev libsodium-dev - elif [[ ${TARGET} == "arch" ]]; then + elif [[ ${TARGET} == "arch" ]]; then pacman -Sy --noconfirm sudo pacman -S --noconfirm wget openssl net-tools sox opus make iproute2 opusfile curl unzip avahi git libsodium go pkg-config - elif [[ ${TARGET} == "fedora" ]]; then + elif [[ ${TARGET} == "fedora" ]]; then dnf update dnf install -y wget openssl net-tools sox opus make opusfile curl unzip avahi git libsodium-devel - elif [[ ${TARGET} == "darwin" ]]; then + elif [[ ${TARGET} == "darwin" ]]; then sudo -u $SUDO_USER brew update sudo -u $SUDO_USER brew install wget pkg-config opus opusfile fi @@ -111,10 +111,10 @@ function getPackages() { if [[ ${ARCH} == "x86_64" ]]; then wget -q --show-progress --no-check-certificate https://go.dev/dl/go1.19.4.linux-amd64.tar.gz rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz - elif [[ ${ARCH} == "aarch64" ]]; then + elif [[ ${ARCH} == "aarch64" ]]; then wget -q --show-progress --no-check-certificate https://go.dev/dl/go1.19.4.linux-arm64.tar.gz rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-arm64.tar.gz - elif [[ ${ARCH} == "armv7l" ]]; then + elif [[ ${ARCH} == "armv7l" ]]; then wget -q --show-progress --no-check-certificate https://go.dev/dl/go1.19.4.linux-armv6l.tar.gz rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-armv6l.tar.gz fi @@ -146,18 +146,18 @@ function getSTT() { read -p "Enter a number (3): " sttServiceNum if [[ ! -n ${sttServiceNum} ]]; then sttService="vosk" - elif [[ ${sttServiceNum} == "1" ]]; then + elif [[ ${sttServiceNum} == "1" ]]; then if [[ ${TARGET} == "darwin" ]]; then echo "Coqui is not supported for macOS. Please select another option." sttServicePrompt else sttService="coqui" fi - elif [[ ${sttServiceNum} == "2" ]]; then + elif [[ ${sttServiceNum} == "2" ]]; then sttService="leopard" - elif [[ ${sttServiceNum} == "3" ]]; then + elif [[ ${sttServiceNum} == "3" ]]; then sttService="vosk" - elif [[ ${sttServiceNum} == "4" ]]; then + elif [[ ${sttServiceNum} == "4" ]]; then sttService="whisper" else echo @@ -187,7 +187,7 @@ function getSTT() { echo "export STT_SERVICE=leopard" >> ./chipper/source.sh echo "export PICOVOICE_APIKEY=${picoKey}" >> ./chipper/source.sh echo "export PICOVOICE_APIKEY=${picoKey}" > ./chipper/pico.key - elif [[ ${sttService} == "vosk" ]]; then + elif [[ ${sttService} == "vosk" ]]; then echo "export STT_SERVICE=vosk" >> ./chipper/source.sh origDir="$(pwd)" if [[ ! -f ./vosk/completed ]]; then @@ -199,11 +199,11 @@ function getSTT() { if [[ ${TARGET} == "darwin" ]]; then VOSK_VER="0.3.42" VOSK_DIR="vosk-osx-${VOSK_VER}" - elif [[ ${ARCH} == "x86_64" ]]; then + elif [[ ${ARCH} == "x86_64" ]]; then VOSK_DIR="vosk-linux-x86_64-${VOSK_VER}" - elif [[ ${ARCH} == "aarch64" ]]; then + elif [[ ${ARCH} == "aarch64" ]]; then VOSK_DIR="vosk-linux-aarch64-${VOSK_VER}" - elif [[ ${ARCH} == "armv7l" ]]; then + elif [[ ${ARCH} == "armv7l" ]]; then VOSK_DIR="vosk-linux-armv7l-${VOSK_VER}" fi VOSK_ARCHIVE="$VOSK_DIR.zip" @@ -222,7 +222,7 @@ function getSTT() { /usr/local/go/bin/go install github.com/kercre123/vosk-api/go cd ${origDir} fi - elif [[ ${sttService} == "whisper" ]]; then + elif [[ ${sttService} == "whisper" ]]; then echo "export STT_SERVICE=whisper.cpp" >> ./chipper/source.sh origDir="$(pwd)" echo "Getting Whisper assets" @@ -276,11 +276,11 @@ function getSTT() { fi tar -xf native_client.tflite.Linux.tar.xz rm -f ./native_client.tflite.Linux.tar.xz - elif [[ ${ARCH} == "aarch64" ]]; then + elif [[ ${ARCH} == "aarch64" ]]; then wget -q --show-progress --no-check-certificate https://github.com/coqui-ai/STT/releases/download/v1.3.0/native_client.tflite.linux.aarch64.tar.xz tar -xf native_client.tflite.linux.aarch64.tar.xz rm -f ./native_client.tflite.linux.aarch64.tar.xz - elif [[ ${ARCH} == "armv7l" ]]; then + elif [[ ${ARCH} == "armv7l" ]]; then wget -q --show-progress --no-check-certificate https://github.com/coqui-ai/STT/releases/download/v1.3.0/native_client.tflite.linux.armv7.tar.xz tar -xf native_client.tflite.linux.armv7.tar.xz rm -f ./native_client.tflite.linux.armv7.tar.xz @@ -304,9 +304,9 @@ function getSTT() { read -p "Enter a number (1): " sttModelNum if [[ ! -n ${sttModelNum} ]]; then sttModel="large_vocabulary" - elif [[ ${sttModelNum} == "1" ]]; then + elif [[ ${sttModelNum} == "1" ]]; then sttModel="large_vocabulary" - elif [[ ${sttModelNum} == "2" ]]; then + elif [[ ${sttModelNum} == "2" ]]; then sttModel="huge_vocabulary" else echo @@ -323,7 +323,7 @@ function getSTT() { wget -O model.tflite -q --show-progress --no-check-certificate https://coqui.gateway.scarf.sh/english/coqui/v1.0.0-large-vocab/model.tflite echo "Getting STT scorer..." wget -O model.scorer -q --show-progress --no-check-certificate https://coqui.gateway.scarf.sh/english/coqui/v1.0.0-large-vocab/large_vocabulary.scorer - elif [[ ${sttModel} == "huge_vocabulary" ]]; then + elif [[ ${sttModel} == "huge_vocabulary" ]]; then echo "Getting STT model..." wget -O model.tflite -q --show-progress --no-check-certificate https://coqui.gateway.scarf.sh/english/coqui/v1.0.0-huge-vocab/model.tflite echo "Getting STT scorer..." @@ -565,14 +565,14 @@ function setupSystemd() { if [[ ${STT_SERVICE} == "leopard" ]]; then echo "wire-pod.service created, building chipper with Picovoice STT service..." /usr/local/go/bin/go build -tags $GOTAGS cmd/leopard/main.go - elif [[ ${STT_SERVICE} == "vosk" ]]; then + elif [[ ${STT_SERVICE} == "vosk" ]]; then echo "wire-pod.service created, building chipper with VOSK STT service..." export CGO_ENABLED=1 export CGO_CFLAGS="-I/root/.vosk/libvosk" export CGO_LDFLAGS="-L /root/.vosk/libvosk -lvosk -ldl -lpthread" export LD_LIBRARY_PATH="/root/.vosk/libvosk:$LD_LIBRARY_PATH" /usr/local/go/bin/go build -tags $GOTAGS cmd/vosk/main.go - elif [[ ${STT_SERVICE} == "whisper.cpp" ]]; then + elif [[ ${STT_SERVICE} == "whisper.cpp" ]]; then echo "wire-pod.service created, building chipper with Whisper.CPP STT service..." export CGO_ENABLED=1 export C_INCLUDE_PATH="../whisper.cpp" From 4beed324f39935498ff275bc6e8c3caab0b2fb1d Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 11:25:53 -0500 Subject: [PATCH 06/45] notes --- compose.yaml | 2 +- dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index a7764c6f..35d104c3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,7 +2,7 @@ services: wire-pod: hostname: escapepod build: . - network_mode: host + network_mode: host # b/c mDNS escapepod.local broadcast... why use mDNS? people hosting a custom vector "server" are clearly capable of setting up a DNS record... platform: linux/arm64 image: ghcr.io/kercre123/wire-pod:main restart: unless-stopped diff --git a/dockerfile b/dockerfile index 7acf92fa..3ab9b651 100644 --- a/dockerfile +++ b/dockerfile @@ -3,6 +3,7 @@ FROM ubuntu COPY . . +# TODO move some or all package installs before copying code RUN chmod +x /setup.sh && apt-get update && apt-get install -y dos2unix && dos2unix /setup.sh && apt-get install -y avahi-daemon avahi-autoipd RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] From f92430b272849b53629cd6c279a917beda09feb2 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 12:27:46 -0500 Subject: [PATCH 07/45] split out installing base packages so we don't repeat it on every source change --- dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index 3ab9b651..5f583fcc 100644 --- a/dockerfile +++ b/dockerfile @@ -1,10 +1,13 @@ FROM ubuntu +# install packages before copying in source so we don't do this on every source change +RUN apt-get update && \ + apt-get install -y dos2unix avahi-daemon avahi-autoipd + COPY . . -# TODO move some or all package installs before copying code -RUN chmod +x /setup.sh && apt-get update && apt-get install -y dos2unix && dos2unix /setup.sh && apt-get install -y avahi-daemon avahi-autoipd +RUN chmod +x /setup.sh && apt-get update && dos2unix /setup.sh RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] From 008ab51d6e208ad8479c21b1d7b2f1a552b83110 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 12:35:55 -0500 Subject: [PATCH 08/45] already chmod'd --- dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index 5f583fcc..e6aa137c 100644 --- a/dockerfile +++ b/dockerfile @@ -7,10 +7,10 @@ RUN apt-get update && \ COPY . . -RUN chmod +x /setup.sh && apt-get update && dos2unix /setup.sh +RUN apt-get update && dos2unix /setup.sh RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] -RUN chmod +x /chipper/start.sh && dos2unix /chipper/start.sh +RUN dos2unix /chipper/start.sh CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 5649ea3a133b7aaff6d0500557600a2f23be1476 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 12:38:12 -0500 Subject: [PATCH 09/45] stock dockerignore to speed up builds and not trigger rebuild on say a Dockerfile change - todo assess if anything ignored is still needed, this is a docker init default dockerignore --- .dockerignore | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9eec0f8a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,36 @@ +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/go/build-context-dockerignore/ +# +# TODO assess if anything that is ignored here needs to be removed... this is from `docker init` and select general type + +**/.DS_Store +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose.y*ml +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md From 59746dffcb684b9bbacb4567a0e9f7e97261dea5 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:40:13 -0500 Subject: [PATCH 10/45] try rearrange to just copy in setup.sh, so we don't re-run setup every time we change anything in our code --- dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dockerfile b/dockerfile index e6aa137c..0134e0e1 100644 --- a/dockerfile +++ b/dockerfile @@ -5,12 +5,14 @@ FROM ubuntu RUN apt-get update && \ apt-get install -y dos2unix avahi-daemon avahi-autoipd -COPY . . - -RUN apt-get update && dos2unix /setup.sh - +# setup.sh is standalone (IIUC upon cursory inspection) at least for debian/aarch64 + vosk purposes +COPY setup.sh /setup.sh +RUN dos2unix /setup.sh RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] +# TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) +COPY . . + RUN dos2unix /chipper/start.sh CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From e783a779ef187f1d2f0e2227dd91ccc15dec01f7 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:41:05 -0500 Subject: [PATCH 11/45] make it look like chipper is present (just the dir though) --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index 0134e0e1..21828832 100644 --- a/dockerfile +++ b/dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && \ # setup.sh is standalone (IIUC upon cursory inspection) at least for debian/aarch64 + vosk purposes COPY setup.sh /setup.sh -RUN dos2unix /setup.sh +RUN dos2unix /setup.sh && mkdir /chipper RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) From 7e6408e72afd32b438b7c8582604498899e391f4 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:42:42 -0500 Subject: [PATCH 12/45] notes --- dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index 21828832..7f6c22ae 100644 --- a/dockerfile +++ b/dockerfile @@ -1,14 +1,17 @@ FROM ubuntu +# *** PACKAGE INSTALLS *** # install packages before copying in source so we don't do this on every source change RUN apt-get update && \ apt-get install -y dos2unix avahi-daemon avahi-autoipd - +# # setup.sh is standalone (IIUC upon cursory inspection) at least for debian/aarch64 + vosk purposes +# setup.sh is more or less further `apt install...` + some file setup (i.e. chipper/source.sh)... thus run this as early as possible as it is not likely to change (as much) as the source code COPY setup.sh /setup.sh RUN dos2unix /setup.sh && mkdir /chipper RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] +# *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) COPY . . From 06aa6978eaf0b05bc524d0f045ceb8cd10cf604f Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:44:28 -0500 Subject: [PATCH 13/45] fix --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index 7f6c22ae..a0318e46 100644 --- a/dockerfile +++ b/dockerfile @@ -9,7 +9,7 @@ RUN apt-get update && \ # setup.sh is standalone (IIUC upon cursory inspection) at least for debian/aarch64 + vosk purposes # setup.sh is more or less further `apt install...` + some file setup (i.e. chipper/source.sh)... thus run this as early as possible as it is not likely to change (as much) as the source code COPY setup.sh /setup.sh -RUN dos2unix /setup.sh && mkdir /chipper +RUN dos2unix /setup.sh && mkdir /chipper && mkdir /vector-cloud RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] # *** END PACKAGE INSTALLS *** From 7fbac38194c52cf42c2a7cb3b0151ebb0d6a11f0 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:45:34 -0500 Subject: [PATCH 14/45] notes --- dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfile b/dockerfile index a0318e46..c0793f7d 100644 --- a/dockerfile +++ b/dockerfile @@ -16,6 +16,7 @@ RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) COPY . . +# TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too RUN dos2unix /chipper/start.sh CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 7b93b980f930d4b4274e4f7ecdecee28a1e12e59 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:46:35 -0500 Subject: [PATCH 15/45] notes --- dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfile b/dockerfile index c0793f7d..1345bd34 100644 --- a/dockerfile +++ b/dockerfile @@ -9,6 +9,7 @@ RUN apt-get update && \ # setup.sh is standalone (IIUC upon cursory inspection) at least for debian/aarch64 + vosk purposes # setup.sh is more or less further `apt install...` + some file setup (i.e. chipper/source.sh)... thus run this as early as possible as it is not likely to change (as much) as the source code COPY setup.sh /setup.sh +# PRN part of what setup.sh does is to install golang and other deps... why not extract those deps here for the Dockerfile and not use setup.sh inside the container build? AND why not find a golang base image to build on top of instead of installing it here? RUN dos2unix /setup.sh && mkdir /chipper && mkdir /vector-cloud RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] # *** END PACKAGE INSTALLS *** From cea58c946c1543ca085514e6bab9a33d131763b6 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:46:49 -0500 Subject: [PATCH 16/45] notes --- .dockerignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 9eec0f8a..12b3f1b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ # For more help, visit the .dockerignore file reference guide at # https://docs.docker.com/go/build-context-dockerignore/ # -# TODO assess if anything that is ignored here needs to be removed... this is from `docker init` and select general type **/.DS_Store **/__pycache__ From 1add7ffe66712e7a5b5347ba53acaf1383e2eff3 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 14:55:36 -0500 Subject: [PATCH 17/45] detect container build and split up steps so when smth goes wrong we don't wait 5 minutes to try again --- dockerfile | 4 ++-- setup.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index 1345bd34..c6917112 100644 --- a/dockerfile +++ b/dockerfile @@ -7,11 +7,11 @@ RUN apt-get update && \ apt-get install -y dos2unix avahi-daemon avahi-autoipd # # setup.sh is standalone (IIUC upon cursory inspection) at least for debian/aarch64 + vosk purposes -# setup.sh is more or less further `apt install...` + some file setup (i.e. chipper/source.sh)... thus run this as early as possible as it is not likely to change (as much) as the source code +# setup.sh is more or less further `apt install...` + golang install + vosk install + gen chipper/source.sh... thus run this as early as possible as it is not likely to change (as much) as the source code COPY setup.sh /setup.sh # PRN part of what setup.sh does is to install golang and other deps... why not extract those deps here for the Dockerfile and not use setup.sh inside the container build? AND why not find a golang base image to build on top of instead of installing it here? RUN dos2unix /setup.sh && mkdir /chipper && mkdir /vector-cloud -RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"] +RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true ./setup.sh"] # *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) diff --git a/setup.sh b/setup.sh index 17447e18..e44b6667 100755 --- a/setup.sh +++ b/setup.sh @@ -651,6 +651,15 @@ if [[ $1 == "-f" ]] && [[ $2 == "scp" ]]; then exit 0 fi +# TODO container detect and break up stages so we can avoid re-run everything? + +# check IMAGE_BUILD env var is set to determine if building image +if [[ -n "${IMAGE_BUILD}" ]]; then + echo "Detected container build env..." + exit 1 +fi + + # echo "What would you like to do?" # echo "1: Full Setup (recommended) (builds chipper, gets STT stuff, generates certs, creates source.sh file, and creates server_config.json for your bot" # echo "2: Just build vic-cloud" From 49889137bb65842cb6f26742bc1db854e3c385ab Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 15:02:09 -0500 Subject: [PATCH 18/45] inline the default path that a container build would use --- setup.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index e44b6667..f2e76d1b 100755 --- a/setup.sh +++ b/setup.sh @@ -651,11 +651,14 @@ if [[ $1 == "-f" ]] && [[ $2 == "scp" ]]; then exit 0 fi -# TODO container detect and break up stages so we can avoid re-run everything? - -# check IMAGE_BUILD env var is set to determine if building image if [[ -n "${IMAGE_BUILD}" ]]; then echo "Detected container build env..." + # break up stages so we can avoid re-run everything? + echo + getPackages + getSTT + echo + echo "wire-pod is ready to run! You are ready to move to the next step and run sudo ./chipper/start.sh" exit 1 fi From 93795dff593a3c88168da86e92199864de5f149a Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 15:04:00 -0500 Subject: [PATCH 19/45] split up two stages --- dockerfile | 3 ++- setup.sh | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dockerfile b/dockerfile index c6917112..40f5742f 100644 --- a/dockerfile +++ b/dockerfile @@ -11,7 +11,8 @@ RUN apt-get update && \ COPY setup.sh /setup.sh # PRN part of what setup.sh does is to install golang and other deps... why not extract those deps here for the Dockerfile and not use setup.sh inside the container build? AND why not find a golang base image to build on top of instead of installing it here? RUN dos2unix /setup.sh && mkdir /chipper && mkdir /vector-cloud -RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true ./setup.sh"] +RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true BUILD_STAGE=getPackages ./setup.sh"] +RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true BUILD_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) diff --git a/setup.sh b/setup.sh index f2e76d1b..1eac57c5 100755 --- a/setup.sh +++ b/setup.sh @@ -654,15 +654,21 @@ fi if [[ -n "${IMAGE_BUILD}" ]]; then echo "Detected container build env..." # break up stages so we can avoid re-run everything? - echo - getPackages - getSTT - echo - echo "wire-pod is ready to run! You are ready to move to the next step and run sudo ./chipper/start.sh" + # if env var BUILD_STAGE == getPackages + if [[ "${BUILD_STAGE}" == "getPackages" ]]; then + getPackages + exit 0 + fi + # TODO add stage to install golang too and move it to first stage? or use base image with golang already installed + if [[ "${BUILD_STAGE}" == "getSTT" ]]; then + getSTT + echo "wire-pod is ready to run! You are ready to move to the next step and run sudo ./chipper/start.sh" + exit 0 + fi + echo "Please provide a valid BUILD_STAGE env var, the current value is '${BUILD_STAGE}' is not recognized" exit 1 fi - # echo "What would you like to do?" # echo "1: Full Setup (recommended) (builds chipper, gets STT stuff, generates certs, creates source.sh file, and creates server_config.json for your bot" # echo "2: Just build vic-cloud" From aba6bcd8f028ecdb02085fefcb8ec2124fe9ee05 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 15:06:54 -0500 Subject: [PATCH 20/45] rename to SETUP_STAGE --- dockerfile | 4 ++-- setup.sh | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dockerfile b/dockerfile index 40f5742f..697f3284 100644 --- a/dockerfile +++ b/dockerfile @@ -11,8 +11,8 @@ RUN apt-get update && \ COPY setup.sh /setup.sh # PRN part of what setup.sh does is to install golang and other deps... why not extract those deps here for the Dockerfile and not use setup.sh inside the container build? AND why not find a golang base image to build on top of instead of installing it here? RUN dos2unix /setup.sh && mkdir /chipper && mkdir /vector-cloud -RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true BUILD_STAGE=getPackages ./setup.sh"] -RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true BUILD_STAGE=getSTT ./setup.sh"] +RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getPackages ./setup.sh"] +RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) diff --git a/setup.sh b/setup.sh index 1eac57c5..19c4aace 100755 --- a/setup.sh +++ b/setup.sh @@ -653,19 +653,17 @@ fi if [[ -n "${IMAGE_BUILD}" ]]; then echo "Detected container build env..." - # break up stages so we can avoid re-run everything? - # if env var BUILD_STAGE == getPackages - if [[ "${BUILD_STAGE}" == "getPackages" ]]; then + if [[ "${SETUP_STAGE}" == "getPackages" ]]; then getPackages exit 0 fi # TODO add stage to install golang too and move it to first stage? or use base image with golang already installed - if [[ "${BUILD_STAGE}" == "getSTT" ]]; then + if [[ "${SETUP_STAGE}" == "getSTT" ]]; then getSTT - echo "wire-pod is ready to run! You are ready to move to the next step and run sudo ./chipper/start.sh" + echo "wire-pod is ready to run! You are ready to move to the next step and run sudo ./chipper/start.sh" exit 0 fi - echo "Please provide a valid BUILD_STAGE env var, the current value is '${BUILD_STAGE}' is not recognized" + echo "Please provide a valid SETUP_STAGE env var, the current value is '${SETUP_STAGE}' is not recognized" exit 1 fi From aaecfee31bb14eb48d17fb66ffe300896a08033d Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 15:21:11 -0500 Subject: [PATCH 21/45] copy in go.{mod,sum} so we can go get/install for the getSTT setup.sh call --- compose.yaml | 3 ++- dockerfile | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compose.yaml b/compose.yaml index 35d104c3..6089db29 100644 --- a/compose.yaml +++ b/compose.yaml @@ -12,7 +12,8 @@ services: - 80:80 - 8084:8084 volumes: - - wire-pod-data:/chipper/ + # get rid of caching the chipper dir, this should be baked into the image IMHO, and is a problem b/c rebuilding image and copying changes into /chipper is masked by an already UP'd volume mount... + # - wire-pod-data:/chipper/ - wire-pod-model:/vosk/ volumes: wire-pod-data: diff --git a/dockerfile b/dockerfile index 697f3284..3ef61518 100644 --- a/dockerfile +++ b/dockerfile @@ -12,13 +12,17 @@ COPY setup.sh /setup.sh # PRN part of what setup.sh does is to install golang and other deps... why not extract those deps here for the Dockerfile and not use setup.sh inside the container build? AND why not find a golang base image to build on top of instead of installing it here? RUN dos2unix /setup.sh && mkdir /chipper && mkdir /vector-cloud RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getPackages ./setup.sh"] + +# so we can install go deps (IIUC for vosk install in setup.sh/getSTT) +COPY ./chipper/go.sum ./chipper/go.mod /chipper/ +# PRN caching of downloaded modules? RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) -COPY . . +# COPY . . # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too -RUN dos2unix /chipper/start.sh +# RUN dos2unix /chipper/start.sh -CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file +#CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 7e008db32cb656ebf828fbd72c9cec1883b79049 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 15:23:53 -0500 Subject: [PATCH 22/45] put back all files so I can troubleshoot any clobber issues from COPY instruction --- dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dockerfile b/dockerfile index 3ef61518..f87695b1 100644 --- a/dockerfile +++ b/dockerfile @@ -20,9 +20,9 @@ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) -# COPY . . +COPY . . # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too -# RUN dos2unix /chipper/start.sh +RUN dos2unix /chipper/start.sh -#CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file +CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From dbf2f685ce7a1ac0477dfde118a83021429e1fca Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 15:24:10 -0500 Subject: [PATCH 23/45] notes --- dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index f87695b1..62f544a2 100644 --- a/dockerfile +++ b/dockerfile @@ -21,8 +21,9 @@ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) COPY . . - -# TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too RUN dos2unix /chipper/start.sh +# TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too +# TODO step 1 - add go get/install for runtime modules into a last layer +# setup 2 - ascertain if I can move go get/install earlier in the Dockerfile (if that has any benefit) CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 4fb4a25ffde6cea70fd7dabe4e3409c97212750a Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:05:01 -0500 Subject: [PATCH 24/45] don't copy in files we dont need --- .dockerignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.dockerignore b/.dockerignore index 12b3f1b3..f83fcda5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,7 @@ +# manual ignores: +**/.github +**/dockerfile* + # Include any files or directories that you don't want to be copied to your # container here (e.g., local build artifacts, temporary files, etc.). # From 6d70eceac29f45d1eeaf5c90471969e942189700 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:10:55 -0500 Subject: [PATCH 25/45] notes --- dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dockerfile b/dockerfile index 62f544a2..c0d31b72 100644 --- a/dockerfile +++ b/dockerfile @@ -20,6 +20,10 @@ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** # TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) +# TODO can we only copy: +# COPY chipper images / +# IIAC docker doesn't need update.sh (b/c instead just rebuild image, IIAC) +# IIUC vector-cloud isn't part of the server (gh issue mentions possibly removing it - is it part of custom ep firmeware that runs on vector?) COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too From df4cccd91ceef41038564d0919a7c0dada0ee889 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:14:38 -0500 Subject: [PATCH 26/45] notes --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index c0d31b72..e05704f3 100644 --- a/dockerfile +++ b/dockerfile @@ -15,7 +15,7 @@ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getPackages ./setup # so we can install go deps (IIUC for vosk install in setup.sh/getSTT) COPY ./chipper/go.sum ./chipper/go.mod /chipper/ -# PRN caching of downloaded modules? +# FYI setup.sh generates /chipper/source.sh: contains env vars for STT_SERVICE & DEBUG_LOGGING for vosk setup.sh: RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** From bc7904b05c0b93377c8b88289317ce5feb0e32a7 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:16:17 -0500 Subject: [PATCH 27/45] notes --- chipper/start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/chipper/start.sh b/chipper/start.sh index 3c4180f9..94ed7a87 100755 --- a/chipper/start.sh +++ b/chipper/start.sh @@ -25,6 +25,7 @@ if [[ ! -f ./source.sh ]]; then exit 0 fi +# sets env vars: (i.e. STT_SERVICE) source source.sh # set go tags From 14cf9920075911d8ad96c7c6c4f875e0c0fa3cb2 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:16:35 -0500 Subject: [PATCH 28/45] notes --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index e05704f3..30d94f00 100644 --- a/dockerfile +++ b/dockerfile @@ -15,7 +15,7 @@ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getPackages ./setup # so we can install go deps (IIUC for vosk install in setup.sh/getSTT) COPY ./chipper/go.sum ./chipper/go.mod /chipper/ -# FYI setup.sh generates /chipper/source.sh: contains env vars for STT_SERVICE & DEBUG_LOGGING for vosk setup.sh: +# FYI setup.sh generates /chipper/source.sh which sets env vars only RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** From 71260cfb0636f9dd11fcb1efe5d8f749f768ecde Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:20:43 -0500 Subject: [PATCH 29/45] add go build call in a new RUN instruction to pull deps during image build --- chipper/start.sh | 8 +++++++- dockerfile | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chipper/start.sh b/chipper/start.sh index 94ed7a87..683ed5a5 100755 --- a/chipper/start.sh +++ b/chipper/start.sh @@ -93,7 +93,13 @@ elif [[ ${STT_SERVICE} == "vosk" ]]; then export CGO_CFLAGS="-I/root/.vosk/libvosk" export CGO_LDFLAGS="-L /root/.vosk/libvosk -lvosk -ldl -lpthread" export LD_LIBRARY_PATH="/root/.vosk/libvosk:$LD_LIBRARY_PATH" - /usr/local/go/bin/go run -tags $GOTAGS -exec "env DYLD_LIBRARY_PATH=$HOME/.vosk/libvosk" cmd/vosk/main.go + # GO_COMMAND=="build" + if [[ ${GO_COMMAND} == "build" ]]; then + # TLDR to download go deps... can I just run this in the Dockerfile? when I copy in go.mod/sum? + /usr/local/go/bin/go $GO_COMMAND -tags $GOTAGS -o chipper cmd/vosk/main.go + else + /usr/local/go/bin/go $GO_COMMAND -tags $GOTAGS -exec "env DYLD_LIBRARY_PATH=$HOME/.vosk/libvosk" cmd/vosk/main.go + fi fi else if [[ -f ./chipper ]]; then diff --git a/dockerfile b/dockerfile index 30d94f00..e82ca18f 100644 --- a/dockerfile +++ b/dockerfile @@ -30,4 +30,8 @@ RUN dos2unix /chipper/start.sh # TODO step 1 - add go get/install for runtime modules into a last layer # setup 2 - ascertain if I can move go get/install earlier in the Dockerfile (if that has any benefit) -CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file +# go build to pull further go deps: +RUN ["/bin/sh", "-c", "GO_COMMAND=build ./chipper/start.sh"] +# +# runtime: +CMD ["/bin/sh", "-c", "GO_COMMAND=run ./chipper/start.sh"] \ No newline at end of file From 84041899b2a7b0678837b558af877ca593e9f90d Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:32:37 -0500 Subject: [PATCH 30/45] ok now move module download into Dockerfile so I can optimize its placement --- chipper/start.sh | 1 - dockerfile | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chipper/start.sh b/chipper/start.sh index 683ed5a5..276e685b 100755 --- a/chipper/start.sh +++ b/chipper/start.sh @@ -93,7 +93,6 @@ elif [[ ${STT_SERVICE} == "vosk" ]]; then export CGO_CFLAGS="-I/root/.vosk/libvosk" export CGO_LDFLAGS="-L /root/.vosk/libvosk -lvosk -ldl -lpthread" export LD_LIBRARY_PATH="/root/.vosk/libvosk:$LD_LIBRARY_PATH" - # GO_COMMAND=="build" if [[ ${GO_COMMAND} == "build" ]]; then # TLDR to download go deps... can I just run this in the Dockerfile? when I copy in go.mod/sum? /usr/local/go/bin/go $GO_COMMAND -tags $GOTAGS -o chipper cmd/vosk/main.go diff --git a/dockerfile b/dockerfile index e82ca18f..703eb42a 100644 --- a/dockerfile +++ b/dockerfile @@ -31,7 +31,8 @@ RUN dos2unix /chipper/start.sh # TODO step 1 - add go get/install for runtime modules into a last layer # setup 2 - ascertain if I can move go get/install earlier in the Dockerfile (if that has any benefit) # go build to pull further go deps: -RUN ["/bin/sh", "-c", "GO_COMMAND=build ./chipper/start.sh"] +# RUN ["/bin/sh", "-c", "GO_COMMAND=build ./chipper/start.sh"] +RUN cd /chipper && go mod download # # runtime: CMD ["/bin/sh", "-c", "GO_COMMAND=run ./chipper/start.sh"] \ No newline at end of file From 6a4799b104037c0cc220050d04cc1ec1379468b3 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:34:03 -0500 Subject: [PATCH 31/45] put back start.sh the way it was --- chipper/start.sh | 7 +------ dockerfile | 10 +++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/chipper/start.sh b/chipper/start.sh index 276e685b..94ed7a87 100755 --- a/chipper/start.sh +++ b/chipper/start.sh @@ -93,12 +93,7 @@ elif [[ ${STT_SERVICE} == "vosk" ]]; then export CGO_CFLAGS="-I/root/.vosk/libvosk" export CGO_LDFLAGS="-L /root/.vosk/libvosk -lvosk -ldl -lpthread" export LD_LIBRARY_PATH="/root/.vosk/libvosk:$LD_LIBRARY_PATH" - if [[ ${GO_COMMAND} == "build" ]]; then - # TLDR to download go deps... can I just run this in the Dockerfile? when I copy in go.mod/sum? - /usr/local/go/bin/go $GO_COMMAND -tags $GOTAGS -o chipper cmd/vosk/main.go - else - /usr/local/go/bin/go $GO_COMMAND -tags $GOTAGS -exec "env DYLD_LIBRARY_PATH=$HOME/.vosk/libvosk" cmd/vosk/main.go - fi + /usr/local/go/bin/go run -tags $GOTAGS -exec "env DYLD_LIBRARY_PATH=$HOME/.vosk/libvosk" cmd/vosk/main.go fi else if [[ -f ./chipper ]]; then diff --git a/dockerfile b/dockerfile index 703eb42a..2b8c1e82 100644 --- a/dockerfile +++ b/dockerfile @@ -28,11 +28,7 @@ COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too -# TODO step 1 - add go get/install for runtime modules into a last layer -# setup 2 - ascertain if I can move go get/install earlier in the Dockerfile (if that has any benefit) -# go build to pull further go deps: -# RUN ["/bin/sh", "-c", "GO_COMMAND=build ./chipper/start.sh"] +# TODO now look into moving this higher in build (next) RUN cd /chipper && go mod download -# -# runtime: -CMD ["/bin/sh", "-c", "GO_COMMAND=run ./chipper/start.sh"] \ No newline at end of file + +CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From bdd3bd89ca984109baaa4fcb2138f6f7a77cc81d Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:39:03 -0500 Subject: [PATCH 32/45] notes --- dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfile b/dockerfile index 2b8c1e82..5cb41942 100644 --- a/dockerfile +++ b/dockerfile @@ -30,5 +30,6 @@ RUN dos2unix /chipper/start.sh # TODO now look into moving this higher in build (next) RUN cd /chipper && go mod download +# TODO web server initial setup page => after submit settings => downloads vosk model smth? then more go modules are downloaded CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 9878bf910635ab5b562337005206319324db117f Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:40:02 -0500 Subject: [PATCH 33/45] hypothesis about vector cloud --- dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dockerfile b/dockerfile index 5cb41942..f0abe6b4 100644 --- a/dockerfile +++ b/dockerfile @@ -31,5 +31,7 @@ RUN dos2unix /chipper/start.sh # TODO now look into moving this higher in build (next) RUN cd /chipper && go mod download # TODO web server initial setup page => after submit settings => downloads vosk model smth? then more go modules are downloaded +# Are these the vector-cloud deps? +RUN cd /vector-cloud && go mod download CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 86e1321f8ffe521b621ebc568941834753094390 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:43:01 -0500 Subject: [PATCH 34/45] notes --- dockerfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dockerfile b/dockerfile index f0abe6b4..305ff547 100644 --- a/dockerfile +++ b/dockerfile @@ -19,19 +19,14 @@ COPY ./chipper/go.sum ./chipper/go.mod /chipper/ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** -# TODO figure out if anything gets clobbered that was created by setup.sh (i.e. ./chipper/source.sh which is created by setup.sh) -# TODO can we only copy: -# COPY chipper images / -# IIAC docker doesn't need update.sh (b/c instead just rebuild image, IIAC) -# IIUC vector-cloud isn't part of the server (gh issue mentions possibly removing it - is it part of custom ep firmeware that runs on vector?) +# PRN copy specific files only: # COPY chipper images vector-cloud / COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too # TODO now look into moving this higher in build (next) RUN cd /chipper && go mod download -# TODO web server initial setup page => after submit settings => downloads vosk model smth? then more go modules are downloaded -# Are these the vector-cloud deps? +# vector-cloud is setup/installed after initial web server Submit Settings page RUN cd /vector-cloud && go mod download CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 720cd21253c557f06098153ee61a961e68948124 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:47:34 -0500 Subject: [PATCH 35/45] move up go mod downloads to earlier in build before we copy in source code --- dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dockerfile b/dockerfile index 305ff547..2c4ecdd4 100644 --- a/dockerfile +++ b/dockerfile @@ -19,14 +19,18 @@ COPY ./chipper/go.sum ./chipper/go.mod /chipper/ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** +# *** go download deps *** +COPY ./vector-cloud/go.sum ./vector-cloud/go.mod /vector-cloud/ +RUN cd /chipper && go mod download +# vector-cloud deps are normally downloaded after initial web server Submit Settings page: + RUN cd /vector-cloud && go mod download + # PRN IIUC vector-cloud has some vosk model download/setup, can I add it to this image build too? +# *** END go download deps *** + # PRN copy specific files only: # COPY chipper images vector-cloud / COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too -# TODO now look into moving this higher in build (next) -RUN cd /chipper && go mod download -# vector-cloud is setup/installed after initial web server Submit Settings page -RUN cd /vector-cloud && go mod download CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From ef47afe7cd026cb38e689c03bb95a50f0f54576f Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:51:18 -0500 Subject: [PATCH 36/45] notes --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index 2c4ecdd4..63d32ef4 100644 --- a/dockerfile +++ b/dockerfile @@ -32,5 +32,5 @@ COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too - +# TODO go build chipper&vector-cloud - bake into this image (perhaps modify start.sh to do this (sep build param) or just inline go build here) CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 2cfed9315361a704d53455df088ad9715d1d913c Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 16:57:22 -0500 Subject: [PATCH 37/45] notes --- dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index 63d32ef4..6fbd1988 100644 --- a/dockerfile +++ b/dockerfile @@ -20,11 +20,14 @@ RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"] # *** END PACKAGE INSTALLS *** # *** go download deps *** +# +# PRN build + cache deps: # RUN --mount=type=cache,target=/root/go/pkg/mod cd /chipper && go mod download +# COPY ./vector-cloud/go.sum ./vector-cloud/go.mod /vector-cloud/ RUN cd /chipper && go mod download # vector-cloud deps are normally downloaded after initial web server Submit Settings page: - RUN cd /vector-cloud && go mod download - # PRN IIUC vector-cloud has some vosk model download/setup, can I add it to this image build too? +RUN cd /vector-cloud && go mod download +# PRN IIUC vector-cloud has some vosk model download/setup, can I add it to this image build too? # *** END go download deps *** # PRN copy specific files only: # COPY chipper images vector-cloud / From ab5791a2577c361527263c0956e932cfa190b9f5 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:15:04 -0500 Subject: [PATCH 38/45] split out build from run and bake build into image --- chipper/start.sh | 6 +++++- dockerfile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chipper/start.sh b/chipper/start.sh index 94ed7a87..5aee6391 100755 --- a/chipper/start.sh +++ b/chipper/start.sh @@ -93,7 +93,11 @@ elif [[ ${STT_SERVICE} == "vosk" ]]; then export CGO_CFLAGS="-I/root/.vosk/libvosk" export CGO_LDFLAGS="-L /root/.vosk/libvosk -lvosk -ldl -lpthread" export LD_LIBRARY_PATH="/root/.vosk/libvosk:$LD_LIBRARY_PATH" - /usr/local/go/bin/go run -tags $GOTAGS -exec "env DYLD_LIBRARY_PATH=$HOME/.vosk/libvosk" cmd/vosk/main.go + if [[ ${DO_GO_BUILD} == "true" ]]; then + /usr/local/go/bin/go build -tags $GOTAGS -o chipper cmd/vosk/main.go + else + /usr/local/go/bin/go run -tags $GOTAGS -exec "env DYLD_LIBRARY_PATH=$HOME/.vosk/libvosk" cmd/vosk/main.go + fi fi else if [[ -f ./chipper ]]; then diff --git a/dockerfile b/dockerfile index 6fbd1988..34bb7794 100644 --- a/dockerfile +++ b/dockerfile @@ -34,6 +34,6 @@ RUN cd /vector-cloud && go mod download COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too - +RUN ["/bin/sh", "-c", "DO_GO_BUILD=true ./chipper/start.sh"] # TODO go build chipper&vector-cloud - bake into this image (perhaps modify start.sh to do this (sep build param) or just inline go build here) CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 4eb8a77edf7746e7264f97135aa1a3829bfa01cf Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:20:39 -0500 Subject: [PATCH 39/45] notes --- dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index 34bb7794..c36370de 100644 --- a/dockerfile +++ b/dockerfile @@ -34,6 +34,11 @@ RUN cd /vector-cloud && go mod download COPY . . RUN dos2unix /chipper/start.sh # TODO do we really need dos2unix? can't we use editorconfig or something else to enforce line endings? and/or force git checkout to have LF endings always? SAME with setup.sh above too +# +# build chipper during image build: +# reuse start.sh so we keep logic for changing env vars (i.e. for whipser instead of vosk) RUN ["/bin/sh", "-c", "DO_GO_BUILD=true ./chipper/start.sh"] -# TODO go build chipper&vector-cloud - bake into this image (perhaps modify start.sh to do this (sep build param) or just inline go build here) +# PRN build vector-cloud during image build too? +# PRN use multi-stage build - with builder image (w/ cached modules) separate of runtime image (final executables only)? + CMD ["/bin/sh", "-c", "./chipper/start.sh"] \ No newline at end of file From 5bec26bc7b3b7fcb3a0681e2c4ffbfce6ff49929 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:24:14 -0500 Subject: [PATCH 40/45] comment out --- compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 6089db29..79682ec3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -16,7 +16,7 @@ services: # - wire-pod-data:/chipper/ - wire-pod-model:/vosk/ volumes: - wire-pod-data: - driver: local + # wire-pod-data: + # driver: local wire-pod-model: driver: local From 08012eda03351cfb4c2b4d1d8999e7da833f7101 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:28:26 -0500 Subject: [PATCH 41/45] notes --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 79682ec3..a975bfd8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -12,7 +12,7 @@ services: - 80:80 - 8084:8084 volumes: - # get rid of caching the chipper dir, this should be baked into the image IMHO, and is a problem b/c rebuilding image and copying changes into /chipper is masked by an already UP'd volume mount... + # TODO this is a problem to use a volume for /chipper in terms of updates, can we split out just the part that has the database we need to preserve and not cache the codebase? otherwise once created it will never update if image contents change... admittedly the compose file here does not appear designed for the use case of updating at all (neither via a volume nor via the image...?) # - wire-pod-data:/chipper/ - wire-pod-model:/vosk/ volumes: From 1550447654010e6d2a3dd24422d2ff10b01d2773 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:34:18 -0500 Subject: [PATCH 42/45] notes --- compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yaml b/compose.yaml index a975bfd8..d7d2b143 100644 --- a/compose.yaml +++ b/compose.yaml @@ -13,6 +13,7 @@ services: - 8084:8084 volumes: # TODO this is a problem to use a volume for /chipper in terms of updates, can we split out just the part that has the database we need to preserve and not cache the codebase? otherwise once created it will never update if image contents change... admittedly the compose file here does not appear designed for the use case of updating at all (neither via a volume nor via the image...?) + # /root/.anki_vector/* ??? is this the path? if so make a volume for this # - wire-pod-data:/chipper/ - wire-pod-model:/vosk/ volumes: From d66ec45186763a715ad857ed5f42c325b1974cb5 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:43:02 -0500 Subject: [PATCH 43/45] notes while rebuilding server and testing my vector - and it all works\! --- compose.yaml | 10 ++++++++++ dockerfile | 1 + 2 files changed, 11 insertions(+) diff --git a/compose.yaml b/compose.yaml index d7d2b143..27e0c42a 100644 --- a/compose.yaml +++ b/compose.yaml @@ -12,6 +12,16 @@ services: - 80:80 - 8084:8084 volumes: + # FYI after setup new server and join vector to it... diff shows only these changed files: + # $ docker container diff wire-pod-wire-pod-run-b2a5f3d4bf75 + # A /certs + # A /certs/server_config.json + # C /chipper + # A /chipper/apiConfig.json + # C /chipper/jdocs + # A /chipper/jdocs/botSdkInfo.json + # A /chipper/jdocs/jdocs.json + # A /vosk # TODO this is a problem to use a volume for /chipper in terms of updates, can we split out just the part that has the database we need to preserve and not cache the codebase? otherwise once created it will never update if image contents change... admittedly the compose file here does not appear designed for the use case of updating at all (neither via a volume nor via the image...?) # /root/.anki_vector/* ??? is this the path? if so make a volume for this # - wire-pod-data:/chipper/ diff --git a/dockerfile b/dockerfile index c36370de..6326d557 100644 --- a/dockerfile +++ b/dockerfile @@ -28,6 +28,7 @@ RUN cd /chipper && go mod download # vector-cloud deps are normally downloaded after initial web server Submit Settings page: RUN cd /vector-cloud && go mod download # PRN IIUC vector-cloud has some vosk model download/setup, can I add it to this image build too? +# Downloading https://github.com/kercre123/vosk-models/raw/main/vosk-model-small-en-us-0.15.zip to /tmp/vosk-model-small-en-us-0.15.zip # *** END go download deps *** # PRN copy specific files only: # COPY chipper images vector-cloud / From 0c3d6096594da90a52b9b9e5ff18698f2efab57c Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 17:46:01 -0500 Subject: [PATCH 44/45] notes --- compose.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compose.yaml b/compose.yaml index 27e0c42a..21126083 100644 --- a/compose.yaml +++ b/compose.yaml @@ -17,11 +17,11 @@ services: # A /certs # A /certs/server_config.json # C /chipper - # A /chipper/apiConfig.json + # A /chipper/apiConfig.json # stores config for first Submit Settings page (i.e. openai api key, weather api key, etc.) # C /chipper/jdocs - # A /chipper/jdocs/botSdkInfo.json + # A /chipper/jdocs/botSdkInfo.json # stores vector IP, etc # A /chipper/jdocs/jdocs.json - # A /vosk + # A /vosk # vosk model extracted here.. would like to move this into image build too (very early on) # TODO this is a problem to use a volume for /chipper in terms of updates, can we split out just the part that has the database we need to preserve and not cache the codebase? otherwise once created it will never update if image contents change... admittedly the compose file here does not appear designed for the use case of updating at all (neither via a volume nor via the image...?) # /root/.anki_vector/* ??? is this the path? if so make a volume for this # - wire-pod-data:/chipper/ From 3d6227d43749f8e294571171ed5ab1c33b632d44 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Sun, 12 May 2024 19:04:18 -0500 Subject: [PATCH 45/45] notes --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 21126083..5e535110 100644 --- a/compose.yaml +++ b/compose.yaml @@ -22,7 +22,7 @@ services: # A /chipper/jdocs/botSdkInfo.json # stores vector IP, etc # A /chipper/jdocs/jdocs.json # A /vosk # vosk model extracted here.. would like to move this into image build too (very early on) - # TODO this is a problem to use a volume for /chipper in terms of updates, can we split out just the part that has the database we need to preserve and not cache the codebase? otherwise once created it will never update if image contents change... admittedly the compose file here does not appear designed for the use case of updating at all (neither via a volume nor via the image...?) + # TODO this is a problem to use a volume for /chipper in terms of updates, can we split out just the part that has the database we need to preserve and not cache the codebase? otherwise once created it will never update if image contents change... admittedly the compose file here does not appear designed for the use case of updating at all (neither via a volume nor via the image...?) ... appears that update.sh uses git to pull latest code?! from this repo... so my dockerignore on .git is not gonna be so helpful then :) # /root/.anki_vector/* ??? is this the path? if so make a volume for this # - wire-pod-data:/chipper/ - wire-pod-model:/vosk/