Skip to content

Commit c2ed736

Browse files
committed
Add multi-arch support for VAD Docker image
1 parent 0f5c5e7 commit c2ed736

File tree

2 files changed

+50
-17
lines changed

2 files changed

+50
-17
lines changed

docker/server-vad/Dockerfile

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,51 @@ FROM debian:bookworm-slim
44

55
WORKDIR /app
66

7+
ARG TARGETPLATFORM
78
ARG ECHOKIT_VERSION=0.1.0
89
ARG VAD_VERSION=0.1.0
910

10-
RUN apt-get update \
11-
&& apt-get install -y --no-install-recommends \
11+
RUN set -eux; \
12+
apt-get update; \
13+
apt-get install -y --no-install-recommends \
1214
bash \
1315
ca-certificates \
1416
curl \
1517
unzip \
1618
libgomp1 \
17-
libssl3 \
18-
&& rm -rf /var/lib/apt/lists/*
19+
libssl3; \
20+
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
21+
apt-get install -y --no-install-recommends \
22+
libopenblas-dev \
23+
libgomp1; \
24+
fi; \
25+
rm -rf /var/lib/apt/lists/*
1926

2027
RUN set -eux; \
21-
curl -L https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.0%2Bcpu.zip -o /tmp/libtorch.zip; \
22-
unzip /tmp/libtorch.zip -d /usr/local/lib; \
23-
rm /tmp/libtorch.zip; \
28+
case "${TARGETPLATFORM}" in \
29+
"linux/amd64") \
30+
curl -fsSL "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.0%2Bcpu.zip" -o /tmp/libtorch.zip; \
31+
unzip /tmp/libtorch.zip -d /usr/local/lib; \
32+
rm /tmp/libtorch.zip; \
33+
;; \
34+
"linux/arm64") \
35+
curl -fsSL "https://github.com/second-state/libtorch-releases/releases/download/v2.4.0/libtorch-cxx11-abi-aarch64-2.4.0.tar.gz" -o /tmp/libtorch.tar.gz; \
36+
tar -xzf /tmp/libtorch.tar.gz -C /usr/local/lib; \
37+
mv /usr/local/lib/torch /usr/local/lib/libtorch; \
38+
rm /tmp/libtorch.tar.gz; \
39+
;; \
40+
*) echo "Unsupported TARGETPLATFORM: ${TARGETPLATFORM}" >&2; exit 1 ;; \
41+
esac; \
2442
if [ -f /usr/local/lib/libtorch/lib/libnvrtc-builtins.so ]; then \
2543
ln -sf /usr/local/lib/libtorch/lib/libnvrtc-builtins.so /usr/local/lib/libtorch/lib/libnvrtc-builtins.so.12.4; \
2644
fi
2745

2846
RUN set -eux; \
29-
ARCH_SUFFIX="x86_64-unknown-linux-gnu"; \
47+
case "${TARGETPLATFORM}" in \
48+
"linux/amd64") ARCH_SUFFIX="x86_64-unknown-linux-gnu" ;; \
49+
"linux/arm64") ARCH_SUFFIX="aarch64-unknown-linux-gnu" ;; \
50+
*) echo "Unsupported TARGETPLATFORM: ${TARGETPLATFORM}" >&2; exit 1 ;; \
51+
esac; \
3052
tmpdir="$(mktemp -d)"; \
3153
archive="echokit_server-v${ECHOKIT_VERSION}-${ARCH_SUFFIX}.tar.gz"; \
3254
url="https://github.com/second-state/echokit_server/releases/download/v${ECHOKIT_VERSION}/${archive}"; \
@@ -38,7 +60,11 @@ RUN set -eux; \
3860
rm -rf "$tmpdir" /tmp/echokit_server.tar.gz
3961

4062
RUN set -eux; \
41-
ARCH_SUFFIX="x86_64-unknown-linux-gnu"; \
63+
case "${TARGETPLATFORM}" in \
64+
"linux/amd64") ARCH_SUFFIX="x86_64-unknown-linux-gnu" ;; \
65+
"linux/arm64") ARCH_SUFFIX="aarch64-unknown-linux-gnu" ;; \
66+
*) echo "Unsupported TARGETPLATFORM: ${TARGETPLATFORM}" >&2; exit 1 ;; \
67+
esac; \
4268
tmpdir="$(mktemp -d)"; \
4369
archive="silero_vad_server-v${VAD_VERSION}-${ARCH_SUFFIX}.tar.gz"; \
4470
url="https://github.com/second-state/silero_vad_server/releases/download/v${VAD_VERSION}/${archive}"; \

docker/server-vad/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This directory provides a single-stage runtime image that launches both `echokit_server` and `silero_vad_server` inside the same container.
44

5-
- **Runtime image** (`debian:bookworm-slim`): installs runtime dependencies, downloads the CUDA-enabled `libtorch` bundle, and fetches the `v0.1.0` release binaries for `echokit_server`, `silero_vad_server`, and the `silero_vad.jit` model.
5+
- **Runtime image** (`debian:bookworm-slim`): installs the runtime dependencies (adding `libopenblas` on arm64), selects the appropriate `libtorch` archive for the target architecture, and downloads the `v0.1.0` release binaries for `echokit_server`, `silero_vad_server`, and the `silero_vad.jit` model.
66
- **Supervisor script**: `/usr/local/bin/start_servers.sh` starts both services, relays signals, and keeps the container alive while either process is running.
77

88
## Run
@@ -27,18 +27,25 @@ The VAD server listens on port `8000` internally. Choose one of the following so
2727
## Build
2828

2929
```sh
30-
docker build \
31-
--platform linux/amd64 \
30+
docker build -t secondstate/echokit:latest-server-vad .
31+
```
32+
33+
The build automatically detects `TARGETPLATFORM` and pulls the matching release artifacts (x86_64 or arm64). Override the downloaded releases by supplying `--build-arg ECHOKIT_VERSION=<version>` or `--build-arg VAD_VERSION=<version>` if you want a different tag.
34+
35+
## Multi-platform build
36+
37+
Use Buildx to produce and publish a multi-arch manifest in one command. BuildKit injects `TARGETPLATFORM` (`linux/amd64`, `linux/arm64`, etc.), so you do not need to set them manually.
38+
39+
```sh
40+
docker buildx build \
41+
--platform linux/amd64,linux/arm64 \
3242
--build-arg ECHOKIT_VERSION=0.1.0 \
43+
--build-arg VAD_VERSION=0.1.0 \
3344
-t secondstate/echokit:latest-server-vad \
3445
.
3546
```
3647

37-
This Dockerfile always downloads the `linux-x86_64` release artifacts baked into the file. Update the URLs if you need to pin a different release.
38-
39-
## Platform support
40-
41-
Multi-platform builds are **not supported**. The image bundles CUDA-enabled `libtorch` and hard-coded `x86_64-unknown-linux-gnu` binaries for both servers, so `docker buildx` cannot produce working arm64 (or other architecture) variants.
48+
Adjust the build arguments as needed; omit them to fall back to the defaults baked into the Dockerfile.
4249

4350
## Publish
4451

0 commit comments

Comments
 (0)