Skip to content

Commit 00086b4

Browse files
dockerfile for testing
1 parent 9c7edbe commit 00086b4

6 files changed

Lines changed: 141 additions & 3 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: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Linux build environment for client-sdk-cpp.
2+
# Ubuntu packages match the Linux jobs in .github/workflows/builds.yml,
3+
# tests.yml, and make-release.yml. Pass --build-arg INSTALL_GSTREAMER=1 to also
4+
# install the GStreamer packages from .github/actions/setup-capture.
5+
# The source tree is bind-mounted at /work.
6+
FROM ubuntu:24.04
7+
8+
ARG DEBIAN_FRONTEND=noninteractive
9+
# Empty means the default version in install-clang.sh.
10+
ARG LLVM_VERSION
11+
12+
# ca-certificates, curl, git, git-lfs, xz-utils, sudo, and python3 are already
13+
# present on GitHub-hosted runners. python3 is what the coverage job uses for
14+
# gcovr. git is needed because FetchContent clones GoogleTest.
15+
RUN apt-get update && apt-get install -y --no-install-recommends \
16+
ca-certificates curl git rsync xz-utils \
17+
python3 \
18+
build-essential cmake ninja-build pkg-config \
19+
llvm-dev libclang-dev clang \
20+
libva-dev libdrm-dev libgbm-dev libx11-dev libgl1-mesa-dev \
21+
libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev \
22+
libxrandr-dev libxi-dev libxkbcommon-dev \
23+
libasound2-dev libpulse-dev \
24+
libssl-dev \
25+
libprotobuf-dev protobuf-compiler \
26+
libabsl-dev \
27+
libcurl4-openssl-dev \
28+
libwayland-dev libdecor-0-dev \
29+
libunwind-dev libjpeg-dev \
30+
gdb jq \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
# webrtc-sys needs a recent clang for the hermetic libc++ in libwebrtc. Use the
34+
# same script as CI. The build context is the repository root, and
35+
# linux-build.Dockerfile.dockerignore limits it to this one file.
36+
COPY client-sdk-rust/.github/scripts/install-clang.sh /tmp/install-clang.sh
37+
RUN LLVM_ROOT=/opt/llvm /tmp/install-clang.sh \
38+
&& rm /tmp/install-clang.sh
39+
40+
ENV CC=/opt/llvm/bin/clang \
41+
CXX=/opt/llvm/bin/clang++ \
42+
LIBCLANG_PATH=/opt/llvm/lib \
43+
RUSTUP_HOME=/opt/rustup \
44+
CARGO_HOME=/opt/cargo \
45+
PATH=/opt/cargo/bin:$PATH
46+
47+
RUN curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable \
48+
&& chmod -R a+rwX /opt/rustup /opt/cargo \
49+
&& cargo --version
50+
51+
# Keep Rust outputs out of the synced source tree.
52+
ENV CARGO_TARGET_DIR=/cargo-target
53+
54+
# Last install so a GStreamer toggle reuses the toolchain layers above.
55+
# libunwind-dev is already in the base package list.
56+
ARG INSTALL_GSTREAMER=0
57+
RUN if [ "$INSTALL_GSTREAMER" = "1" ]; then \
58+
apt-get update && apt-get install -y --no-install-recommends \
59+
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
60+
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
61+
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav \
62+
&& rm -rf /var/lib/apt/lists/*; \
63+
fi
64+
65+
WORKDIR /work
66+
CMD ["bash"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Build context allowlist for linux-build.Dockerfile. The context is the
2+
# repository root, but the image needs only the clang install script.
3+
*
4+
!client-sdk-rust/.github/scripts/install-clang.sh
5+
build-debug
6+
build-release
7+

‎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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,66 @@ the installed SDK instead of another configuration's most recent build.
417417

418418
See [Capture sources](capture-sources.md) for dependencies and usage.
419419

420+
## Build in a Linux container
421+
422+
You can test a clean Linux build and its dependency tree from a macOS or Linux
423+
host with `docker/linux-build.Dockerfile`. The container is a build check, not
424+
a development environment. The image uses Ubuntu 24.04 with the same packages
425+
as the Linux CI jobs. It also includes GStreamer for `--capture` builds and
426+
the stable Rust toolchain.
427+
428+
The container bind-mounts the source paths that the build reads from the host
429+
into `/work`. Changes on the host show up in the container immediately. The
430+
`/work` directory itself is the `lk-cpp-work` volume, so build outputs such as
431+
`build-*`, `local-install`, and `sdk-out` stay in the container. Host build
432+
directories and `.git` data are not mounted.
433+
434+
1. From the repository root, build the image. The `client-sdk-rust` submodule
435+
must be checked out, because the image copies its clang install script.
436+
437+
```bash
438+
docker build -f docker/linux-build.Dockerfile -t livekit-cpp-build .
439+
```
440+
441+
To install gstreamer:
442+
```bash
443+
docker build -f docker/linux-build.Dockerfile \
444+
--build-arg INSTALL_GSTREAMER=1 \
445+
-t livekit-cpp-build .
446+
```
447+
448+
The build context is the repository root. The file
449+
`docker/linux-build.Dockerfile.dockerignore` limits the context to the
450+
clang install script, so Docker does not send build outputs or `.git`.
451+
452+
2. From the repository root, start the container:
453+
454+
```bash
455+
docker run -d --name lk-cpp --network host \
456+
-v lk-cpp-work:/work \
457+
-v lk-cargo-target:/cargo-target \
458+
-v lk-cargo-registry:/opt/cargo/registry \
459+
-v "$(pwd)/build.sh:/work/build.sh" \
460+
-v "$(pwd)/CMakeLists.txt:/work/CMakeLists.txt" \
461+
-v "$(pwd)/CMakePresets.json:/work/CMakePresets.json" \
462+
-v "$(pwd)/build.h.in:/work/build.h.in" \
463+
-v "$(pwd)/.build-info.json.in:/work/.build-info.json.in" \
464+
-v "$(pwd)/cmake:/work/cmake" \
465+
-v "$(pwd)/include:/work/include" \
466+
-v "$(pwd)/src:/work/src" \
467+
-v "$(pwd)/scripts:/work/scripts" \
468+
-v "$(pwd)/client-sdk-rust:/work/client-sdk-rust" \
469+
-v lk-rust-source-target:/work/client-sdk-rust/target \
470+
-v "$(pwd)/cpp-example-collection:/work/cpp-example-collection" \
471+
livekit-cpp-build sleep infinity
472+
```
473+
474+
3. Open a shell in the container:
475+
476+
```bash
477+
docker exec -it lk-cpp bash
478+
```
479+
For a fully clean build, run `./build.sh clean-all` in the container, or remove the volumes.
420480

421481
## Support
422482

‎src/capture_source.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace {
5353
// Report validation and synchronous send failures through the same future as
5454
// asynchronous creation errors. All public factories share this path.
5555
template <typename Config>
56-
std::future<std::shared_ptr<CaptureSource>> createCaptureSource(Config config) {
56+
std::future<std::shared_ptr<CaptureSource>> createCaptureSource(const Config& config) {
5757
try {
5858
return FfiClient::instance().newCaptureSourceAsync(toProto(std::move(config)));
5959
} catch (const std::exception& error) {

0 commit comments

Comments
 (0)