Skip to content

Commit f297d38

Browse files
committed
Add C++ development environment configuration with Docker and scripts
Signed-off-by: Vladislav Polyakov <polRk@ydb.tech>
1 parent a2817be commit f297d38

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04
2+
3+
# Install software-properties-common for add-apt-repository
4+
RUN apt-get update && apt-get -y install software-properties-common
5+
6+
# Install C++ tools and libraries
7+
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get -y update && apt-get -y install \
8+
git cmake ninja-build libidn11-dev ragel yasm protobuf-compiler \
9+
protobuf-compiler-grpc libprotobuf-dev libgrpc++-dev libgrpc-dev libgrpc++1 libgrpc10 \
10+
rapidjson-dev zlib1g-dev libxxhash-dev libzstd-dev libsnappy-dev libgtest-dev libgmock-dev \
11+
libbz2-dev libdouble-conversion-dev libstdc++-13-dev liblz4-dev libssl-dev \
12+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
13+
14+
# Install LLVM
15+
RUN wget https://apt.llvm.org/llvm.sh && \
16+
chmod u+x llvm.sh && \
17+
./llvm.sh 16
18+
19+
# Update alternatives to use clang-16 and clang++-16 by default
20+
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100 && \
21+
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-16 100 && \
22+
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100
23+
24+
# Install libiconv
25+
ENV LIBICONV_VERSION=1.15
26+
RUN wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz && \
27+
tar -xvzf libiconv-${LIBICONV_VERSION}.tar.gz && cd libiconv-${LIBICONV_VERSION} && \
28+
./configure --prefix=/usr/local && \
29+
make && \
30+
make install
31+
32+
# Install base64
33+
ENV BASE64_VERSION=0.5.2
34+
RUN wget -O base64-${BASE64_VERSION}.tar.gz https://github.com/aklomp/base64/archive/refs/tags/v${BASE64_VERSION}.tar.gz && \
35+
tar -xvzf base64-${BASE64_VERSION}.tar.gz && cd base64-${BASE64_VERSION} && \
36+
mkdir build && cd build && \
37+
cmake -DCMAKE_BUILD_TYPE=Release .. && \
38+
cmake --build . --config Release --target install
39+
40+
# Install brotli
41+
ENV BROTLI_VERSION=1.1.0
42+
RUN wget -O brotli-${BROTLI_VERSION}.tar.gz https://github.com/google/brotli/archive/refs/tags/v${BROTLI_VERSION}.tar.gz && \
43+
tar -xvzf brotli-${BROTLI_VERSION}.tar.gz && cd brotli-${BROTLI_VERSION} && \
44+
mkdir build && cd build && \
45+
cmake -DCMAKE_BUILD_TYPE=Release .. && \
46+
cmake --build . --config Release --target install
47+
48+
# Install jwt-cpp
49+
ENV JWT_CPP_VERSION=0.7.0
50+
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 && \
51+
tar -xvzf jwt-cpp-${JWT_CPP_VERSION}.tar.gz && cd jwt-cpp-${JWT_CPP_VERSION} && \
52+
mkdir build && cd build && \
53+
cmake -DCMAKE_BUILD_TYPE=Release .. && \
54+
cmake --build . --config Release --target install
55+
56+
# Install ccache 4.8.1 or above
57+
ENV CCACHE_VERSION=4.8.1
58+
RUN wget https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz \
59+
&& tar -xf ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz \
60+
&& cp ccache-${CCACHE_VERSION}-linux-x86_64/ccache /usr/local/bin/ \
61+
&& rm -rf ccache-${CCACHE_VERSION}-linux-x86_64 ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz

.devcontainer/configure.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
WORKSPACE_FOLDER=$1
3+
4+
cd $1
5+
cmake --preset release -DCMAKE_EXPORT_COMPILE_COMMANDS=1

.devcontainer/devcontainer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "C++",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"options": [
8+
"--platform",
9+
"linux/amd64"
10+
]
11+
},
12+
// Features to add to the dev container. More info: https://containers.dev/features.
13+
"features": {
14+
"ghcr.io/devcontainers/features/github-cli:1": {
15+
"installDirectlyFromGitHubRelease": true,
16+
"version": "latest"
17+
}
18+
},
19+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
20+
"forwardPorts": [],
21+
"initializeCommand": "cd \"${localWorkspaceFolder}\" && git config --local user.email \"$(git config user.email)\" && git config --local user.name \"$(git config user.name)\"",
22+
// Use 'postCreateCommand' to run commands after the container is created.
23+
"postCreateCommand": ".devcontainer/configure.sh ${containerWorkspaceFolder}",
24+
// Configure tool-specific properties.
25+
"customizations": {
26+
"vscode": {
27+
"extensions": [
28+
"ms-vscode.cpptools",
29+
"ms-vscode.cmake-tools",
30+
"twxs.cmake",
31+
"ms-vscode.cpptools-extension-pack",
32+
"llvm-vs-code-extensions.vscode-clangd"
33+
]
34+
}
35+
},
36+
"mounts": [
37+
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind,consistency=cached"
38+
// "source=${localEnv:HOME}/.skotty,target=/root/.skotty,type=bind,consistency=cached"
39+
],
40+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
41+
"remoteUser": "root"
42+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ llvm.sh
7676

7777
# User CMake presets
7878
CMakeUserPresets.json
79+
80+
# Dev Containers
81+
!.devcontainer/Dockerfile

0 commit comments

Comments
 (0)