-
Notifications
You must be signed in to change notification settings - Fork 163
add Docker support for local Linux builds #951
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
Merged
+170
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright 2026 LiveKit, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Build environment image for LiveKit Rust SDKs on Linux (x86_64 and aarch64). | ||
| # Based on manylinux_2_28 for maximum glibc compatibility (RHEL 8 / glibc 2.28+). | ||
| # | ||
| # This image contains only system dependencies and the Rust toolchain. | ||
| # The source tree is volume-mounted at runtime, not copied into the image. | ||
| # This matches the CI approach in ffi-builds.yml. | ||
|
|
||
| ARG BASE_IMAGE=sameli/manylinux_2_28_x86_64_cuda_12.3 | ||
| FROM ${BASE_IMAGE} | ||
|
|
||
| ARG RUST_TARGET=x86_64-unknown-linux-gnu | ||
|
|
||
| # Install system dependencies (mirrors ffi-builds.yml) | ||
| RUN yum install -y \ | ||
| llvm \ | ||
| llvm-libs \ | ||
| lld \ | ||
| clang \ | ||
| protobuf-compiler \ | ||
| openssl-devel \ | ||
| libX11-devel \ | ||
| mesa-libGL-devel \ | ||
| libXext-devel \ | ||
| libva-devel \ | ||
| libdrm-devel \ | ||
| libgbm-devel \ | ||
| libXdamage-devel \ | ||
| libXrandr-devel \ | ||
| libXfixes-devel \ | ||
| libXcomposite-devel \ | ||
| && yum groupinstall -y 'Development Tools' \ | ||
| && yum clean all | ||
|
|
||
| # Install Rust | ||
| RUN curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
| ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
|
||
| # Add the target | ||
| RUN rustup target add ${RUST_TARGET} | ||
|
|
||
| WORKDIR /workspace | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Copyright 2026 LiveKit, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| ROOT_DIR := $(shell cd .. && pwd) | ||
|
|
||
| X86_IMAGE := livekit-rust-env:x86_64 | ||
| AARCH64_IMAGE := livekit-rust-env:aarch64 | ||
|
|
||
| X86_TARGET := x86_64-unknown-linux-gnu | ||
| AARCH64_TARGET := aarch64-unknown-linux-gnu | ||
|
|
||
| DOCKER_RUN = docker run --rm -v $(ROOT_DIR):/workspace -w /workspace | ||
|
|
||
| .PHONY: submodules env-x86_64 env-aarch64 sdk-x86_64 sdk-aarch64 ffi-x86_64 ffi-aarch64 clean | ||
|
|
||
| # --- Submodules --- | ||
|
|
||
| submodules: | ||
| git -C $(ROOT_DIR) submodule update --init --recursive | ||
|
|
||
| # --- Environment images --- | ||
|
|
||
| env-x86_64: | ||
| docker build -f Dockerfile.linux \ | ||
| -t $(X86_IMAGE) . | ||
|
|
||
| env-aarch64: | ||
| docker build -f Dockerfile.linux \ | ||
| --build-arg BASE_IMAGE=quay.io/pypa/manylinux_2_28_aarch64 \ | ||
| --build-arg RUST_TARGET=$(AARCH64_TARGET) \ | ||
| -t $(AARCH64_IMAGE) . | ||
|
|
||
| # --- SDK builds --- | ||
|
|
||
| sdk-x86_64: submodules env-x86_64 | ||
| $(DOCKER_RUN) $(X86_IMAGE) \ | ||
| cargo build --release --target $(X86_TARGET) -p livekit | ||
|
|
||
| sdk-aarch64: submodules env-aarch64 | ||
| $(DOCKER_RUN) $(AARCH64_IMAGE) \ | ||
| cargo build --release --target $(AARCH64_TARGET) -p livekit | ||
|
|
||
| # --- FFI builds --- | ||
|
|
||
| ffi-x86_64: submodules env-x86_64 | ||
| $(DOCKER_RUN) $(X86_IMAGE) \ | ||
| bash -c "cd livekit-ffi && cargo build --release --target $(X86_TARGET)" | ||
|
|
||
| ffi-aarch64: submodules env-aarch64 | ||
| $(DOCKER_RUN) $(AARCH64_IMAGE) \ | ||
| bash -c "cd livekit-ffi && cargo build --release --target $(AARCH64_TARGET)" | ||
|
|
||
| # --- Cleanup --- | ||
|
|
||
| clean: | ||
| -docker rmi $(X86_IMAGE) $(AARCH64_IMAGE) 2>/dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Docker Build for LiveKit Rust SDKs | ||
|
|
||
| Builds the LiveKit Rust SDK and FFI library inside a [manylinux_2_28](https://github.com/pypa/manylinux) container, ensuring the resulting binaries are compatible with most Linux distributions (glibc 2.28+, i.e. RHEL 8, Ubuntu 20.04, Debian 11, and newer). The x86_64 build uses a CUDA-enabled base image for NVIDIA hardware-accelerated video codec support. | ||
|
|
||
| ## How it works | ||
|
|
||
| The Dockerfile builds an **environment image** containing only system dependencies and the Rust toolchain — no source code is copied in. At build time, the host workspace is volume-mounted into the container (`-v $PWD:/workspace`). This matches the CI approach used in `ffi-builds.yml` and means: | ||
|
|
||
| - Git submodules (`yuv-sys/libyuv`, `livekit-protocol/protocol`) are available automatically | ||
| - The `target/` directory persists on the host, so incremental builds are fast | ||
| - No multi-gigabyte build context is sent to the Docker daemon | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ```bash | ||
| git submodule update --init | ||
| ``` | ||
|
|
||
| ## Makefile targets | ||
|
|
||
| ```bash | ||
| cd docker | ||
|
|
||
| # Build environment images (done automatically by sdk/ffi targets) | ||
| make env-x86_64 | ||
| make env-aarch64 | ||
|
|
||
| # Build the SDK (livekit crate) | ||
| make sdk-x86_64 | ||
| make sdk-aarch64 | ||
|
|
||
| # Build the FFI library (livekit-ffi crate) | ||
| make ffi-x86_64 | ||
| make ffi-aarch64 | ||
|
|
||
| # Remove environment images | ||
| make clean | ||
| ``` | ||
|
|
||
| Build artifacts are written to `target/<triple>/release/` in the host workspace. | ||
|
|
||
| ## File ownership | ||
|
|
||
| Because the container runs as root, files created in `target/` will be root-owned. To reclaim ownership: | ||
|
|
||
| ```bash | ||
| sudo chown -R $(id -u):$(id -g) target/ | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.