From ac35c789ced2fe7c8a76d4284bcb5eb928a9c0bb Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 28 Aug 2024 23:09:44 -0400 Subject: [PATCH] Set up devcontainer for sparkd With config from development branch --- .devcontainer/Dockerfile | 129 ++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 43 +++++++++++ 2 files changed, 172 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..07a0b7bce --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,129 @@ +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive + +# Note installations that take a while (more than 10s) + +RUN apt-get update +RUN apt-get install -y ca-certificates +RUN apt-get install -y ccache +RUN apt-get install -y curl +RUN apt-get install -y fish +RUN apt-get install -y gdb +# git-all: ~250s +RUN apt-get install -y git-all +RUN apt-get install -y gnupg +# liblttng-ust-dev: ~30s +RUN apt-get install -y liblttng-ust-dev +RUN apt-get install -y libssh2-1-dev +RUN apt-get install -y locales +RUN apt-get install -y ninja-build +# openssh-server: ~40s +RUN apt-get install -y openssh-server +RUN apt-get install -y pkg-config +RUN apt-get install -y software-properties-common +RUN apt-get install -y sudo +RUN apt-get install -y tzdata +RUN apt-get install -y vim +RUN apt-get install -y zip + +# Python: ~30s +RUN apt-get install -y \ + python3-pip \ + python3-venv \ + && python3 -m pip install --upgrade pip + +# GCC +ARG gcc_major=13 +RUN \ + add-apt-repository ppa:ubuntu-toolchain-r/test \ + && apt-get update \ + && apt-get install -y g++-$gcc_major + +# Clang +ARG clang_major=17 +RUN \ + curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key 2> /dev/null \ + | gpg --dearmor - \ + | tee /usr/share/keyrings/llvm-snapshot.gpg > /dev/null \ + && echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-$clang_major main" \ + | tee -a "/etc/apt/sources.list.d/llvm.list" \ + && apt-get update \ + && apt-get install -y \ + clang-$clang_major \ + clang-format-$clang_major \ + clangd-$clang_major + +# CMake +RUN \ + curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc 2> /dev/null \ + | gpg --dearmor - \ + | tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null \ + && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" \ + | tee /etc/apt/sources.list.d/kitware.list > /dev/null \ + && apt-get update \ + && apt-get install -y cmake + +# Dotnet +RUN apt-get update && apt-get install -y dotnet7 + +# Node +ARG node_major=18 +RUN mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ + | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_major.x nodistro main" \ + | tee /etc/apt/sources.list.d/nodesource.list \ + && apt-get update \ + && apt-get install -y nodejs + +# Emumba (deps) +RUN apt-get update && apt-get -y install rapidjson-dev +# Emumba +COPY emumba /emumba +RUN dpkg -i /emumba/emumba-deribit-connector-3.3.1-Linux.LICENSE_DISABLED.deb \ + && rm -r /emumba + +# Pcap +RUN apt-get update && apt-get install -y libpcap0.8-dev + +RUN apt-get update && apt-get install -y \ + docker.io \ + docker-compose \ + docker-compose-v2 + +# Set up default executables (update-alternatives) +RUN \ + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$clang_major 100; \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-$clang_major 100; \ + update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-$clang_major 100; \ + update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-$clang_major 100; \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$gcc_major 100; \ + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$gcc_major 100 + +# Add compiler symlinks for ccache +RUN \ + ln -s /usr/bin/ccache /usr/local/bin/clang; \ + ln -s /usr/bin/ccache /usr/local/bin/clang++; \ + ln -s /usr/bin/ccache /usr/local/bin/clang-$clang_major; \ + ln -s /usr/bin/ccache /usr/local/bin/clang++-$clang_major; \ + ln -s /usr/bin/ccache /usr/local/bin/gcc; \ + ln -s /usr/bin/ccache /usr/local/bin/g++ + +RUN locale-gen en_US.UTF-8 + +ARG docker_user="bts" +ARG docker_uid="1000" +ARG docker_pass="bts" + +RUN \ + groupadd -g "$docker_uid" "$docker_user" \ + && useradd \ + -m \ + -u "$docker_uid" \ + -g "$docker_uid" \ + -G sudo \ + --password "$(openssl passwd -1 "$docker_pass")" \ + "$docker_user" + +RUN usermod -aG docker "$docker_user" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..4f9bf86dc --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,43 @@ +{ + "dockerFile": "Dockerfile", + // Creates local dir to mount to HOME in docker + "initializeCommand": "mkdir -p ${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId}", + "hostRequirements": { + "memory": "4gb", + "storage": "6gb" + }, + "postCreateCommand": "/home/bts/spark/docker/sparkd/dev/devcontainer_post_create.sh", + "containerUser": "bts", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/bts/spark,type=bind", + "workspaceFolder": "/home/bts/spark", + "updateRemoteUserUID": true, + "shutdownAction": "none", + // Note: If running multiple containers on the same host, each must use a + // unique set of ports. Usually we just add 1000 to each port as needed. For + // example, if 8000-8003 is taken, go with 9000-9003, then 10000-10003, etc. + "runArgs": [ + "--shm-size", + "2gb", + "--network", + "host" + ], + "mounts": [ + "source=${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId},target=/home/bts,type=bind", + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], + "customizations": { + "vscode": { + "settings": { + "clangd.arguments": [ + "--compile-commands-dir=${workspaceFolder}/build/clang/debug" + ] + }, + "extensions": [ + "eamodio.gitlens", + "llvm-vs-code-extensions.vscode-clangd", + "ms-vscode.cmake-tools", + "ms-vscode.cpptools" + ] + } + } +}