Skip to content

Commit 194b710

Browse files
Copilotbbockelm
andauthored
Add devcontainer configuration for GitHub Codespaces (#188)
Add devcontainer configuration for GitHub Codespaces --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
1 parent 7557e71 commit 194b710

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Use latest Ubuntu as base
2+
FROM ubuntu:latest
3+
4+
# Avoid warnings by switching to noninteractive
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Configure apt and install packages
8+
RUN apt-get update \
9+
&& apt-get -y install --no-install-recommends \
10+
# Build essentials and tools
11+
build-essential \
12+
cmake \
13+
ninja-build \
14+
pkg-config \
15+
git \
16+
# Required dependencies from GitHub Actions workflow
17+
libssl-dev \
18+
sqlite3 \
19+
libsqlite3-dev \
20+
libcurl4 \
21+
libcurl4-openssl-dev \
22+
uuid-dev \
23+
libgtest-dev \
24+
# C++ development and debugging tools
25+
gdb \
26+
gdbserver \
27+
valgrind \
28+
clang \
29+
clang-format \
30+
clang-tidy \
31+
lldb \
32+
# Additional utilities
33+
curl \
34+
wget \
35+
vim \
36+
nano \
37+
htop \
38+
tree \
39+
zip \
40+
unzip \
41+
ca-certificates \
42+
sudo \
43+
# Clean up
44+
&& apt-get autoremove -y \
45+
&& apt-get clean -y \
46+
&& rm -rf /var/lib/apt/lists/*
47+
48+
# Create a non-root user to use
49+
ARG USERNAME=vscode
50+
ARG USER_UID=1000
51+
ARG USER_GID=$USER_UID
52+
53+
RUN groupadd --gid $USER_GID $USERNAME \
54+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
55+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
56+
&& chmod 0440 /etc/sudoers.d/$USERNAME
57+
58+
# Switch back to dialog for any ad-hoc use of apt-get
59+
ENV DEBIAN_FRONTEND=dialog
60+
61+
# Set the default user
62+
USER $USERNAME

.devcontainer/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# SciTokens C++ Development Container
2+
3+
This devcontainer configuration enables GitHub Codespaces and local development container support for the scitokens-cpp project.
4+
5+
## Features
6+
7+
### Base Environment
8+
- **OS**: Latest Ubuntu
9+
- **User**: Non-root `vscode` user with sudo access
10+
11+
### Build Dependencies
12+
All dependencies from the GitHub Actions workflow are included:
13+
- `libssl-dev` - OpenSSL development files
14+
- `sqlite3` and `libsqlite3-dev` - SQLite database
15+
- `cmake` - Build system
16+
- `libcurl4` and `libcurl4-openssl-dev` - HTTP client library
17+
- `uuid-dev` - UUID generation library
18+
- `libgtest-dev` - Google Test framework
19+
20+
### Development Tools
21+
- **Build Tools**: build-essential, cmake, ninja-build, pkg-config
22+
- **Debuggers**: gdb, gdbserver, lldb
23+
- **Analysis Tools**: valgrind, clang-tidy
24+
- **Compilers**: gcc/g++ (via build-essential), clang
25+
- **Formatters**: clang-format
26+
- **Utilities**: git, curl, wget, vim, nano, htop, tree
27+
28+
### VSCode Extensions
29+
- C/C++ Extension Pack
30+
- CMake Tools
31+
- CMake Language Support
32+
- GitHub Copilot (if available)
33+
34+
## Usage
35+
36+
### GitHub Codespaces
37+
1. Navigate to the repository on GitHub
38+
2. Click the "Code" button
39+
3. Select "Codespaces" tab
40+
4. Click "Create codespace on [branch]"
41+
42+
### Local Development with VSCode
43+
1. Install [Docker](https://www.docker.com/products/docker-desktop)
44+
2. Install [VSCode](https://code.visualstudio.com/)
45+
3. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
46+
4. Open the repository in VSCode
47+
5. Click "Reopen in Container" when prompted (or use Command Palette: "Dev Containers: Reopen in Container")
48+
49+
## Building the Project
50+
51+
After the container is created, submodules are automatically initialized. To build:
52+
53+
```bash
54+
# Create build directory
55+
mkdir -p build
56+
cd build
57+
58+
# Configure with CMake
59+
cmake .. -DCMAKE_BUILD_TYPE=Release -DSCITOKENS_BUILD_UNITTESTS=ON
60+
61+
# Build
62+
cmake --build .
63+
64+
# Run tests
65+
ctest --verbose
66+
```
67+
68+
## Debugging
69+
70+
The container includes both GDB and LLDB debuggers. You can:
71+
- Use VSCode's integrated debugging features
72+
- Run debuggers from the terminal
73+
- Use valgrind for memory analysis
74+
75+
Example using GDB:
76+
```bash
77+
gdb ./scitokens-test
78+
```

.devcontainer/devcontainer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "SciTokens C++ Development",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
7+
// Configure tool-specific properties.
8+
"customizations": {
9+
"vscode": {
10+
"settings": {
11+
"terminal.integrated.defaultProfile.linux": "bash",
12+
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
13+
},
14+
"extensions": [
15+
"ms-vscode.cpptools",
16+
"ms-vscode.cpptools-extension-pack",
17+
"ms-vscode.cmake-tools",
18+
"twxs.cmake",
19+
"github.copilot",
20+
"github.copilot-chat"
21+
]
22+
}
23+
},
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
// "forwardPorts": [],
27+
28+
// Use 'postCreateCommand' to run commands after the container is created.
29+
"postCreateCommand": "git submodule update --init --recursive",
30+
31+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
32+
"remoteUser": "vscode",
33+
34+
"features": {
35+
"ghcr.io/devcontainers/features/git:1": {}
36+
}
37+
}

0 commit comments

Comments
 (0)