Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations for running in a container based via compose/Dockerfile in repo roo #328

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e3838c5
add compose build
g0t4 May 11, 2024
c2051b0
try sharing root netns for mDNS
g0t4 May 11, 2024
41b1296
explicit platform - likely isn't needed
g0t4 May 12, 2024
50db1ad
fix readability of indent
g0t4 May 12, 2024
587c255
indent
g0t4 May 12, 2024
4beed32
notes
g0t4 May 12, 2024
f92430b
split out installing base packages so we don't repeat it on every sou…
g0t4 May 12, 2024
008ab51
already chmod'd
g0t4 May 12, 2024
5649ea3
stock dockerignore to speed up builds and not trigger rebuild on say …
g0t4 May 12, 2024
59746df
try rearrange to just copy in setup.sh, so we don't re-run setup ever…
g0t4 May 12, 2024
e783a77
make it look like chipper is present (just the dir though)
g0t4 May 12, 2024
7e6408e
notes
g0t4 May 12, 2024
06aa697
fix
g0t4 May 12, 2024
7fbac38
notes
g0t4 May 12, 2024
7b93b98
notes
g0t4 May 12, 2024
cea58c9
notes
g0t4 May 12, 2024
1add7ff
detect container build and split up steps so when smth goes wrong we
g0t4 May 12, 2024
4988913
inline the default path that a container build would use
g0t4 May 12, 2024
93795df
split up two stages
g0t4 May 12, 2024
aba6bcd
rename to SETUP_STAGE
g0t4 May 12, 2024
aaecfee
copy in go.{mod,sum} so we can go get/install for the getSTT setup.sh…
g0t4 May 12, 2024
7e008db
put back all files so I can troubleshoot any clobber issues from COPY…
g0t4 May 12, 2024
dbf2f68
notes
g0t4 May 12, 2024
4fb4a25
don't copy in files we dont need
g0t4 May 12, 2024
6d70ece
notes
g0t4 May 12, 2024
df4cccd
notes
g0t4 May 12, 2024
bc7904b
notes
g0t4 May 12, 2024
14cf992
notes
g0t4 May 12, 2024
71260cf
add go build call in a new RUN instruction to pull deps during image …
g0t4 May 12, 2024
8404189
ok now move module download into Dockerfile so I can optimize its pla…
g0t4 May 12, 2024
6a4799b
put back start.sh the way it was
g0t4 May 12, 2024
bdd3bd8
notes
g0t4 May 12, 2024
9878bf9
hypothesis about vector cloud
g0t4 May 12, 2024
86e1321
notes
g0t4 May 12, 2024
720cd21
move up go mod downloads to earlier in build before we copy in source…
g0t4 May 12, 2024
ef47afe
notes
g0t4 May 12, 2024
2cfed93
notes
g0t4 May 12, 2024
ab5791a
split out build from run and bake build into image
g0t4 May 12, 2024
4eb8a77
notes
g0t4 May 12, 2024
5bec26b
comment out
g0t4 May 12, 2024
08012ed
notes
g0t4 May 12, 2024
1550447
notes
g0t4 May 12, 2024
d66ec45
notes while rebuilding server and testing my vector - and it all works\!
g0t4 May 12, 2024
0c3d609
notes
g0t4 May 12, 2024
3d6227d
notes
g0t4 May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/
#

**/.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
17 changes: 11 additions & 6 deletions chipper/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,25 +42,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"
Expand All @@ -80,7 +81,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"
Expand All @@ -92,7 +93,11 @@ if [[ ${STT_SERVICE} == "leopard" ]]; 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
Expand Down
22 changes: 18 additions & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '3.8'
services:
wire-pod:
hostname: escapepod
build: .
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...
Copy link
Contributor

@Zippy-boy Zippy-boy May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used mDNS because it was simple to set up and didn't require a DNS record (which I couldn't do with my network setup). Although, if this is more efficient, go for it :)

You could also add in a volume for vectors images, I did this in another branch but if this gets merged it will be better in here:
volumes: - wire-pod-data:/chipper/ - wire-pod-model:/vosk/ - wire-pod-images:/images/ volumes: wire-pod-data: driver: local wire-pod-model: driver: local wire-pod-images: driver: local

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took out the wire-pod-data:/chipper/ volume because it was a mix of state (i.e. vector config) and code (for chipper), thus to update the code I had to get rid of the volume.

Since I was just doing some initial testing, I didn't mind recreating state but I would much prefer to get state split out (ideally into one volume) and then I can update chipper code/executables via the image and get best of both worlds... that was next on my todo list :)

If this sounds interesting to you, I will proceed with it to make an example that we can use to later talk about updating the actual Dockerfile, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, 100% agree with you with the chipper thing. When I put that in, i5 wasn't meant to last, I knew it wasnt proper when doing it, but I didn't have the time to figure out what needed to be saved or forgotten so I just included everything. I meant to add a volume for the images vector takes.

platform: linux/arm64
image: ghcr.io/kercre123/wire-pod:main
restart: unless-stopped
ports:
Expand All @@ -10,10 +12,22 @@ services:
- 80:80
- 8084:8084
volumes:
- wire-pod-data:/chipper/
# 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 # stores config for first Submit Settings page (i.e. openai api key, weather api key, etc.)
# C /chipper/jdocs
# 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much more finished then the current solution. Would like to discuss the downloading of vosk in the image though. If updating is implemented for docker, then surely it would be less efficient to download vosk in the image everytime rather then once when needed? I think my intent was to keep the image a little smaller so when downloading it for a second time it wouldn't take as long (i have terrible internet speeds). Tell me if I'm incorrect though, I'm not the best with docker as you can see lol

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely makes sense to cache it in a volume.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not a priority... it might be nice to combine mDNS + DHCP domain suffix search (i.e. my DHCP server provides .lan suffix and so escapepod.lan would be nice to try too)... or some way to otherwise provide a custom base_url to vector... just curious, is vector given the escapepod.local URL to connect back to? I haven't yet looked into that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is given escapepod.local sadly. Although there may be a way to change it. It might be quite hard though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escapepod.local is a hard coded URL in Vector's firmware and cannot be changed.

# 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/
volumes:
wire-pod-data:
driver: local
# wire-pod-data:
# driver: local
wire-pod-model:
driver: local
41 changes: 37 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
FROM ubuntu


COPY . .
# *** 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...` + 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 IMAGE_BUILD=true SETUP_STAGE=getPackages ./setup.sh"]

RUN chmod +x /setup.sh && apt-get update && apt-get install -y dos2unix && dos2unix /setup.sh && apt-get install -y avahi-daemon avahi-autoipd
# 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 which sets env vars only
RUN ["/bin/sh", "-c", "STT=vosk IMAGE_BUILD=true SETUP_STAGE=getSTT ./setup.sh"]
# *** END PACKAGE INSTALLS ***

RUN ["/bin/sh", "-c", "STT=vosk ./setup.sh"]
# *** 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?
# 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 ***

RUN chmod +x /chipper/start.sh && dos2unix /chipper/start.sh
# 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
#
# 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"]
# 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"]
68 changes: 42 additions & 26 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=""
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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..."
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -651,6 +651,22 @@ if [[ $1 == "-f" ]] && [[ $2 == "scp" ]]; then
exit 0
fi

if [[ -n "${IMAGE_BUILD}" ]]; then
echo "Detected container build env..."
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 [[ "${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"
exit 0
fi
echo "Please provide a valid SETUP_STAGE env var, the current value is '${SETUP_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"
Expand Down