Skip to content
Closed
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
43 changes: 43 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM mcr.microsoft.com/devcontainers/base:debian

# Set non-interactive frontend for apt
ENV DEBIAN_FRONTEND=noninteractive

# Switch to root for installing packages
USER root

# Install additional dependencies
RUN apt update && apt install -y \
curl \
jq \
python3 \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js 20.x using NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt update && \
apt install -y nodejs && \
apt clean && \
rm -rf /var/lib/apt/lists/*

# Install Claude Code
RUN npm install -g @anthropic-ai/claude-code

# Ensure all users have access to the tools
RUN chmod 755 /usr/local/bin/* && \
# Create a directory for vscode user's binaries
mkdir -p /home/vscode/.local/bin && \
chown -R vscode:vscode /home/vscode/.local/bin

# Switch back to vscode user
USER vscode

# Set environment variables
ENV PATH="/home/vscode/.local/bin:/root/.local/bin:$PATH"

# Create .bashrc additions for PATH
RUN echo 'export PATH="/usr/local/bin:$HOME/.local/bin:$PATH"' >> $HOME/.bashrc

# Set the default command
CMD ["sleep", "infinity"]
41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "GIP",
"dockerComposeFile": [
"docker-compose.yml"
],
"service": "dev-gip",
"features": {
"ghcr.io/devcontainers/features/git:1": {
"configureGitHubCLI": true,
"gitCredentialHelper": "cache"
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/common-utils:2.5.3": {}
},
"postCreateCommand": ".devcontainer/project-setup.sh",
"remoteUser": "vscode",
"workspaceFolder": "/work",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.cwd": "/work"
},
"extensions": [
"tamasfe.even-better-toml",
"usernamehw.errorlens",
"yzhang.markdown-all-in-one",
"DavidAnson.vscode-markdownlint",
"shd101wyy.markdown-preview-enhanced",
"bierner.markdown-preview-github-styles",
"Gruntfuggly.todo-tree",
"donjayamanne.githistory",
"eamodio.gitlens",
"fill-labs.dependi",
"streetsidesoftware.code-spell-checker",
"Augment.vscode-augment",
"foundry-rs.foundry-vscode",
"BlueGlassBlock.better-json5"
]
}
}
}
15 changes: 15 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
dev-gip:
build:
context: .
dockerfile: Dockerfile
env_file:
- /opt/configs/graphprotocol/gip.env
working_dir: /work
user: "vscode"
volumes:
# Workspace
- ../:/work

# Git repo root
- /git:/git
70 changes: 70 additions & 0 deletions .devcontainer/project-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
# Project-specific setup script for graph
set -euo pipefail

echo "Running project-specific setup for graph..."

# Get the script directory and repository root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

echo "Script directory: $SCRIPT_DIR"
echo "Repository root: $REPO_ROOT"

# Set up local user directories with proper permissions
echo "Setting up local user directories..."

# Ensure all user directories exist and have proper ownership
sudo mkdir -p /home/vscode/.cache /home/vscode/.config /home/vscode/.local/share /home/vscode/.local/bin
sudo chown -R vscode:vscode /home/vscode/.cache /home/vscode/.config /home/vscode/.local
sudo chmod -R 755 /home/vscode/.cache /home/vscode/.config /home/vscode/.local

echo "User directories set up with proper permissions"

# Add CONTAINER_BIN_PATH to PATH if it's set
if [ -n "${CONTAINER_BIN_PATH:-}" ]; then
echo "CONTAINER_BIN_PATH is set to: $CONTAINER_BIN_PATH"
echo "Adding CONTAINER_BIN_PATH to PATH..."

# Add to current PATH
export PATH="$CONTAINER_BIN_PATH:$PATH"

# Add to .bashrc if not already there
if ! grep -q "export PATH=\"\$CONTAINER_BIN_PATH:\$PATH\"" "$HOME/.bashrc"; then
echo "Adding CONTAINER_BIN_PATH to .bashrc..."
echo '
# Add CONTAINER_BIN_PATH to PATH if set
if [ -n "${CONTAINER_BIN_PATH:-}" ]; then
export PATH="$CONTAINER_BIN_PATH:$PATH"
fi' >> "$HOME/.bashrc"
fi

echo "CONTAINER_BIN_PATH added to PATH"
else
echo "CONTAINER_BIN_PATH is not set, skipping PATH modification"
fi

# Source shell customizations if available in PATH
if command -v shell-customizations &> /dev/null; then
SHELL_CUSTOMIZATIONS_PATH=$(command -v shell-customizations)
echo "Found shell customizations in PATH at: ${SHELL_CUSTOMIZATIONS_PATH}"
echo "Sourcing shell customizations..."
source "${SHELL_CUSTOMIZATIONS_PATH}"

# Add to .bashrc if not already there
if ! grep -q "source.*shell-customizations" "$HOME/.bashrc"; then
echo "Adding shell customizations to .bashrc..."
echo "source ${SHELL_CUSTOMIZATIONS_PATH}" >> "$HOME/.bashrc"
fi
else
echo "Shell customizations not found in PATH, skipping..."
fi

# Set up Git SSH signing
if [ -f "$SCRIPT_DIR/setup-git-signing.sh" ]; then
"$SCRIPT_DIR/setup-git-signing.sh"
else
echo "WARNING: setup-git-signing.sh not found, skipping Git SSH signing setup"
fi

echo "Project-specific setup completed"
76 changes: 76 additions & 0 deletions .devcontainer/setup-git-signing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# Automatically configure Git to use SSH signing with forwarded SSH keys
set -euo pipefail

echo "Setting up Git SSH signing..."

# Check if SSH agent forwarding is working
if ! ssh-add -l &>/dev/null; then
echo "ERROR: No SSH keys found in agent. SSH agent forwarding is not set up correctly."
echo "SSH signing will not work without SSH agent forwarding."
exit 1
fi

# Get the first SSH key from the agent
SSH_KEY=$(ssh-add -L | head -n 1)
if [ -z "$SSH_KEY" ]; then
echo "ERROR: No SSH keys found in agent. SSH signing will not work."
exit 1
fi

# Extract the key type and key content
KEY_TYPE=$(echo "$SSH_KEY" | awk '{print $1}')
KEY_CONTENT=$(echo "$SSH_KEY" | awk '{print $2}')

# Check if Git user settings are available
if [[ -z "${GIT_USER_NAME:-}" || -z "${GIT_USER_EMAIL:-}" ]]; then
echo "WARNING: Git user settings (GIT_USER_NAME and/or GIT_USER_EMAIL) are not set."
echo "Git commit signing will not be configured."
echo "If you need Git commit signing, add these variables to your environment file."
exit 0
fi

# Set Git user name from environment variable
echo "Setting Git user.name: $GIT_USER_NAME"
git config --global user.name "$GIT_USER_NAME"

# Set Git user email from environment variable
echo "Setting Git user.email: $GIT_USER_EMAIL"
git config --global user.email "$GIT_USER_EMAIL"

# Create the .ssh directory if it doesn't exist
mkdir -p ~/.ssh
chmod 700 ~/.ssh

# Create or update the allowed signers file
echo "Updating allowed signers file..."
ALLOWED_SIGNERS_FILE=~/.ssh/allowed_signers
SIGNER_LINE="$GIT_USER_EMAIL $KEY_TYPE $KEY_CONTENT"

# Create the file if it doesn't exist
if [ ! -f "$ALLOWED_SIGNERS_FILE" ]; then
echo "$SIGNER_LINE" > "$ALLOWED_SIGNERS_FILE"
echo "Created new allowed signers file."
else
# Check if the key is already in the file
if ! grep -q "$KEY_CONTENT" "$ALLOWED_SIGNERS_FILE"; then
# Append the key if it's not already there
echo "$SIGNER_LINE" >> "$ALLOWED_SIGNERS_FILE"
echo "Added new key to allowed signers file."
else
echo "Key already exists in allowed signers file."
fi
fi

chmod 600 "$ALLOWED_SIGNERS_FILE"

# Configure Git to use SSH signing
echo "Configuring Git to use SSH signing..."
git config --global gpg.format ssh
git config --global user.signingkey "key::$KEY_TYPE $KEY_CONTENT"
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
git config --global commit.gpgsign true

echo "Git SSH signing setup complete!"
echo "Your commits will now be automatically signed using your SSH key."
echo "Make sure this key is added to GitHub as a signing key in your account settings."
Loading