|
| 1 | +# Building SRT Using Devcontainer or Docker |
| 2 | + |
| 3 | +This guide describes how to use the provided Devcontainer or Dockerfile to set up a consistent build environment for SRT. |
| 4 | + |
| 5 | +## VS Code Devcontainer (Recommended) |
| 6 | + |
| 7 | +The devcontainer provides the easiest and most integrated development experience with VS Code. |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- [Visual Studio Code](https://code.visualstudio.com/) |
| 12 | +- [Docker Desktop](https://www.docker.com/products/docker-desktop) or Docker Engine |
| 13 | +- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code |
| 14 | + |
| 15 | +### Steps |
| 16 | + |
| 17 | +1. Open the SRT repository in VS Code |
| 18 | + |
| 19 | + ```console |
| 20 | + $ code </path/to/srt> |
| 21 | + ``` |
| 22 | + |
| 23 | +2. Open in Container |
| 24 | + |
| 25 | + - VS Code should prompt you to "Reopen in Container" |
| 26 | + - Alternatively, press `F1` and select `Dev Containers: Reopen in Container` |
| 27 | + |
| 28 | +3. Run Spell Check |
| 29 | + |
| 30 | + ```console |
| 31 | + $ cd </path/to/srt> |
| 32 | + $ codespell --config scripts/codespell/codespell.cfg |
| 33 | + ``` |
| 34 | + |
| 35 | +4. Build SRT Inside the Container |
| 36 | + |
| 37 | + ```console |
| 38 | + $ mkdir _build && cd _build |
| 39 | + $ 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 |
| 40 | + $ cmake --build . --parallel |
| 41 | + ``` |
| 42 | + |
| 43 | +5. Run Tests |
| 44 | + |
| 45 | + ```console |
| 46 | + $ cd _build |
| 47 | + $ ctest --extra-verbose |
| 48 | + ``` |
| 49 | + |
| 50 | +## Dockerfile |
| 51 | + |
| 52 | +If you prefer not to use VS Code or want to use the Dockerfile independently, you can build and run the container manually. |
| 53 | + |
| 54 | +### Prerequisites |
| 55 | + |
| 56 | +- [Docker Desktop](https://www.docker.com/products/docker-desktop) or Docker Engine |
| 57 | + |
| 58 | +### Steps |
| 59 | + |
| 60 | +1. Build the Docker Image |
| 61 | + |
| 62 | + ```console |
| 63 | + $ cd </path/to/srt> |
| 64 | + $ docker build -t srt-build-env -f docker/Dockerfile . |
| 65 | + ``` |
| 66 | + |
| 67 | +2. Run the Container |
| 68 | + |
| 69 | + Mount the SRT source directory into the container: |
| 70 | + ```console |
| 71 | + $ docker run -it --rm -v "$(pwd)":/srt_build_env -w /srt_build_env srt-build-env |
| 72 | + ``` |
| 73 | + |
| 74 | +3. Run Spell Check |
| 75 | + |
| 76 | + ```console |
| 77 | + $ cd </path/to/srt> |
| 78 | + $ codespell --config scripts/codespell/codespell.cfg |
| 79 | + ``` |
| 80 | + |
| 81 | +4. Build SRT Inside the Container |
| 82 | + |
| 83 | + ```console |
| 84 | + $ mkdir _build && cd _build |
| 85 | + $ 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 |
| 86 | + $ cmake --build . --parallel |
| 87 | + ``` |
| 88 | + |
| 89 | +5. Run Tests |
| 90 | + |
| 91 | + ```console |
| 92 | + $ cd _build |
| 93 | + $ ctest --extra-verbose |
| 94 | + ``` |
| 95 | + |
| 96 | +6. Exit the Container |
| 97 | + |
| 98 | + ```console |
| 99 | + $ exit |
| 100 | + ``` |
0 commit comments