Skip to content

Commit d254903

Browse files
authored
Merge pull request #461 from Zippy-boy/main
Rework of docker and docker compose
2 parents 9e2a52f + 368e7f4 commit d254903

File tree

6 files changed

+374
-16
lines changed

6 files changed

+374
-16
lines changed

.dockerignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.git
2+
.github
3+
.idea
4+
.vscode
5+
*.log
6+
*.tmp
7+
*.swp
8+
*.swo
9+
Dockerfile
10+
docker-compose.yml
11+
docker-compose.yaml
12+
compose.yml
13+
compose.yaml
14+
compose.override.yml
15+
node_modules
16+
vendor
17+
vosk
18+
stt
19+
whisper.cpp
20+
vector-cloud/build
21+
chipper/session-certs
22+
chipper/jdocs
23+
chipper/apiConfig.json
24+
chipper/botConfig.json
25+
chipper/customIntents.json
26+
chipper/pico.key
27+
chipper/useepod
28+
chipper/source.sh
29+
.env

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ name: Docker
66
# documentation.
77

88
on:
9-
schedule:
10-
- cron: '25 22 * * *'
119
push:
1210
branches: [ "main" ]
1311
# Publish semver tags as releases.
@@ -96,4 +94,4 @@ jobs:
9694
DIGEST: ${{ steps.build-and-push.outputs.digest }}
9795
# This step uses the identity token to provision an ephemeral certificate
9896
# against the sigstore community Fulcio instance.
99-
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
97+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

compose.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
services:
22
wire-pod:
3+
container_name: wire-pod
34
hostname: escapepod
45
image: ghcr.io/kercre123/wire-pod:main
56
restart: unless-stopped
7+
environment:
8+
WIREPOD_DATA_DIR: /data
69
ports:
7-
- 443:443
8-
- 8080:8080
9-
- 80:80
10-
- 8084:8084
10+
- "80:80"
11+
- "443:443"
12+
- "8080:8080"
13+
- "8084:8084"
1114
volumes:
12-
- wire-pod-data:/chipper/
13-
- wire-pod-model:/vosk/
15+
- wire-pod-data:/data
16+
- wire-pod-images:/images
17+
healthcheck:
18+
test: [ "CMD", "curl", "-fsS", "http://localhost:8080/ok" ]
19+
interval: 30s
20+
timeout: 5s
21+
retries: 5
22+
start_period: 30s
23+
1424
volumes:
1525
wire-pod-data:
1626
driver: local
17-
wire-pod-model:
18-
driver: local

docker/default-source.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
export DEBUG_LOGGING="true"
4+
export STT_SERVICE="vosk"
5+
export STT_LANGUAGE="en-US"
6+
export USE_INBUILT_BLE="false"

docker/entrypoint.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
APP_ROOT="/opt/wire-pod"
5+
DATA_ROOT="${WIREPOD_DATA_DIR:-/data}"
6+
DEFAULT_SOURCE="${APP_ROOT}/docker/default-source.sh"
7+
8+
mkdir -p "${DATA_ROOT}"
9+
10+
link_dir() {
11+
local rel_path="$1"
12+
local src_path="${APP_ROOT}/${rel_path}"
13+
local dest_path="${DATA_ROOT}/${rel_path}"
14+
15+
mkdir -p "$(dirname "${dest_path}")"
16+
17+
if [ ! -d "${dest_path}" ]; then
18+
if [ -d "${src_path}" ]; then
19+
cp -a "${src_path}" "${dest_path}"
20+
else
21+
mkdir -p "${dest_path}"
22+
fi
23+
fi
24+
25+
if [ -e "${src_path}" ] && [ ! -L "${src_path}" ]; then
26+
rm -rf "${src_path}"
27+
fi
28+
29+
ln -sfn "${dest_path}" "${src_path}"
30+
}
31+
32+
link_file() {
33+
local rel_path="$1"
34+
local src_path="${APP_ROOT}/${rel_path}"
35+
local dest_path="${DATA_ROOT}/${rel_path}"
36+
37+
mkdir -p "$(dirname "${dest_path}")"
38+
39+
if [ ! -e "${dest_path}" ]; then
40+
if [ -f "${src_path}" ]; then
41+
cp -a "${src_path}" "${dest_path}"
42+
else
43+
: >"${dest_path}"
44+
fi
45+
fi
46+
47+
if [ -e "${src_path}" ] && [ ! -L "${src_path}" ]; then
48+
rm -f "${src_path}"
49+
fi
50+
51+
ln -sfn "${dest_path}" "${src_path}"
52+
}
53+
54+
link_file_with_default() {
55+
local rel_path="$1"
56+
local default_path="$2"
57+
local src_path="${APP_ROOT}/${rel_path}"
58+
local dest_path="${DATA_ROOT}/${rel_path}"
59+
60+
mkdir -p "$(dirname "${dest_path}")"
61+
62+
if [ ! -e "${dest_path}" ]; then
63+
if [ -n "${default_path}" ] && [ -f "${default_path}" ]; then
64+
cp -a "${default_path}" "${dest_path}"
65+
elif [ -f "${src_path}" ]; then
66+
cp -a "${src_path}" "${dest_path}"
67+
else
68+
: >"${dest_path}"
69+
fi
70+
fi
71+
72+
if [ -e "${src_path}" ] && [ ! -L "${src_path}" ]; then
73+
rm -f "${src_path}"
74+
fi
75+
76+
ln -sfn "${dest_path}" "${src_path}"
77+
}
78+
79+
persist_directories() {
80+
link_dir certs
81+
link_dir stt
82+
link_dir vosk
83+
link_dir whisper.cpp
84+
link_dir vector-cloud/build
85+
link_dir chipper/jdocs
86+
link_dir chipper/plugins
87+
link_dir chipper/session-certs
88+
}
89+
90+
persist_files() {
91+
link_file chipper/apiConfig.json
92+
link_file chipper/botConfig.json
93+
link_file chipper/customIntents.json
94+
link_file chipper/pico.key
95+
link_file chipper/useepod
96+
link_file_with_default chipper/source.sh "${DEFAULT_SOURCE}"
97+
}
98+
99+
update_export() {
100+
local key="$1"
101+
local value="$2"
102+
local file_path="$3"
103+
104+
local escaped
105+
escaped=$(printf '%s' "${value}" | sed 's/[\\&/]/\\&/g')
106+
107+
if grep -q "^export ${key}=" "${file_path}"; then
108+
sed -i "s/^export ${key}=.*/export ${key}=\"${escaped}\"/" "${file_path}"
109+
else
110+
printf 'export %s="%s"\n' "${key}" "${value}" >>"${file_path}"
111+
fi
112+
}
113+
114+
apply_env_overrides() {
115+
local source_file="${APP_ROOT}/chipper/source.sh"
116+
117+
if [ -n "${WIREPOD_DEBUG_LOGGING:-}" ]; then
118+
update_export "DEBUG_LOGGING" "${WIREPOD_DEBUG_LOGGING}" "${source_file}"
119+
fi
120+
121+
if [ -n "${WIREPOD_STT_SERVICE:-}" ]; then
122+
update_export "STT_SERVICE" "${WIREPOD_STT_SERVICE}" "${source_file}"
123+
fi
124+
125+
if [ -n "${WIREPOD_STT_LANGUAGE:-}" ]; then
126+
update_export "STT_LANGUAGE" "${WIREPOD_STT_LANGUAGE}" "${source_file}"
127+
fi
128+
129+
if [ -n "${WIREPOD_USE_INBUILT_BLE:-}" ]; then
130+
update_export "USE_INBUILT_BLE" "${WIREPOD_USE_INBUILT_BLE}" "${source_file}"
131+
fi
132+
133+
if [ -n "${WIREPOD_PICOVOICE_APIKEY:-}" ]; then
134+
update_export "PICOVOICE_APIKEY" "${WIREPOD_PICOVOICE_APIKEY}" "${source_file}"
135+
printf '%s\n' "${WIREPOD_PICOVOICE_APIKEY}" >"${DATA_ROOT}/chipper/pico.key"
136+
fi
137+
}
138+
139+
persist_directories
140+
persist_files
141+
142+
if [ ! -e /root/.vosk ]; then
143+
ln -sfn /opt/vosk /root/.vosk
144+
fi
145+
146+
apply_env_overrides
147+
148+
exec "$@"

0 commit comments

Comments
 (0)