Skip to content

Commit b8e475e

Browse files
MohsinHashmi-DataInnDeveloperclaude
authored
feat: add direnv and improve devcontainer environment setup (#451)
* fix: add missing simpleaccounts_db env vars and update documentation Issues fixed: - Backend failed to start due to missing SIMPLEACCOUNTS_DB_* environment variables - post-start.sh used wrong hostnames (localhost vs db/redis) - Documentation had outdated npm commands (npm run dev vs npm start) Changes: - Add SIMPLEACCOUNTS_DB_HOST, SIMPLEACCOUNTS_DB_PORT, etc. to .env.example - Add same env vars to Coder template.tf for seamless Coder support - Update post-start.sh to auto-detect Coder vs DevContainer environment - Fix npm commands in CLAUDE.md, AGENTS.md, and other docs - Update README.md architecture diagram to show localhost networking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: handle java_tool_options in java version detection scripts The JAVA_TOOL_OPTIONS environment variable outputs a message that was being captured by `head -1`, causing Java version detection to fail even when Java 21+ was properly installed. Fixed by using `grep -E '(openjdk|java) version'` to filter for the actual version line before extracting the version number. Files fixed: - apps/backend/run.sh - apps/backend/check_java.sh - scripts/setup-mcp-sonarqube.sh - scripts/run-sonarqube-mcp.sh 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add direnv for automatic .env loading in devcontainer - Add direnv to Dockerfile apt-get install - Configure direnv hook in bashrc via post-create.sh - Auto-create .envrc that loads all .env files - Add .envrc to .gitignore This enables automatic environment variable loading when entering the workspace directory, loading from .devcontainer/.env and any local override files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: update sonarqube url and package-lock - Update SONARQUBE_URL to sonarqube.datainn.io in .mcp.json - Update package-lock.json 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Developer <developer@simpleaccounts.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5372ce4 commit b8e475e

5 files changed

Lines changed: 64 additions & 1 deletion

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
3434
&& echo "deb [signed-by=/usr/share/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /" > /etc/apt/sources.list.d/kubernetes.list \
3535
&& apt-get update \
3636
&& apt-get -y install --no-install-recommends \
37+
direnv \
3738
docker-ce-cli \
3839
docker-compose-plugin \
3940
gh \

.devcontainer/post-create.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,52 @@ else
146146
echo " ⚠️ Not in a git repository, skipping git hooks"
147147
fi
148148

149+
# ============================================
150+
# Setup direnv for automatic .env loading
151+
# ============================================
152+
echo "🔧 Setting up direnv..."
153+
154+
# Add direnv hook to bashrc if not already present
155+
if ! grep -q "direnv hook bash" "$TARGET_HOME/.bashrc" 2>/dev/null; then
156+
echo '' >> "$TARGET_HOME/.bashrc"
157+
echo '# direnv hook for automatic .env loading' >> "$TARGET_HOME/.bashrc"
158+
echo 'eval "$(direnv hook bash)"' >> "$TARGET_HOME/.bashrc"
159+
echo " ✅ Added direnv hook to .bashrc"
160+
fi
161+
162+
# Create .envrc file if it doesn't exist
163+
if [ ! -f ".envrc" ]; then
164+
cat > .envrc << 'ENVRCEOF'
165+
# direnv configuration for SimpleAccounts-UAE
166+
# This file loads environment variables from .env files
167+
168+
# Load main devcontainer environment variables
169+
if [ -f .devcontainer/.env ]; then
170+
dotenv .devcontainer/.env
171+
fi
172+
173+
# Load local overrides (not committed to git)
174+
if [ -f .devcontainer/.env.local ]; then
175+
dotenv .devcontainer/.env.local
176+
fi
177+
178+
# Load root .env if it exists (not committed to git)
179+
if [ -f .env ]; then
180+
dotenv .env
181+
fi
182+
183+
# Load root .env.local if it exists (not committed to git)
184+
if [ -f .env.local ]; then
185+
dotenv .env.local
186+
fi
187+
ENVRCEOF
188+
echo " ✅ Created .envrc file"
189+
fi
190+
191+
# Allow direnv for this directory
192+
direnv allow . 2>/dev/null || true
193+
echo " ✅ direnv configured"
194+
149195
# ============================================
150196
# Create local environment files
151197
# ============================================

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ lerna-debug.log*
4343
.env
4444
.env.local
4545
.mcp.env
46+
.envrc
4647

4748
# DevContainer secrets
4849
.devcontainer/.env

.mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"[ -f .mcp.env ] && export $(grep -v '^#' .mcp.env | xargs); JAVA_CMD=$(/usr/libexec/java_home -v 21 2>/dev/null)/bin/java || JAVA_CMD=java; exec $JAVA_CMD -jar $HOME/.local/share/mcp-servers/sonarqube-mcp-server.jar"
99
],
1010
"env": {
11-
"SONARQUBE_URL": "https://sonar-r0w40gg48okc00wkc08oowo4.46.62.252.63.sslip.io",
11+
"SONARQUBE_URL": "https://sonarqube.datainn.io",
1212
"STORAGE_PATH": "${HOME}/.local/share/mcp-servers/storage"
1313
}
1414
}

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)