Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Use latest Ubuntu as base
FROM ubuntu:latest

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
# Build essentials and tools
build-essential \
cmake \
ninja-build \
pkg-config \
git \
# Required dependencies from GitHub Actions workflow
libssl-dev \
sqlite3 \
libsqlite3-dev \
libcurl4 \
libcurl4-openssl-dev \
uuid-dev \
libgtest-dev \
# C++ development and debugging tools
gdb \
gdbserver \
valgrind \
clang \
clang-format \
clang-tidy \
lldb \
# Additional utilities
curl \
wget \
vim \
nano \
htop \
tree \
zip \
unzip \
ca-certificates \
sudo \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Create a non-root user to use
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog

# Set the default user
USER $USERNAME
78 changes: 78 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SciTokens C++ Development Container

This devcontainer configuration enables GitHub Codespaces and local development container support for the scitokens-cpp project.

## Features

### Base Environment
- **OS**: Latest Ubuntu
- **User**: Non-root `vscode` user with sudo access

### Build Dependencies
All dependencies from the GitHub Actions workflow are included:
- `libssl-dev` - OpenSSL development files
- `sqlite3` and `libsqlite3-dev` - SQLite database
- `cmake` - Build system
- `libcurl4` and `libcurl4-openssl-dev` - HTTP client library
- `uuid-dev` - UUID generation library
- `libgtest-dev` - Google Test framework

### Development Tools
- **Build Tools**: build-essential, cmake, ninja-build, pkg-config
- **Debuggers**: gdb, gdbserver, lldb
- **Analysis Tools**: valgrind, clang-tidy
- **Compilers**: gcc/g++ (via build-essential), clang
- **Formatters**: clang-format
- **Utilities**: git, curl, wget, vim, nano, htop, tree

### VSCode Extensions
- C/C++ Extension Pack
- CMake Tools
- CMake Language Support
- GitHub Copilot (if available)

## Usage

### GitHub Codespaces
1. Navigate to the repository on GitHub
2. Click the "Code" button
3. Select "Codespaces" tab
4. Click "Create codespace on [branch]"

### Local Development with VSCode
1. Install [Docker](https://www.docker.com/products/docker-desktop)
2. Install [VSCode](https://code.visualstudio.com/)
3. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
4. Open the repository in VSCode
5. Click "Reopen in Container" when prompted (or use Command Palette: "Dev Containers: Reopen in Container")

## Building the Project

After the container is created, submodules are automatically initialized. To build:

```bash
# Create build directory
mkdir -p build
cd build

# Configure with CMake
cmake .. -DCMAKE_BUILD_TYPE=Release -DSCITOKENS_BUILD_UNITTESTS=ON

# Build
cmake --build .

# Run tests
ctest --verbose
```

## Debugging

The container includes both GDB and LLDB debuggers. You can:
- Use VSCode's integrated debugging features
- Run debuggers from the terminal
- Use valgrind for memory analysis

Example using GDB:
```bash
gdb ./scitokens-test
```
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "SciTokens C++ Development",
"build": {
"dockerfile": "Dockerfile"
},

// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
},
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cmake-tools",
"twxs.cmake",
"github.copilot",
"github.copilot-chat"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "git submodule update --init --recursive",

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "vscode",

"features": {
"ghcr.io/devcontainers/features/git:1": {}
}
}
Loading