feat(devcontainer): add Dockerfile and devcontainer.json for C++ development setup
This commit is contained in:
parent
c255878b2f
commit
dfc4bc7dd0
55
.devcontainer/Dockerfile
Normal file
55
.devcontainer/Dockerfile
Normal file
@ -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
|
||||||
78
.devcontainer/devcontainer.json
Normal file
78
.devcontainer/devcontainer.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user