Skip to content

Commit 4c67c5a

Browse files
dockerfile for testing
1 parent 9c7edbe commit 4c67c5a

4 files changed

Lines changed: 132 additions & 2 deletions

File tree

‎AGENTS.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Be sure to update the directory layout in this file if the directory layout chan
9292
| `client-sdk-rust/livekit-ffi/protocol/*.proto` | FFI contract (protobuf definitions, read-only reference) |
9393
| `cmake/` | Build helpers (`protobuf.cmake`, `spdlog.cmake`, `nlohmann_json.cmake`, `LiveKitConfig.cmake.in`) |
9494
| `scripts/` | Local helper scripts for SDK-specific development tasks |
95+
| `docker/` | Dockerfiles for local Linux build environments (`linux-build.Dockerfile`); not used by CI |
9596
| `docs/` | Documentation root. `docs/` holds hand-written long-form Markdown intended to also read well on GitHub. |
9697
| `docs/doxygen/` | Doxygen tool config, theme assets, and Doxygen-only content (`Doxyfile`, `index.md` mainpage, `customization/*.css`, `customization/header.html`, `customization/favicon.ico`). Files here use Doxygen-only syntax (`@ref`, `@brief`, …) and are not intended for human reading on their own. |
9798
| `src/tests/packaging/` | Standalone CTest integration tests consuming installed SDK bundles |
@@ -123,6 +124,10 @@ Updates to ./build.sh and ./build.cmd should be accompanied by updates to this f
123124
./build.sh clean-all # Full clean (C++ + local-install + Rust targets)
124125
```
125126

127+
To build for Linux from another host, use the container in
128+
`docker/linux-build.Dockerfile`. See "Build in a Linux container" in
129+
`docs/building.md` for the image and `docker run` commands.
130+
126131
To create an installable SDK bundle, use the same build command with
127132
`--bundle --prefix <install-dir>` (for example,
128133
`./build.sh release --bundle --prefix sdk-out/livekit-sdk`). On Windows, use

‎docker/linux-build.Dockerfile‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Linux build environment for client-sdk-cpp.
2+
# Mirrors the Ubuntu packages in .github/workflows/builds.yml and
3+
# .github/actions/setup-capture. The source tree is bind-mounted at /work.
4+
FROM ubuntu:24.04
5+
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
ARG LLVM_VERSION=21.1.8
8+
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
ca-certificates curl git git-lfs xz-utils sudo \
11+
build-essential cmake ninja-build pkg-config \
12+
llvm-dev libclang-dev clang \
13+
libva-dev libdrm-dev libgbm-dev libx11-dev libgl1-mesa-dev \
14+
libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev \
15+
libxrandr-dev libxi-dev libxkbcommon-dev \
16+
libasound2-dev libpulse-dev \
17+
libssl-dev \
18+
libprotobuf-dev protobuf-compiler \
19+
libabsl-dev \
20+
libcurl4-openssl-dev \
21+
libwayland-dev libdecor-0-dev \
22+
libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
23+
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
24+
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav \
25+
python3 \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
# webrtc-sys needs a recent clang for the hermetic libc++ in libwebrtc
29+
# (same as client-sdk-rust/.github/scripts/install-clang.sh).
30+
RUN case "$(uname -m)" in \
31+
x86_64) arch=X64 ;; \
32+
aarch64) arch=ARM64 ;; \
33+
*) echo "unsupported arch $(uname -m)" >&2; exit 1 ;; \
34+
esac \
35+
&& mkdir -p /opt/llvm \
36+
&& curl -fsSL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/LLVM-${LLVM_VERSION}-Linux-${arch}.tar.xz" \
37+
| tar -xJ --strip-components=1 -C /opt/llvm \
38+
&& /opt/llvm/bin/clang++ --version
39+
40+
ENV CC=/opt/llvm/bin/clang \
41+
CXX=/opt/llvm/bin/clang++ \
42+
RUSTUP_HOME=/opt/rustup \
43+
CARGO_HOME=/opt/cargo \
44+
PATH=/opt/cargo/bin:$PATH
45+
46+
RUN curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable \
47+
&& chmod -R a+rwX /opt/rustup /opt/cargo \
48+
&& cargo --version
49+
50+
# Keep Rust outputs off the bind mount so they do not mix with macOS artifacts.
51+
ENV CARGO_TARGET_DIR=/cargo-target
52+
53+
RUN git config --global --add safe.directory '*'
54+
55+
WORKDIR /work
56+
CMD ["bash"]

‎docs/README.md‎

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

33
Additional documentation for the SDK.
44

5-
- [Building](building.md) — prerequisites, build scripts, CMake presets,
6-
vcpkg, integration into your CMake project, troubleshooting.
5+
- [Building](building.md) — prerequisites, build scripts, Linux build
6+
container, CMake presets, vcpkg, integration into your CMake project, troubleshooting.
77
- [Capture sources](capture-sources.md) — pattern, clock, and GStreamer sources;
88
build features, release bundles, and publishing. Use capture to stream video through LiveKit
99
without maintaining your own video pipeline.

‎docs/building.md‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,75 @@ CMake package files, add `--bundle --prefix <install-dir>` to a build command:
135135
The build scripts pass an explicit job count to `cmake --build --parallel`. Set
136136
`CMAKE_BUILD_PARALLEL_LEVEL` to override the auto-detected logical CPU count.
137137

138+
## Build in a Linux container
139+
140+
You can build and test the SDK for Linux from a macOS or Linux host with
141+
`docker/linux-build.Dockerfile`. The image uses Ubuntu 24.04 with the same
142+
packages as the Linux CI jobs. It also includes GStreamer for `--capture`
143+
builds, the LLVM 21 clang that `webrtc-sys` needs, and the stable Rust
144+
toolchain. The container builds for the host CPU architecture, so an Apple
145+
silicon Mac produces a Linux arm64 build.
146+
147+
1. From the repository root, build the image:
148+
149+
```bash
150+
docker build -f docker/linux-build.Dockerfile -t livekit-cpp-build docker/
151+
```
152+
153+
2. Start the container with the source tree mounted at `/work`:
154+
155+
```bash
156+
docker run -d --name lk-cpp --network host \
157+
-v "$PWD":/work \
158+
-v lk-build-debug:/work/build-debug \
159+
-v lk-build-release:/work/build-release \
160+
-v lk-local-install:/work/local-install \
161+
-v lk-sdk-out:/work/sdk-out \
162+
-v lk-cargo-target:/cargo-target \
163+
-v lk-cargo-registry:/opt/cargo/registry \
164+
livekit-cpp-build sleep infinity
165+
```
166+
167+
3. Open a shell in the container:
168+
169+
```bash
170+
docker exec -it lk-cpp bash
171+
```
172+
173+
4. In the container shell, build and run the tests:
174+
175+
```bash
176+
./build.sh debug-tests
177+
source scripts/set-test-tokens.sh
178+
cd build-debug && ctest
179+
```
180+
181+
The named volumes keep the Linux build directories and Rust outputs apart from
182+
the host build directories. The image sets `CARGO_TARGET_DIR=/cargo-target`, so
183+
Rust outputs do not go to `client-sdk-rust/target` on the host.
184+
185+
`build.sh` replaces the `compile_commands.json` symlink at the repository root.
186+
After a container build, the symlink points to a path that exists only in the
187+
container. To restore it for host tools such as clangd, run this command on the
188+
host:
189+
190+
```bash
191+
ln -sf "$PWD/build-debug/compile_commands.json" compile_commands.json
192+
```
193+
194+
If you use Docker Desktop on macOS, turn on host networking in
195+
Settings > Resources > Network before you use `--network host`. With host
196+
networking, the container can reach a local `livekit-server --dev` on
197+
`localhost:7880`.
198+
199+
To remove the container and its build volumes, run:
200+
201+
```bash
202+
docker rm -f lk-cpp
203+
docker volume rm lk-build-debug lk-build-release lk-local-install lk-sdk-out \
204+
lk-cargo-target lk-cargo-registry
205+
```
206+
138207
## Advanced: CMake presets
139208

140209
For more control, drive CMake directly via the presets in

0 commit comments

Comments
 (0)