From eb76c38bb4cdee3dc1f2cc8423721ea0a948e730 Mon Sep 17 00:00:00 2001 From: kidfromjupiter Date: Sat, 17 Jan 2026 18:10:13 +0000 Subject: [PATCH] Added devcontainers --- .devcontainer/bazel/Dockerfile | 50 +++++++++++++++++ .devcontainer/bazel/devcontainer.json | 26 +++++++++ .devcontainer/bazelclion/Dockerfile | 47 ++++++++++++++++ .devcontainer/bazelclion/devcontainer.json | 52 ++++++++++++++++++ .devcontainer/bazelclion/reinstall-cmake.sh | 59 +++++++++++++++++++++ 5 files changed, 234 insertions(+) create mode 100755 .devcontainer/bazel/Dockerfile create mode 100755 .devcontainer/bazel/devcontainer.json create mode 100755 .devcontainer/bazelclion/Dockerfile create mode 100755 .devcontainer/bazelclion/devcontainer.json create mode 100755 .devcontainer/bazelclion/reinstall-cmake.sh diff --git a/.devcontainer/bazel/Dockerfile b/.devcontainer/bazel/Dockerfile new file mode 100755 index 00000000..0f8f6f5b --- /dev/null +++ b/.devcontainer/bazel/Dockerfile @@ -0,0 +1,50 @@ +FROM ubuntu:24.04 + +RUN apt-get update && apt-get install -y \ + build-essential \ + clang \ + cmake \ + git \ + curl \ + libsdbus-c++-dev \ + libssl-dev \ + libsystemd-dev \ + libcurlpp-dev \ + apt-transport-https \ + gnupg \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Installing bazel +RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg && mv bazel-archive-keyring.gpg /usr/share/keyrings \ + && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && apt update && apt install -y bazel + +RUN apt-get install -y pkg-config libasound2-dev + +RUN apt-get install -y libunistring-dev libldap-dev libkrb5-dev libgpg-error-dev gdb libc6-dbg libgtest-dev libbluetooth-dev + +#gtest +RUN apt-get update && apt-get install -y \ + googletest cmake g++ make \ + && rm -rf /var/lib/apt/lists/* \ + && cd /usr/src/googletest \ + && cmake -S . -B build \ + && cmake --build build -j"$(nproc)" \ + && cmake --install build + +# bash history +RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ + && echo "$SNIPPET" >> "/root/.bashrc" + +RUN apt-get install -y libunistring-dev libldap-dev libkrb5-dev libgpg-error-dev ca-certificates tzdata curl && update-ca-certificates && date + +WORKDIR /workspace + + +ENTRYPOINT ["/bin/bash"] +# [Optional] Uncomment this section to install additional vcpkg ports. +# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install " + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/bazel/devcontainer.json b/.devcontainer/bazel/devcontainer.json new file mode 100755 index 00000000..d5ca6a17 --- /dev/null +++ b/.devcontainer/bazel/devcontainer.json @@ -0,0 +1,26 @@ +{ + "name": "Bazel Dev Container", + "dockerFile": "Dockerfile", + "customizations": { + "vscode": { + "settings": { + "C_Cpp.default.configurationProvider": "ms-vscode.cpptools", + "C_Cpp.intelliSenseEngine": "Default" + }, + "extensions": [ + "ms-vscode.cpptools", + "bazelbuild.vscode-bazel", + "ms-vscode.cpptools-extension-pack" + ], + + } + }, + "mounts": [ + "source=${localWorkspaceFolder},target=/workspace,type=bind", + "source=bashhistory,target=/commandhistory,type=volume", + "source=${localWorkspaceFolder}/bazel-output,target=/bazel-output,type=bind", + "source=/run/dbus,target=/run/dbus,type=bind" + // "source=${localWorkspaceFolder}/build-bin,target=/workspace/bazel-bin,type=bind", + // "source=${localWorkspaceFolder}/build-out,target=/workspace/bazel-out,type=bind" + ] +} diff --git a/.devcontainer/bazelclion/Dockerfile b/.devcontainer/bazelclion/Dockerfile new file mode 100755 index 00000000..5eab4c65 --- /dev/null +++ b/.devcontainer/bazelclion/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:24.04 + +RUN apt-get update && apt-get install -y \ + build-essential \ + clang \ + cmake \ + git \ + curl \ + libsdbus-c++-dev \ + libssl-dev \ + libsystemd-dev \ + libcurlpp-dev \ + apt-transport-https \ + gnupg \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Installing bazel +RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg && mv bazel-archive-keyring.gpg /usr/share/keyrings \ + && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && apt update && apt install -y bazel + +RUN apt-get install -y pkg-config libasound2-dev + +RUN apt-get install -y libunistring-dev libldap-dev libkrb5-dev libgpg-error-dev gdb libc6-dbg googletest + +#gtest +RUN cd /usr/src/googletest +RUN cmake -S . -B build +RUN cmake --build build -j +RUN cmake --install build + +# bash history +RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ + && echo "$SNIPPET" >> "/root/.bashrc" + +RUN apt-get install -y libunistring-dev libldap-dev libkrb5-dev libgpg-error-dev ca-certificates tzdata curl && update-ca-certificates && date + +WORKDIR /workspace + + +ENTRYPOINT ["/bin/bash"] +# [Optional] Uncomment this section to install additional vcpkg ports. +# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install " + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/bazelclion/devcontainer.json b/.devcontainer/bazelclion/devcontainer.json new file mode 100755 index 00000000..0fafd692 --- /dev/null +++ b/.devcontainer/bazelclion/devcontainer.json @@ -0,0 +1,52 @@ +// 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++ Latest", + "build": { + "dockerfile": "Dockerfile" + }, + "mounts": [ + { + "source": "bashhistory", + "target": "/commandhistory", + "type": "volume" + }, + { + "source": "/run/dbus", + "target": "/run/dbus", + "type": "bind" + }, + { + "source": "${localWorkspaceFolder}/bazel-output", + "target": "/bazel-output", + "type": "bind" + } + ], + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", + "workspaceFolder": "/workspace", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "gcc -v", + + // Configure tool-specific properties. + "customizations" : { + "jetbrains" : { + "backend" : "CLion", + //"plugins":[ + // "com.google.idea.bazel.clwb", + // "com.github.copilot" + //] + } + }, + "runArgs": [ + "--network=host", + "--dns=1.1.1.1", + "--dns=8.8.8.8" + ] +} diff --git a/.devcontainer/bazelclion/reinstall-cmake.sh b/.devcontainer/bazelclion/reinstall-cmake.sh new file mode 100755 index 00000000..408b81d2 --- /dev/null +++ b/.devcontainer/bazelclion/reinstall-cmake.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +set -e + +CMAKE_VERSION=${1:-"none"} + +if [ "${CMAKE_VERSION}" = "none" ]; then + echo "No CMake version specified, skipping CMake reinstallation" + exit 0 +fi + +# Cleanup temporary directory and associated files when exiting the script. +cleanup() { + EXIT_CODE=$? + set +e + if [[ -n "${TMP_DIR}" ]]; then + echo "Executing cleanup of tmp files" + rm -Rf "${TMP_DIR}" + fi + exit $EXIT_CODE +} +trap cleanup EXIT + + +echo "Installing CMake..." +apt-get -y purge --auto-remove cmake +mkdir -p /opt/cmake + +architecture=$(dpkg --print-architecture) +case "${architecture}" in + arm64) + ARCH=aarch64 ;; + amd64) + ARCH=x86_64 ;; + *) + echo "Unsupported architecture ${architecture}." + exit 1 + ;; +esac + +CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" +CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt" +TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) + +echo "${TMP_DIR}" +cd "${TMP_DIR}" + +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O + +sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}" +sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license + +ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake +ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest