-
Notifications
You must be signed in to change notification settings - Fork 926
Add devcontainer build env #3277
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "SRT Development", | ||
| "dockerFile": "../docker/Dockerfile", | ||
| "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" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
|
|
||
| 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"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Building SRT Using Devcontainer or Docker | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ethouris
.devcontainer/devcontainer.jsonneeds 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...