-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add C++ development environment configuration with Docker and scripts
Signed-off-by: Vladislav Polyakov <[email protected]>
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,61 @@ | ||
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04 | ||
|
||
# Install software-properties-common for add-apt-repository | ||
RUN apt-get update && apt-get -y install software-properties-common | ||
|
||
# Install C++ tools and libraries | ||
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get -y update && apt-get -y install \ | ||
git cmake ninja-build libidn11-dev ragel yasm protobuf-compiler \ | ||
protobuf-compiler-grpc libprotobuf-dev libgrpc++-dev libgrpc-dev libgrpc++1 libgrpc10 \ | ||
rapidjson-dev zlib1g-dev libxxhash-dev libzstd-dev libsnappy-dev libgtest-dev libgmock-dev \ | ||
libbz2-dev libdouble-conversion-dev libstdc++-13-dev liblz4-dev libssl-dev \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install LLVM | ||
RUN wget https://apt.llvm.org/llvm.sh && \ | ||
chmod u+x llvm.sh && \ | ||
./llvm.sh 16 | ||
|
||
# Update alternatives to use clang-16 and clang++-16 by default | ||
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 && \ | ||
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-16 100 && \ | ||
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100 | ||
|
||
# Install libiconv | ||
ENV LIBICONV_VERSION=1.15 | ||
RUN wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz && \ | ||
tar -xvzf libiconv-${LIBICONV_VERSION}.tar.gz && cd libiconv-${LIBICONV_VERSION} && \ | ||
./configure --prefix=/usr/local && \ | ||
make && \ | ||
make install | ||
|
||
# Install base64 | ||
ENV BASE64_VERSION=0.5.2 | ||
RUN wget -O base64-${BASE64_VERSION}.tar.gz https://github.com/aklomp/base64/archive/refs/tags/v${BASE64_VERSION}.tar.gz && \ | ||
tar -xvzf base64-${BASE64_VERSION}.tar.gz && cd base64-${BASE64_VERSION} && \ | ||
mkdir build && cd build && \ | ||
cmake -DCMAKE_BUILD_TYPE=Release .. && \ | ||
cmake --build . --config Release --target install | ||
|
||
# Install brotli | ||
ENV BROTLI_VERSION=1.1.0 | ||
RUN wget -O brotli-${BROTLI_VERSION}.tar.gz https://github.com/google/brotli/archive/refs/tags/v${BROTLI_VERSION}.tar.gz && \ | ||
tar -xvzf brotli-${BROTLI_VERSION}.tar.gz && cd brotli-${BROTLI_VERSION} && \ | ||
mkdir build && cd build && \ | ||
cmake -DCMAKE_BUILD_TYPE=Release .. && \ | ||
cmake --build . --config Release --target install | ||
|
||
# Install jwt-cpp | ||
ENV JWT_CPP_VERSION=0.7.0 | ||
RUN wget -O jwt-cpp-${JWT_CPP_VERSION}.tar.gz https://github.com/Thalhammer/jwt-cpp/archive/refs/tags/v${JWT_CPP_VERSION}.tar.gz && \ | ||
tar -xvzf jwt-cpp-${JWT_CPP_VERSION}.tar.gz && cd jwt-cpp-${JWT_CPP_VERSION} && \ | ||
mkdir build && cd build && \ | ||
cmake -DCMAKE_BUILD_TYPE=Release .. && \ | ||
cmake --build . --config Release --target install | ||
|
||
# Install ccache 4.8.1 or above | ||
ENV CCACHE_VERSION=4.8.1 | ||
RUN wget https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz \ | ||
&& tar -xf ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz \ | ||
&& cp ccache-${CCACHE_VERSION}-linux-x86_64/ccache /usr/local/bin/ \ | ||
&& rm -rf ccache-${CCACHE_VERSION}-linux-x86_64 ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz |
This file contains 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,7 @@ | ||
#!/bin/sh | ||
WORKSPACE_FOLDER=$1 | ||
|
||
cd $1 | ||
mkdir -p build | ||
git submodule update --init --recursive | ||
cmake --preset release-test -DCMAKE_EXPORT_COMPILE_COMMANDS=1 |
This file contains 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,38 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp | ||
{ | ||
"name": "C++", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"options": [ | ||
"--platform", | ||
"linux/amd64" | ||
] | ||
}, | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/github-cli:1": { | ||
"installDirectlyFromGitHubRelease": true, | ||
"version": "latest" | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [], | ||
"initializeCommand": "cd \"${localWorkspaceFolder}\" && git config --local user.email \"$(git config user.email)\" && git config --local user.name \"$(git config user.name)\"", | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": ".devcontainer/configure.sh ${containerWorkspaceFolder}", | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"ms-vscode.cmake-tools", | ||
"twxs.cmake", | ||
"ms-vscode.cpptools-extension-pack", | ||
"llvm-vs-code-extensions.vscode-clangd" | ||
] | ||
} | ||
}, | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
"remoteUser": "root" | ||
} |
This file contains 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 |
---|---|---|
|
@@ -76,3 +76,6 @@ llvm.sh | |
|
||
# User CMake presets | ||
CMakeUserPresets.json | ||
|
||
# Dev Containers | ||
!.devcontainer/Dockerfile |