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
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "SRT Development",
"dockerFile": "../docker/Dockerfile",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethouris .devcontainer/devcontainer.json needs to be statically there, and docker file is linked as relative path. to answer your question, no we cannot move those files freely. and i am not quite sure why this is a hard requirement... if that is we can never use the devcontainer or codespace...

"workspaceFolder": "/srt_build_env",
"workspaceMount": "source=${localWorkspaceFolder},target=/srt_build_env,type=bind",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake"
]
}
},
"remoteUser": "srt-dev"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ In live streaming configurations, the SRT protocol maintains a constant end-to-e

## Build Instructions

[Linux (Ubuntu/CentOS)](./docs/build/build-linux.md) | [Windows](./docs/build/build-win.md) | [macOS](./docs/build/build-macOS.md) | [iOS](./docs/build/build-iOS.md) | [Android](./docs/build/build-android.md) | [Package Managers](./docs/build/package-managers.md)
[Linux (Ubuntu/CentOS)](./docs/build/build-linux.md) | [Windows](./docs/build/build-win.md) | [macOS](./docs/build/build-macOS.md) | [iOS](./docs/build/build-iOS.md) | [Android](./docs/build/build-android.md) | [Package Managers](./docs/build/package-managers.md) | [Devcontainer/Docker](./docs/build/build-devcontainer.md)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we talked about this is optional procedure, i added this procedure in the last.


### Requirements

Expand Down
54 changes: 54 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SRT Build Environment - Ubuntu 22.04 (Jammy)
# This Dockerfile can be used standalone or as part of a devcontainer setup

FROM ubuntu:22.04

# Set non-interactive mode for apt
ENV DEBIAN_FRONTEND=noninteractive

# Install build dependencies
RUN apt-get update && apt-get install -y \
# Build essentials
build-essential \
cmake \
gcc \
g++ \
make \
pkg-config \
# SRT dependencies
tclsh \
libssl-dev \
# Testing and code coverage
gcovr \
lcov \
# Spell checking
python3 \
python3-pip \
# Git for source control
git \
&& rm -rf /var/lib/apt/lists/*

# Install codespell using pip
RUN pip3 install --no-cache-dir codespell

# Create a non-root user for development
ARG USERNAME=srt-dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/*

# Set the default user
USER $USERNAME

# Set working directory
WORKDIR /srt_build_env

# Default command
CMD ["/bin/bash"]
100 changes: 100 additions & 0 deletions docs/build/build-container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Building SRT Using Devcontainer or Docker
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i confirmed and verified the all following procedure.

just FYI, when we open the devcontainer via vscode 1st time, it will need to build to container image. so it takes a minutes to build the docker image for devcontainer. but from the 2nd time to open the devcontainer, it just binds the environment to the already-built image, so i does not take any time to start.


This guide describes how to use the provided Devcontainer or Dockerfile to set up a consistent build environment for SRT.

## VS Code Devcontainer (Recommended)

The devcontainer provides the easiest and most integrated development experience with VS Code.

### Prerequisites

- [Visual Studio Code](https://code.visualstudio.com/)
- [Docker Desktop](https://www.docker.com/products/docker-desktop) or Docker Engine
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code

### Steps

1. Open the SRT repository in VS Code

```console
$ code </path/to/srt>
```

2. Open in Container

- VS Code should prompt you to "Reopen in Container"
- Alternatively, press `F1` and select `Dev Containers: Reopen in Container`

3. Run Spell Check

```console
$ cd </path/to/srt>
$ codespell --config scripts/codespell/codespell.cfg
```

4. Build SRT Inside the Container

```console
$ mkdir _build && cd _build
$ cmake ../ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON -DENABLE_CODE_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
$ cmake --build . --parallel
```

5. Run Tests

```console
$ cd _build
$ ctest --extra-verbose
```

## Dockerfile

If you prefer not to use VS Code or want to use the Dockerfile independently, you can build and run the container manually.

### Prerequisites

- [Docker Desktop](https://www.docker.com/products/docker-desktop) or Docker Engine

### Steps

1. Build the Docker Image

```console
$ cd </path/to/srt>
$ docker build -t srt-build-env -f docker/Dockerfile .
```

2. Run the Container

Mount the SRT source directory into the container:
```console
$ docker run -it --rm -v "$(pwd)":/srt_build_env -w /srt_build_env srt-build-env
```

3. Run Spell Check

```console
$ cd </path/to/srt>
$ codespell --config scripts/codespell/codespell.cfg
```

4. Build SRT Inside the Container

```console
$ mkdir _build && cd _build
$ cmake ../ -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=ON -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_TESTING=ON -DENABLE_EXAMPLES=ON -DENABLE_CODE_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
$ cmake --build . --parallel
```

5. Run Tests

```console
$ cd _build
$ ctest --extra-verbose
```

6. Exit the Container

```console
$ exit
```
2 changes: 1 addition & 1 deletion scripts/codespell/codespell.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ ignore-words = ./scripts/codespell/codespell_whitelist.txt
dictionary = ./scripts/codespell/codespell_dictionary.txt,-

# Skip checking files or directories.
skip = ./build/*,./.git/*
skip = ./build/*,./_build/*,./.git/*
Loading