Added devcontainers

This commit is contained in:
kidfromjupiter
2026-01-17 18:10:13 +00:00
parent d516d0b3c1
commit eb76c38bb4
5 changed files with 234 additions and 0 deletions
+50
View File
@@ -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 <your-port-name-here>"
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
+26
View File
@@ -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"
]
}
+47
View File
@@ -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 <your-port-name-here>"
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
+52
View File
@@ -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"
]
}
+59
View File
@@ -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