From dfc4bc7dd0a28d3e9642cb5ae040f15a3d229c55 Mon Sep 17 00:00:00 2001 From: whaffman Date: Tue, 23 Sep 2025 16:09:53 +0000 Subject: [PATCH] feat(devcontainer): add Dockerfile and devcontainer.json for C++ development setup --- .devcontainer/Dockerfile | 55 +++++++++++++++++++++++ .devcontainer/devcontainer.json | 78 +++++++++++++++++++++++++++++++++ 2 files changed, 133 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 0000000..5f54dcb --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,55 @@ +FROM ubuntu:22.04 + +# Set environment variables for non-interactive installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install essential development tools +RUN apt-get update && apt-get install -y \ + # Build essentials + build-essential \ + clang \ + clang-format \ + clang-tidy \ + clangd \ + lldb \ + # Build tools + cmake \ + make \ + ninja-build \ + pkg-config \ + # Version control and utilities + git \ + wget \ + curl \ + unzip \ + # Development utilities + gdb \ + valgrind \ + strace \ + # Network tools for web server testing + netcat \ + telnet \ + # Text processing + vim \ + nano \ + # Clean up + && rm -rf /var/lib/apt/lists/* + +# Create a non-root user for development +RUN groupadd --gid 1000 vscode \ + && useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \ + && apt-get update \ + && apt-get install -y sudo \ + && echo vscode ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/vscode \ + && chmod 0440 /etc/sudoers.d/vscode \ + && rm -rf /var/lib/apt/lists/* + +# Set clang as the default compiler +ENV CC=clang +ENV CXX=clang++ + +# Set working directory +WORKDIR /workspace + +# Switch to non-root user +USER vscode \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..5eccf66 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,78 @@ +{ + "name": "C++ Development Container", + "dockerFile": "Dockerfile", + + // Configure tool-specific properties + "customizations": { + "vscode": { + // Essential C++ development extensions + "extensions": [ + "ms-vscode.cpptools-extension-pack", + "ms-vscode.cpptools", + "ms-vscode.cpptools-themes", + "ms-vscode.cmake-tools", + "xaver.clang-format", + "usernamehw.errorlens", + "llvm-vs-code-extensions.vscode-clangd", + "ms-vscode.hexeditor", + "eamodio.gitlens", + "ms-vscode-remote.remote-containers" + ], + + // Container-specific VS Code settings + "settings": { + "C_Cpp.default.compilerPath": "/usr/bin/clang++", + "C_Cpp.default.cStandard": "c17", + "C_Cpp.default.cppStandard": "c++20", + "C_Cpp.default.intelliSenseMode": "linux-clang-x64", + "cmake.configureOnOpen": false, + "clang-format.executable": "/usr/bin/clang-format", + "editor.formatOnSave": true, + "[cpp]": { + "editor.defaultFormatter": "xaver.clang-format" + }, + "[c]": { + "editor.defaultFormatter": "xaver.clang-format" + }, + "files.associations": { + "*.hpp": "cpp", + "*.tpp": "cpp" + } + } + } + }, + + // Container configuration + "workspaceFolder": "/workspace", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", + + // Development user setup + "remoteUser": "vscode", + + // Container lifecycle hooks + "postCreateCommand": "echo 'Container ready for C++ development!'", + + // Port forwarding for web server testing + "forwardPorts": [8080, 3000], + "portsAttributes": { + "8080": { + "label": "WebServ Server", + "onAutoForward": "notify" + }, + "3000": { + "label": "Development Server", + "onAutoForward": "silent" + } + }, + + // Container features + "features": { + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + + // Mount points for better performance + "mounts": [ + "source=webserv-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume" + ] +} \ No newline at end of file