Skip to content

Commit b7f507a

Browse files
committed
feat(container): update and simplify dev container config
1 parent b5848df commit b7f507a

File tree

5 files changed

+56
-132
lines changed

5 files changed

+56
-132
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,15 @@
1-
FROM mcr.microsoft.com/devcontainers/base:debian
2-
3-
# Set non-interactive frontend for apt
4-
ENV DEBIAN_FRONTEND=noninteractive
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
52

63
# Switch to root for installing packages
74
USER root
85

96
# Install additional dependencies
10-
RUN apt update && apt install -y \
7+
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \
118
build-essential \
12-
curl \
139
jq \
14-
python3 \
15-
python3-pip \
16-
python3-venv \
17-
pipx \
1810
&& apt clean \
1911
&& rm -rf /var/lib/apt/lists/*
2012

21-
# Install Node.js 20.x using NodeSource
22-
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
23-
apt update && \
24-
apt install -y nodejs && \
25-
apt clean && \
26-
rm -rf /var/lib/apt/lists/*
27-
28-
# Install Solidity compiler using pipx (isolated environment)
29-
RUN pipx install solc-select && \
30-
pipx ensurepath && \
31-
/root/.local/bin/solc-select install 0.8.27 && \
32-
/root/.local/bin/solc-select use 0.8.27 && \
33-
# Copy binaries to /usr/local/bin with proper permissions (not symlinks)
34-
cp /root/.local/bin/solc /usr/local/bin/solc && \
35-
cp /root/.local/bin/solc-select /usr/local/bin/solc-select && \
36-
chmod 755 /usr/local/bin/solc && \
37-
chmod 755 /usr/local/bin/solc-select && \
38-
# Make sure pipx directory is accessible
39-
chmod -R a+rx /root/.local/pipx && \
40-
# Set up for vscode user
41-
mkdir -p /home/vscode/.solc-select && \
42-
cp -r /root/.solc-select/* /home/vscode/.solc-select/ && \
43-
chown -R vscode:vscode /home/vscode/.solc-select
44-
45-
RUN npm install -g [email protected]
46-
47-
# Install cloc for code analysis
48-
RUN npm install -g cloc
49-
5013
# Install Foundry for Anvil (as root for global installation)
5114
RUN curl -L https://foundry.paradigm.xyz | bash && \
5215
/root/.foundry/bin/foundryup && \
@@ -61,10 +24,6 @@ RUN curl -L https://foundry.paradigm.xyz | bash && \
6124
chmod 755 /usr/local/bin/forge && \
6225
chmod 755 /usr/local/bin/chisel
6326

64-
# Set up pnpm
65-
RUN corepack enable && \
66-
corepack prepare [email protected] --activate
67-
6827
# Ensure all users have access to the tools
6928
RUN chmod 755 /usr/local/bin/* && \
7029
# Create a directory for vscode user's binaries

.devcontainer/README.md

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@ The dev container provides a consistent development environment with caching to
1313
1. **Docker Compose Configuration**: Defines the container setup, volume mounts, and environment variables
1414
2. **Dockerfile**: Specifies the container image and installed tools
1515
3. **project-setup.sh**: Configures the environment after container creation
16-
4. **host-setup.sh**: Sets up the host environment before starting the container
17-
5. **setup-git-signing.sh**: Automatically configures Git to use SSH signing with forwarded SSH keys
18-
19-
## Cache System
20-
21-
The container uses a conservative caching approach to prevent cache corruption issues:
22-
23-
1. **Local Cache Directories**: Each container instance maintains its own cache directories
24-
- `vscode-cache``/home/vscode/.cache` (VS Code cache)
25-
- `vscode-config``/home/vscode/.config` (VS Code configuration)
26-
- `vscode-data``/home/vscode/.local/share` (VS Code data)
27-
- `vscode-bin``/home/vscode/.local/bin` (User binaries)
28-
29-
2. **Safe Caches Only**: Only caches that won't cause cross-branch issues are configured
30-
- GitHub CLI: `/home/vscode/.cache/github`
31-
- Python packages: `/home/vscode/.cache/pip`
32-
33-
3. **Intentionally Not Cached**: These tools use their default cache locations to avoid contamination
34-
- NPM (different dependency versions per branch)
35-
- Foundry, Solidity (different compilation artifacts per branch)
36-
- Hardhat (different build artifacts per branch)
3716

3817
## Setup Instructions
3918

@@ -48,7 +27,7 @@ To start the dev container:
4827
When the container starts, the `project-setup.sh` script will automatically run and:
4928

5029
- Install project dependencies using pnpm
51-
- Configure Git to use SSH signing with your forwarded SSH key
30+
- Configure basic Git settings (user.name, user.email) from environment variables
5231
- Source shell customizations if available in PATH
5332

5433
## Environment Variables
@@ -60,10 +39,10 @@ Environment variables are defined in two places:
6039

6140
### Git Configuration
6241

63-
To enable Git commit signing, add the following settings to your environment file:
42+
To configure Git user settings, add the following to your environment file:
6443

6544
```env
66-
# Git settings for commit signing
45+
# Git settings
6746
GIT_USER_NAME=Your Name
6847
6948
```
@@ -72,34 +51,20 @@ These environment variables are needed for Git commit signing to work properly.
7251

7352
## Troubleshooting
7453

75-
### Cache Issues
54+
### Build Issues
7655

77-
If you encounter build or compilation issues that seem related to cached artifacts:
56+
If you encounter build or compilation issues:
7857

79-
1. **Rebuild the container**: This will start with fresh local caches
58+
1. **Rebuild the container**: This will start with fresh isolated caches
8059
2. **Clean project caches**: Run `pnpm clean` to clear project-specific build artifacts
8160
3. **Clear node modules**: Delete `node_modules` and run `pnpm install` again
8261

83-
### Git SSH Signing Issues
62+
### Git Authentication Issues
8463

85-
If you encounter issues with Git SSH signing:
64+
If you encounter issues with Git operations:
8665

87-
1. **SSH Agent Forwarding**: Make sure SSH agent forwarding is properly set up in your VS Code settings
88-
2. **GitHub Configuration**: Ensure your SSH key is added to GitHub as a signing key in your account settings
89-
3. **Manual Setup**: If automatic setup fails, you can manually configure SSH signing:
90-
91-
```bash
92-
# Check available SSH keys
93-
ssh-add -l
94-
95-
# Configure Git to use SSH signing
96-
git config --global gpg.format ssh
97-
git config --global user.signingkey "key::ssh-ed25519 YOUR_KEY_CONTENT"
98-
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
99-
git config --global commit.gpgsign true
100-
101-
# Create allowed signers file
102-
echo "[email protected] ssh-ed25519 YOUR_KEY_CONTENT" > ~/.ssh/allowed_signers
103-
```
66+
1. **GitHub CLI**: Use `gh auth login` to authenticate with GitHub
67+
2. **Git Configuration**: Set user.name and user.email if not configured via environment variables
68+
3. **Commit Signing**: Handle commit signing on your host machine for security
10469

105-
For other issues, check the `project-setup.sh` and `setup-git-signing.sh` scripts for any errors.
70+
For other issues, check the `project-setup.sh` script for any errors.

.devcontainer/devcontainer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"name": "graph contracts",
32
"dockerComposeFile": ["docker-compose.yml"],
43
"service": "dev-graph-contracts",
54
"features": {
@@ -12,11 +11,16 @@
1211
"ghcr.io/devcontainers/features/node:1": {
1312
"version": "20"
1413
},
15-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
14+
"ghcr.io/devcontainers/features/python:1": {
15+
"version": "3.11"
16+
}
1617
},
18+
"mounts": [
19+
"source=${localWorkspaceFolder},target=/work/${localWorkspaceFolderBasename},type=bind,consistency=cached"
20+
],
1721
"postCreateCommand": ".devcontainer/project-setup.sh",
1822
"remoteUser": "vscode",
19-
"workspaceFolder": "${localWorkspaceFolder}",
23+
"workspaceFolder": "/work/${localWorkspaceFolderBasename}",
2024
"customizations": {
2125
"vscode": {
2226
"extensions": [
@@ -28,14 +32,14 @@
2832
"shd101wyy.markdown-preview-enhanced",
2933
"bierner.markdown-preview-github-styles",
3034
"Gruntfuggly.todo-tree",
31-
"ms-azuretools.vscode-docker",
3235
"donjayamanne.githistory",
3336
"eamodio.gitlens",
3437
"fill-labs.dependi",
3538
"streetsidesoftware.code-spell-checker",
3639
"Augment.vscode-augment",
3740
"NomicFoundation.hardhat-solidity",
38-
"foundry-rs.foundry-vscode"
41+
"foundry-rs.foundry-vscode",
42+
"esbenp.prettier-vscode"
3943
]
4044
}
4145
}

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,6 @@ services:
1515
# Disable interactive prompts
1616
- COREPACK_ENABLE_DOWNLOAD_PROMPT=0
1717

18-
# Standard user directories
19-
- XDG_CACHE_HOME=/home/vscode/.cache
20-
- XDG_CONFIG_HOME=/home/vscode/.config
21-
- XDG_DATA_HOME=/home/vscode/.local/share
22-
23-
# Safe caches (won't cause cross-branch issues)
24-
- GH_CONFIG_DIR=/home/vscode/.cache/github
25-
- PIP_CACHE_DIR=/home/vscode/.cache/pip
26-
27-
# pnpm cache is safe to share due to content-addressable storage
28-
- PNPM_HOME=/home/vscode/.local/share/pnpm
29-
- PNPM_CACHE_DIR=/home/vscode/.cache/pnpm
30-
31-
# Note: NPM, Foundry, and Solidity caches are intentionally not set
32-
# to avoid cross-branch contamination. Tools will use their default locations.
3318
volumes:
3419
# Git repo root
3520
- /git:/git
36-
37-
# Local directories for user data (keep local to container)
38-
- vscode-cache:/home/vscode/.cache
39-
- vscode-config:/home/vscode/.config
40-
- vscode-data:/home/vscode/.local/share
41-
- vscode-bin:/home/vscode/.local/bin
42-
43-
# Shared pnpm cache (safe due to content-addressable storage)
44-
- pnpm-store:/home/vscode/.local/share/pnpm
45-
- pnpm-cache:/home/vscode/.cache/pnpm
46-
47-
volumes:
48-
vscode-cache:
49-
vscode-config:
50-
vscode-data:
51-
vscode-bin:
52-
pnpm-store:
53-
pnpm-cache:

.devcontainer/project-setup.sh

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ sudo chmod -R 755 /home/vscode/.cache /home/vscode/.config /home/vscode/.local
2121

2222
echo "User directories set up with proper permissions"
2323

24+
# Install Solidity compiler (moved from Dockerfile since Python/pipx is now available)
25+
echo "Installing Solidity compiler..."
26+
pipx install solc-select
27+
pipx ensurepath
28+
solc-select install 0.8.27
29+
solc-select use 0.8.27
30+
31+
# Upgrade npm to latest version for better compatibility and security
32+
echo "Upgrading npm to latest version..."
33+
npm install -g npm@latest
34+
35+
npm install -g [email protected] cloc @anthropic-ai/claude-code
36+
37+
# Set up pnpm with correct version (matching package.json)
38+
echo "Setting up pnpm..."
39+
corepack enable
40+
corepack prepare [email protected] --activate
41+
42+
# Verify pnpm is working
43+
echo "Verifying pnpm installation..."
44+
pnpm --version
45+
2446
# Install project dependencies
2547
echo "Installing project dependencies..."
2648
if [ -f "$REPO_ROOT/package.json" ]; then
@@ -72,11 +94,18 @@ else
7294
echo "Shell customizations not found in PATH, skipping..."
7395
fi
7496

75-
# Set up Git SSH signing
76-
if [ -f "$SCRIPT_DIR/setup-git-signing.sh" ]; then
77-
"$SCRIPT_DIR/setup-git-signing.sh"
97+
# Set up basic Git configuration (user.name and user.email from environment)
98+
echo "Setting up basic Git configuration..."
99+
if [[ -n "${GIT_USER_NAME:-}" && -n "${GIT_USER_EMAIL:-}" ]]; then
100+
echo "Setting Git user.name: $GIT_USER_NAME"
101+
git config --global user.name "$GIT_USER_NAME"
102+
echo "Setting Git user.email: $GIT_USER_EMAIL"
103+
git config --global user.email "$GIT_USER_EMAIL"
104+
echo "Git user configuration complete"
78105
else
79-
echo "WARNING: setup-git-signing.sh not found, skipping Git SSH signing setup"
106+
echo "GIT_USER_NAME and/or GIT_USER_EMAIL not set - skipping Git user configuration"
107+
echo "You can set these manually with: git config --global user.name 'Your Name'"
108+
echo "and: git config --global user.email '[email protected]'"
80109
fi
81110

82111
echo "Project-specific setup completed"

0 commit comments

Comments
 (0)