refactor(devcontainer): streamline Dockerfile and update VS Code settings for Clang 12
This commit is contained in:
parent
878fe4790a
commit
15d749eae9
@ -3,33 +3,15 @@ FROM ubuntu:22.04
|
||||
# Set environment variables for non-interactive installation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install essential development tools
|
||||
# Install development tools in one layer
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Build essentials
|
||||
build-essential \
|
||||
# Add LLVM repository for specific Clang versions
|
||||
wget \
|
||||
lsb-release \
|
||||
software-properties-common \
|
||||
gnupg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install development tools - Ubuntu 22.04 approach
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Build essentials
|
||||
build-essential \
|
||||
# Check what Clang versions are available and install Clang 12 if possible
|
||||
software-properties-common \
|
||||
wget \
|
||||
gnupg \
|
||||
&& apt-get update && \
|
||||
# Install available Clang tools (Ubuntu 22.04 has clang-12 available)
|
||||
apt-get install -y \
|
||||
# Clang 12 toolchain
|
||||
clang-12 \
|
||||
clang++-12 \
|
||||
clang-format-12 \
|
||||
clang-tidy-12 \
|
||||
# clangd and lldb may have different versioning
|
||||
clangd \
|
||||
lldb \
|
||||
# Build tools
|
||||
@ -56,13 +38,13 @@ RUN apt-get update && apt-get install -y \
|
||||
# Clean up
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create symbolic links to make clang-12 the default
|
||||
# Set up Clang 12 alternatives
|
||||
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100 \
|
||||
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 100 \
|
||||
&& update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 100 \
|
||||
&& update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-12 100
|
||||
|
||||
# Create a non-root user for development
|
||||
# Create non-root user
|
||||
RUN groupadd --gid 1000 vscode \
|
||||
&& useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \
|
||||
&& apt-get update \
|
||||
@ -71,7 +53,7 @@ RUN groupadd --gid 1000 vscode \
|
||||
&& chmod 0440 /etc/sudoers.d/vscode \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set clang-12 as the default compiler
|
||||
# Set environment variables
|
||||
ENV CC=clang-12
|
||||
ENV CXX=clang++-12
|
||||
|
||||
|
||||
@ -20,12 +20,12 @@
|
||||
|
||||
// Container-specific VS Code settings
|
||||
"settings": {
|
||||
"C_Cpp.default.compilerPath": "/usr/bin/clang++",
|
||||
"C_Cpp.default.compilerPath": "/usr/bin/clang++-12",
|
||||
"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",
|
||||
"clang-format.executable": "/usr/bin/clang-format-12",
|
||||
"editor.formatOnSave": true,
|
||||
"[cpp]": {
|
||||
"editor.defaultFormatter": "xaver.clang-format"
|
||||
@ -36,27 +36,15 @@
|
||||
"files.associations": {
|
||||
"*.hpp": "cpp",
|
||||
"*.tpp": "cpp"
|
||||
},
|
||||
"vscode" : {
|
||||
"settings" : {
|
||||
"remote.SSH.forwardAgent": true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Container configuration
|
||||
"workspaceFolder": "/workspace",
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
|
||||
|
||||
// Development user setup
|
||||
// "workspaceFolder": "/workspace",
|
||||
"remoteUser": "vscode",
|
||||
|
||||
// Container lifecycle hooks
|
||||
"postCreateCommand": "echo 'Container ready for C++ development!'",
|
||||
|
||||
// Port forwarding for web server testing
|
||||
"forwardPorts": [8080, 3000],
|
||||
"portsAttributes": {
|
||||
@ -70,18 +58,12 @@
|
||||
}
|
||||
},
|
||||
|
||||
// Container features
|
||||
// Additional dev container features (SSH agent removed)
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/git:1": {},
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/sshd:1": {
|
||||
"version": "latest",
|
||||
"forwardPorts": [22]
|
||||
}
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {}
|
||||
},
|
||||
|
||||
// Mount points for better performance
|
||||
"mounts": [
|
||||
"source=webserv-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
|
||||
]
|
||||
// Simple post-create setup
|
||||
"postCreateCommand": "echo 'Dev container ready! Use GitHub CLI (gh auth login) or configure Git with HTTPS for GitHub access.'"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user