From 48bb57b6a5457a7ed950e7b5c2a006ca3f37c32b Mon Sep 17 00:00:00 2001 From: RS Date: Tue, 12 Aug 2025 08:23:23 +0000 Subject: [PATCH 1/2] Docker and devcontainer files for development in an ubuntu container --- .devcontainer/devcontainer.json | 19 +++++++++++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 4 ++++ 3 files changed, 53 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..2766e58 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +// .devcontainer/devcontainer.json +{ + "name": "ModernCppStarter", + "context": "..", + "dockerFile": "../Dockerfile", + "customizations": { + "vscode": { + "settings": { + "C_Cpp.default.compilerPath": "/usr/bin/clang++", + "cmake.generator": "Ninja" + }, + "extensions": [ + "ms-vscode.cmake-tools", + "ms-vscode.cpptools", + "twxs.cmake" + ] + } + } +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0afc8d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use official Ubuntu image +FROM ubuntu:22.04 + +# Install dependencies +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential \ + cmake \ + ninja-build \ + git \ + curl \ + gdb \ + lldb \ + python3 \ + python3-pip \ + python3-jinja2 \ + clang \ + clang-tidy \ + lcov \ + doxygen \ + meson \ + libpsl-dev \ + sudo \ + pkg-config \ + && apt-get clean + +RUN pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml + +# Load shell. +CMD ["/bin/bash"] diff --git a/README.md b/README.md index 46b6226..18354a7 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,10 @@ Additional arguments can be passed to the analyzers by setting the `CLANG_TIDY_A Ccache can be enabled by configuring with `-DUSE_CCACHE=`. +#### Devcontainer + +The project includes a dockerfile along with a devcontainer file which allows for development in a docker container. Open the project folder in VS Code and you should be prompted to reopen the project in a container. + ## FAQ > Can I use this for header-only libraries? From a4cedc75ff37d42e29d41550eb80ad5649ba402e Mon Sep 17 00:00:00 2001 From: RS Date: Wed, 13 Aug 2025 08:13:51 +0000 Subject: [PATCH 2/2] Update docker image to use Ubuntu's current LTS and fix ghostscript warning --- Dockerfile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0afc8d8..6ac81d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use official Ubuntu image -FROM ubuntu:22.04 +FROM ubuntu:24.04 # Install dependencies RUN apt-get update && \ @@ -13,7 +13,7 @@ RUN apt-get update && \ lldb \ python3 \ python3-pip \ - python3-jinja2 \ + python3-venv \ clang \ clang-tidy \ lcov \ @@ -22,9 +22,20 @@ RUN apt-get update && \ libpsl-dev \ sudo \ pkg-config \ + ghostscript \ && apt-get clean -RUN pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml +# Create and activate a virtual environment for Python tools +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" -# Load shell. +# Set CLANG_FORMAT_EXECUTABLE environment variable to use clang-format from the venv +RUN ln -s /opt/venv/bin/clang-format /usr/local/bin/clang-format + +# Upgrade pip and install Python packages in venv +RUN pip install --upgrade pip && \ + pip install clang-format==14.0.6 cmake_format==0.6.11 pyyaml jinja2 pygments + +# Load shell CMD ["/bin/bash"]