Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docker/Dockerfile.linux
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
67 changes: 67 additions & 0 deletions docker/Makefile
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
48 changes: 48 additions & 0 deletions docker/README.md
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/
```
Loading