Skip to content

Commit a66c8e6

Browse files
MohsinHashmi-DataInnmohsin-wiserclaude
authored
fix: use internal network hostnames and update docs for devpod (#388)
* fix: suppress act() warnings and unhandled rejections in tests Configure testing-library for React 18+ and suppress harmless act() warnings that occur due to async state updates completing after test cleanup. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: upgrade postgresql from 16 to 18 Upgrade devcontainer database to PostgreSQL 18.1 (released Sept 2025). Key benefits: - 3x performance with new Async I/O subsystem - UUIDv7 function for timestamp-ordered UUIDs - Virtual generated columns - Skip scan on multicolumn B-tree indexes - OAuth 2.0 authentication support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: add init to devcontainer to prevent zombie processes Adds `init: true` to the devcontainer service which uses tini as PID 1. This properly reaps zombie processes that accumulate from DevPod sessions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: add container naming convention for devpod Adds instructions for configuring username-based container names when multiple developers share the same remote server. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update proxy template with postgres 18 and init - Upgrade PostgreSQL from 16 to 18 - Add init: true to prevent zombie processes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use internal network hostnames for health checks - Change pg_isready from localhost to db hostname - Change redis-cli from localhost to redis hostname - Update application-local.properties to use db/redis hostnames - Update README.md troubleshooting commands - Update proxy docker-compose comments for DevPod workflow With the explicit internal network, services must use their hostnames (db, redis) instead of localhost for communication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update documentation for devpod workflow - remove references to deleted setup-user.sh and generate-hosts.sh - update README.md multi-user section to use DevPod commands - update NEW-USER-ONBOARDING.md for DevPod-based workflow - update install-traefik-service.sh next steps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: comprehensive devcontainer review fixes - update idle-shutdown.sh to find DevPod workspace compose files - update README.md architecture diagram for internal network - fix service connectivity table to use db/redis hostnames - remove obsolete hostname troubleshooting section - remove non-functional port forwarding for db/redis - update volume check command for user-specific naming 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: additional comprehensive review fixes - update README.md volumes section with correct naming convention - add timeout (60s) to PostgreSQL/Redis health check loops - fix DEV_USER fallback consistency in post-start.sh - add nip.io route for Traefik dashboard 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Mohsin Hashmi <mhashmi@wiser.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a4053a2 commit a66c8e6

7 files changed

Lines changed: 132 additions & 115 deletions

File tree

.devcontainer/NEW-USER-ONBOARDING.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Welcome to SimpleAccounts UAE development! Choose your setup based on your envir
66

77
| Setup | Best For | Command |
88
|-------|----------|---------|
9-
| **Multi-User (Recommended)** | Shared dev server, team collaboration | `./setup-user.sh <username>` |
9+
| **Multi-User (Recommended)** | Shared dev server, team collaboration | `devpod up ... --provider ssh` |
1010
| **Single User** | Local development, solo work | `devpod up simpleaccounts-uae` |
1111

1212
---
@@ -18,19 +18,17 @@ Best for teams sharing a development server. Each developer gets isolated contai
1818
### Quick Start
1919

2020
```bash
21-
# SSH into the dev server
22-
ssh <your-username>@<dev-server-ip>
21+
# From your local machine, launch via DevPod
22+
devpod up git@github.com:SimpleAccounts/SimpleAccounts-UAE.git \
23+
--provider ssh \
24+
--provider-option HOST=<dev-server-ip>
2325

24-
# Navigate to the project
25-
cd /path/to/SimpleAccounts-UAE/.devcontainer/proxy
26-
27-
# Setup your environment (auto-starts proxy if needed)
28-
./setup-user.sh <your-username>
26+
# Container auto-connects to Traefik proxy for shareable URLs
2927
```
3028

3129
### What You Get
3230

33-
After running the setup script, you'll see:
31+
After the container starts, you'll see URLs printed:
3432

3533
```
3634
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -43,10 +41,15 @@ Option 1: nip.io URLs (No DNS config needed!)
4341

4442
### Connect VS Code
4543

46-
1. Open VS Code
47-
2. Install "Dev Containers" extension
48-
3. `Cmd+Shift+P` > "Dev Containers: Attach to Running Container"
49-
4. Select `dev-<your-username>`
44+
DevPod automatically opens VS Code when the workspace is ready. Alternatively:
45+
46+
```bash
47+
# Open in VS Code
48+
devpod up simpleaccounts-uae --ide vscode
49+
50+
# Or use the Web IDE
51+
# http://<username>-ide.<server-ip>.nip.io
52+
```
5053

5154
### Share Your Environment
5255

@@ -135,11 +138,11 @@ This will:
135138

136139
| Task | Command |
137140
| --------------------- | --------------------------------------------------- |
138-
| Setup environment | `./setup-user.sh <username>` |
139-
| List active users | `docker ps --filter "name=dev-"` |
140-
| Stop your environment | `docker compose -f docker-compose.<user>.yml down` |
141-
| View your logs | `docker logs dev-<username>` |
142-
| Attach VS Code | Dev Containers: Attach to Running Container |
141+
| Setup environment | `devpod up ... --provider ssh --provider-option HOST=<server>` |
142+
| List active users | `docker ps --filter "name=simpleaccounts"` |
143+
| Stop your environment | `devpod stop simpleaccounts-uae` |
144+
| View your logs | `devpod logs simpleaccounts-uae` |
145+
| Open VS Code | `devpod up simpleaccounts-uae --ide vscode` |
143146

144147
### Single-User (DevPod) Commands
145148

@@ -180,7 +183,7 @@ claude
180183
docker ps | grep dev-proxy
181184

182185
# Check your container is running
183-
docker ps | grep dev-<username>
186+
docker ps | grep simpleaccounts
184187

185188
# View proxy logs
186189
docker logs dev-proxy
@@ -189,11 +192,11 @@ docker logs dev-proxy
189192
#### Container won't start
190193

191194
```bash
192-
# Check logs
193-
docker logs dev-<username>
195+
# Check DevPod logs
196+
devpod logs simpleaccounts-uae
194197

195-
# Check compose file
196-
cat .devcontainer/proxy/docker-compose.<username>.yml
198+
# Check container logs directly
199+
docker logs $(docker ps -q --filter "name=simpleaccounts")
197200
```
198201

199202
### Single-User (DevPod) Setup
@@ -279,8 +282,9 @@ sudo chown -R 1000:1000 /home/<username>/.devpod-mount/
279282

280283
| Script | Location | Purpose |
281284
| ----------------------------- | -------------------- | -------------------------------- |
282-
| `setup-user.sh` | `.devcontainer/proxy/` | Multi-user environment setup |
283-
| `generate-hosts.sh` | `.devcontainer/proxy/` | Generate /etc/hosts entries |
285+
| `install-traefik-service.sh` | `.devcontainer/proxy/` | Install Traefik proxy (admin) |
286+
| `post-create.sh` | `.devcontainer/` | Initial container setup |
287+
| `post-start.sh` | `.devcontainer/` | Container startup (Traefik connect) |
284288
| `admin-add-user.sh` | `scripts/` | Admin adds new DevPod user |
285289
| `user-quick-setup.sh` | `scripts/` | User one-click DevPod setup |
286290
| `devpod-setup.sh` | `scripts/` | Full self-service DevPod setup |

.devcontainer/README.md

Lines changed: 53 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ code .
1515
### Multi-User (Shared Dev Server)
1616

1717
```bash
18-
cd .devcontainer/proxy
19-
./setup-user.sh <your-username>
18+
# Launch via DevPod (from your local machine)
19+
devpod up git@github.com:SimpleAccounts/SimpleAccounts-UAE.git \
20+
--provider ssh \
21+
--provider-option HOST=<dev-server>
2022

21-
# Then attach VS Code:
22-
# Cmd+Shift+P > "Dev Containers: Attach to Running Container"
23-
# Select: dev-<your-username>
23+
# Container auto-connects to Traefik proxy for shareable URLs
2424
```
2525

2626
---
@@ -42,15 +42,14 @@ Uses `.devcontainer/docker-compose.yml` and `devcontainer.json`.
4242

4343
```
4444
┌─────────────────────────────────────────────────────────────┐
45-
Shared Network Namespace
46-
│ (hostname: simpleaccounts-dev)
45+
Internal Docker Network │
46+
│ (user-specific isolation)
4747
│ │
4848
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
4949
│ │ devcontainer │ │ db │ │ redis │ │
5050
│ │ │ │ (postgres) │ │ │ │
51-
│ │ localhost: │ │ localhost: │ │ localhost: │ │
52-
│ │ 5432 ─────────► 5432 │ │ 6379 ◄─────────────│
53-
│ │ 6379 ◄────────────────────────────► 6379 │ │
51+
│ │ db:5432 ──────► :5432 │ │ │ │
52+
│ │ redis:6379 ───────────────────────► :6379 │ │
5453
│ └──────────────┘ └──────────────┘ └──────────────┘ │
5554
└─────────────────────────────────────────────────────────────┘
5655
```
@@ -59,17 +58,17 @@ Uses `.devcontainer/docker-compose.yml` and `devcontainer.json`.
5958

6059
| Service | Access From DevContainer |
6160
| ---------- | ------------------------ |
62-
| PostgreSQL | `localhost:5432` |
63-
| Redis | `localhost:6379` |
61+
| PostgreSQL | `db:5432` |
62+
| Redis | `redis:6379` |
6463
| Frontend | `localhost:3000` |
6564
| Backend | `localhost:8080` |
6665

67-
### Why Shared Network Namespace?
66+
### Why Internal Network?
6867

69-
1. **Simplicity**: No DNS resolution or service discovery needed
70-
2. **Localhost Access**: Applications connect to `localhost` just like local development
71-
3. **Consistency**: Same connection strings work locally and in the container
72-
4. **Performance**: No network overlay overhead
68+
1. **Multi-user Isolation**: Each user gets their own network namespace
69+
2. **Traefik Compatible**: Devcontainer can join Traefik network for external routing
70+
3. **Simple Hostnames**: Services use predictable hostnames (`db`, `redis`)
71+
4. **Consistent**: Same connection strings work for single and multi-user setups
7372

7473
---
7574

@@ -115,32 +114,30 @@ Uses `.devcontainer/proxy/` with Traefik reverse proxy.
115114
### Usage
116115

117116
```bash
118-
# Setup your environment (auto-starts proxy if needed)
119-
cd .devcontainer/proxy
120-
./setup-user.sh alice
121-
122-
# Access URLs printed after setup:
123-
# Frontend: http://alice.192-168-1-100.nip.io
124-
# Backend: http://alice-api.192-168-1-100.nip.io
117+
# Launch via DevPod (from your local machine)
118+
devpod up git@github.com:SimpleAccounts/SimpleAccounts-UAE.git \
119+
--provider ssh \
120+
--provider-option HOST=dev-server
121+
122+
# Container auto-registers with Traefik. Access URLs shown at startup:
123+
# Frontend: http://<username>.192-168-1-100.nip.io
124+
# Backend: http://<username>-api.192-168-1-100.nip.io
125125
```
126126

127127
### User Management
128128

129129
```bash
130-
# Add new user
131-
./setup-user.sh bob
132-
133-
# List active users
134-
docker ps --filter "name=dev-" --format "table {{.Names}}\t{{.Status}}"
130+
# List active user containers
131+
docker ps --filter "name=simpleaccounts" --format "table {{.Names}}\t{{.Status}}"
135132

136-
# Stop user environment
137-
docker compose -f docker-compose.alice.yml down
133+
# Stop user environment (via DevPod)
134+
devpod stop simpleaccounts-uae
138135

139-
# Remove user environment (with data)
140-
docker compose -f docker-compose.alice.yml down -v
136+
# Delete user environment (via DevPod)
137+
devpod delete simpleaccounts-uae
141138
```
142139

143-
See [proxy/README.md](proxy/README.md) for full documentation.
140+
See [proxy/README.md](proxy/README.md) for Traefik proxy documentation.
144141

145142
---
146143

@@ -157,30 +154,32 @@ See [proxy/README.md](proxy/README.md) for full documentation.
157154

158155
## Volumes
159156

160-
### Persistent Data
157+
### Persistent Data (Named Volumes)
161158

162-
- `postgres-data` - PostgreSQL database files
163-
- `redis-data` - Redis persistence
159+
Named Docker volumes (user-specific to avoid conflicts):
164160

165-
### Developer Tool Caches (Survives Rebuilds)
161+
- `${USER}-postgres-data` - PostgreSQL database files
162+
- `${USER}-redis-data` - Redis persistence
163+
- `${USER}-vscode-extensions` - VS Code extensions
164+
- `${USER}-maven-cache` - Maven dependencies (~/.m2)
165+
- `${USER}-npm-cache` - npm cache (~/.npm)
166166

167-
- `devcontainer-vscode-extensions` - VS Code extensions
168-
- `devcontainer-maven-cache` - Maven dependencies (~/.m2)
169-
- `devcontainer-npm-cache` - npm cache (~/.npm)
167+
### Credentials & Configuration (Host Bind Mounts)
170168

171-
### Credentials & Configuration (Survives Rebuilds)
169+
Persisted to host directory `~/.devpod-mount/` for portability:
172170

173-
- `devcontainer-claude-config` - Claude CLI credentials (~/.claude)
174-
- `devcontainer-gemini-config` - Gemini CLI config (~/.gemini)
175-
- `devcontainer-codex-config` - Codex CLI config (~/.codex)
176-
- `devcontainer-gh-config` - GitHub CLI auth (~/.config/gh)
177-
- `devcontainer-ssh` - SSH keys (~/.ssh)
178-
- `devcontainer-docker` - Docker config (~/.docker)
179-
- `devcontainer-kube` - Kubernetes config (~/.kube)
180-
- `devcontainer-aws` - AWS credentials (~/.aws)
181-
- `devcontainer-azure` - Azure credentials (~/.azure)
182-
- `devcontainer-gitconfig` - Git configuration (~/.gitconfig)
183-
- `devcontainer-bash-history` - Bash history
171+
- `~/.devpod-mount/claude`~/.claude (Claude CLI)
172+
- `~/.devpod-mount/gemini`~/.gemini (Gemini CLI)
173+
- `~/.devpod-mount/codex`~/.codex (Codex CLI)
174+
- `~/.devpod-mount/gh`~/.config/gh (GitHub CLI)
175+
- `~/.devpod-mount/ssh`~/.ssh (SSH keys)
176+
- `~/.devpod-mount/docker`~/.docker (Docker config)
177+
- `~/.devpod-mount/kube`~/.kube (Kubernetes config)
178+
- `~/.devpod-mount/aws`~/.aws (AWS credentials)
179+
- `~/.devpod-mount/azure`~/.azure (Azure credentials)
180+
- `~/.devpod-mount/gitconfig`~/.gitconfig_dir (Git config)
181+
- `~/.devpod-mount/bash-history`~/.bash_history_dir (Bash history)
182+
- `~/.devpod-mount/code-server`~/.config/code-server (Web IDE config)
184183

185184
## Local Overrides
186185

@@ -210,13 +209,6 @@ docker compose down
210209
docker compose up -d
211210
```
212211

213-
### Check Hostname
214-
215-
```bash
216-
hostname
217-
# Output: simpleaccounts-dev
218-
```
219-
220212
### Verify Network Connectivity
221213

222214
```bash
@@ -245,21 +237,12 @@ docker compose ps
245237
docker compose logs db
246238
```
247239

248-
### Hostname shows random ID instead of simpleaccounts-dev
249-
250-
The container needs to be rebuilt to pick up the hostname change:
251-
252-
```bash
253-
docker compose down
254-
docker compose up -d
255-
```
256-
257240
### Credentials lost after rebuild
258241

259242
Credentials are stored in named volumes and should persist. Check volume exists:
260243

261244
```bash
262-
docker volume ls | grep devcontainer-claude-config
245+
docker volume ls | grep "$(whoami)-"
263246
```
264247

265248
### Multi-user: URL not accessible

.devcontainer/devcontainer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
}
6262
},
6363

64-
// Port forwarding
65-
"forwardPorts": [3000, 8080, 8443, 5432, 6379],
64+
// Port forwarding (for services running inside devcontainer)
65+
// Note: PostgreSQL (db:5432) and Redis (redis:6379) are on separate containers
66+
// Access them from devcontainer via hostnames, not localhost
67+
"forwardPorts": [3000, 8080, 8443],
6668
"portsAttributes": {
6769
"3000": { "label": "Frontend (Vite)", "onAutoForward": "notify" },
6870
"8080": { "label": "Backend (Spring Boot)", "onAutoForward": "notify" },
69-
"8443": { "label": "Code Server (Web IDE)", "onAutoForward": "notify" },
70-
"5432": { "label": "PostgreSQL", "onAutoForward": "silent" },
71-
"6379": { "label": "Redis", "onAutoForward": "silent" }
71+
"8443": { "label": "Code Server (Web IDE)", "onAutoForward": "notify" }
7272
},
7373

7474
// Lifecycle scripts

.devcontainer/post-start.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,36 @@
33

44
echo "🔄 Starting SimpleAccounts-UAE development environment..."
55

6-
# Wait for PostgreSQL to be ready
6+
# Wait for PostgreSQL to be ready (with timeout)
77
echo "⏳ Waiting for PostgreSQL..."
8+
TIMEOUT=60
9+
ELAPSED=0
810
until pg_isready -h db -p 5432 -U simpleaccounts -q; do
911
sleep 1
12+
ELAPSED=$((ELAPSED + 1))
13+
if [ $ELAPSED -ge $TIMEOUT ]; then
14+
echo "⚠️ PostgreSQL not ready after ${TIMEOUT}s, continuing anyway..."
15+
break
16+
fi
1017
done
11-
echo "✅ PostgreSQL is ready"
18+
if [ $ELAPSED -lt $TIMEOUT ]; then
19+
echo "✅ PostgreSQL is ready"
20+
fi
1221

13-
# Wait for Redis to be ready
22+
# Wait for Redis to be ready (with timeout)
1423
echo "⏳ Waiting for Redis..."
24+
ELAPSED=0
1525
until redis-cli -h redis ping > /dev/null 2>&1; do
1626
sleep 1
27+
ELAPSED=$((ELAPSED + 1))
28+
if [ $ELAPSED -ge $TIMEOUT ]; then
29+
echo "⚠️ Redis not ready after ${TIMEOUT}s, continuing anyway..."
30+
break
31+
fi
1732
done
18-
echo "✅ Redis is ready"
33+
if [ $ELAPSED -lt $TIMEOUT ]; then
34+
echo "✅ Redis is ready"
35+
fi
1936

2037
# Symlink Claude settings from persistent mount
2138
if [ -f /home/vscode/.claude/claude.json ] && [ ! -L /home/vscode/.claude.json ]; then
@@ -80,8 +97,8 @@ connect_to_traefik() {
8097
return 1
8198
fi
8299

83-
# Get the devcontainer name
84-
DEV_USER="${DEV_USER:-$(whoami)}"
100+
# Get the devcontainer name (DEV_USER is set from docker-compose environment)
101+
DEV_USER="${DEV_USER:-devuser}"
85102
DEV_CONTAINER_NAME="dev-${DEV_USER}"
86103

87104
# Check if devcontainer exists

.devcontainer/proxy/docker-compose.proxy.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ services:
5353
- dev-proxy-network
5454
labels:
5555
- 'traefik.enable=true'
56-
- 'traefik.http.routers.dashboard.rule=Host(`proxy.dev.simpleaccounts.local`)'
56+
# Dashboard routing via nip.io (no DNS config needed)
57+
- 'traefik.http.routers.dashboard.rule=HostRegexp(`proxy.{ip:[0-9-]+}.nip.io`)'
58+
- 'traefik.http.routers.dashboard.entrypoints=web'
5759
- 'traefik.http.routers.dashboard.service=api@internal'
60+
# Dashboard routing via local domain (requires /etc/hosts or local DNS)
61+
- 'traefik.http.routers.dashboard-local.rule=Host(`proxy.dev.simpleaccounts.local`)'
62+
- 'traefik.http.routers.dashboard-local.entrypoints=web'
63+
- 'traefik.http.routers.dashboard-local.service=api@internal'
5864

5965
networks:
6066
dev-proxy-network:

0 commit comments

Comments
 (0)