Skip to content

Commit 8077b23

Browse files
committed
Added deployment options
1 parent 8299614 commit 8077b23

5 files changed

Lines changed: 490 additions & 97 deletions

File tree

Dockerfile

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
# ============================================================================
2-
# VSCode Cloud IDE - Claude Code & Node.js Ready
3-
# Browser-based VSCode with persistent extensions and Node.js
4-
# https://github.com/sphinxcode/code-server
2+
# Claude Code Server - Browser-based VS Code with AI Coding Assistants
3+
# https://github.com/sphinxcode/claude-code-server
54
# ============================================================================
65

7-
FROM codercom/code-server:latest
6+
FROM codercom/code-server:4.108.0
87

98
USER root
109

11-
# Install gosu for proper user switching, Node.js, and essential tools
12-
# Cache bust: 2026-01-29-v3
10+
# ============================================================================
11+
# SYSTEM DEPENDENCIES
12+
# Install gosu, Node.js 20, Python/uv, and essential tools
13+
# Cache bust: 2026-01-29-v4
14+
# ============================================================================
15+
1316
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
1417
&& apt-get update \
1518
&& apt-get install -y --no-install-recommends \
1619
gosu \
1720
nodejs \
21+
python3 \
22+
python3-pip \
1823
git \
1924
curl \
2025
wget \
@@ -25,43 +30,54 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
2530
nano \
2631
ripgrep \
2732
&& npm install -g npm@latest \
33+
&& pip3 install --break-system-packages uv \
2834
&& apt-get clean \
2935
&& rm -rf /var/lib/apt/lists/*
3036

3137
# ============================================================================
3238
# PERSISTENCE CONFIGURATION
3339
# ============================================================================
3440

35-
ENV HOME=/home/coder
36-
ENV USER=coder
41+
ENV HOME=/home/clauder
42+
ENV USER=clauder
3743

3844
# XDG Base Directory Specification
39-
ENV XDG_DATA_HOME=/home/coder/.local/share
40-
ENV XDG_CONFIG_HOME=/home/coder/.config
41-
ENV XDG_CACHE_HOME=/home/coder/.cache
42-
ENV XDG_STATE_HOME=/home/coder/.local/state
45+
ENV XDG_DATA_HOME=/home/clauder/.local/share
46+
ENV XDG_CONFIG_HOME=/home/clauder/.config
47+
ENV XDG_CACHE_HOME=/home/clauder/.cache
48+
ENV XDG_STATE_HOME=/home/clauder/.local/state
4349

4450
# PATH: Volume paths FIRST (user installs), image paths LAST (fallbacks)
45-
ENV PATH="/home/coder/.local/bin:/home/coder/.local/node/bin:/home/coder/.claude/local:/home/coder/node_modules/.bin:/usr/local/bin:/usr/bin:/usr/lib/code-server/lib/vscode/bin/remote-cli:${PATH}"
51+
ENV PATH="/home/clauder/.local/bin:/home/clauder/.local/node/bin:/home/clauder/.claude/local:/home/clauder/node_modules/.bin:/usr/local/bin:/usr/bin:/usr/lib/code-server/lib/vscode/bin/remote-cli:${PATH}"
4652

4753
# Custom startup scripts directory
48-
ENV ENTRYPOINTD=/home/coder/entrypoint.d
54+
ENV ENTRYPOINTD=/home/clauder/entrypoint.d
55+
56+
# ============================================================================
57+
# USER SETUP
58+
# Create clauder user with same UID as coder for compatibility
59+
# ============================================================================
60+
61+
RUN groupadd -g 1000 clauder 2>/dev/null || true \
62+
&& useradd -m -s /bin/bash -u 1000 -g 1000 clauder 2>/dev/null || true \
63+
&& usermod -l clauder coder 2>/dev/null || true \
64+
&& groupmod -n clauder coder 2>/dev/null || true
4965

5066
# ============================================================================
5167
# DIRECTORY SETUP
5268
# ============================================================================
5369

5470
RUN mkdir -p \
55-
/home/coder/.local/share \
56-
/home/coder/.config \
57-
/home/coder/.cache \
58-
/home/coder/.local/state \
59-
/home/coder/.local/bin \
60-
/home/coder/.local/node \
61-
/home/coder/.claude \
62-
/home/coder/entrypoint.d \
63-
/home/coder/workspace \
64-
&& chown -R 1000:1000 /home/coder
71+
/home/clauder/.local/share \
72+
/home/clauder/.config \
73+
/home/clauder/.cache \
74+
/home/clauder/.local/state \
75+
/home/clauder/.local/bin \
76+
/home/clauder/.local/node \
77+
/home/clauder/.claude \
78+
/home/clauder/entrypoint.d \
79+
/home/clauder/workspace \
80+
&& chown -R 1000:1000 /home/clauder
6581

6682
# Copy our custom entrypoint (replaces base image's entrypoint)
6783
COPY railway-entrypoint.sh /usr/bin/railway-entrypoint.sh
@@ -70,6 +86,7 @@ RUN chmod +x /usr/bin/railway-entrypoint.sh
7086
# ============================================================================
7187
# FALLBACK CLAUDE CODE CLI INSTALLATION
7288
# Installed to /usr/local/bin as fallback - volume version takes priority
89+
# Claude Code is ALWAYS installed (cannot be disabled)
7390
# ============================================================================
7491

7592
RUN curl -fsSL https://claude.ai/install.sh | bash \
@@ -84,7 +101,7 @@ RUN curl -fsSL https://claude.ai/install.sh | bash \
84101
# Stay as root - entrypoint handles user switching based on RUN_AS_USER
85102
# ============================================================================
86103

87-
WORKDIR /home/coder/workspace
104+
WORKDIR /home/clauder/workspace
88105
EXPOSE 8080
89106

90107
# Use our entrypoint which calls code-server directly

PROJECT_BRIEF.md

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# Project Brief: Code-Server Railway Template
2+
3+
**Project:** VSCode Cloud IDE with Claude Code Integration
4+
**Repository:** `sphinxcode/code-server`
5+
**Railway Service:** `code-ajna` (claude.sphinx.codes)
6+
**Status:** In Progress
7+
8+
---
9+
10+
## Executive Summary
11+
12+
Create a production-ready, marketable Railway template that provides browser-based VS Code (code-server) with pre-installed Claude Code CLI, persistent extensions, and configurable user permissions.
13+
14+
---
15+
16+
## Original Problems
17+
18+
### 1. Root User Permission Issues
19+
- **Symptom:** code-server displayed security warnings about running as root
20+
- **Cause:** `RAILWAY_RUN_UID=0` was set, forcing container to run as root
21+
- **Impact:** Couldn't bypass certain settings, security warnings in UI
22+
23+
### 2. Non-Persistent Tools
24+
- **Symptom:** npm, npx, extensions disappeared after redeployment
25+
- **Cause:** Container running as root with `HOME=/root` (ephemeral), while volume mounted at `/home/coder`
26+
- **Impact:** Users lost installed tools and configurations on each deploy
27+
28+
### 3. Claude Code Not Pre-installed
29+
- **Request:** Template users should have Claude Code CLI available out-of-the-box
30+
- **Requirement:** Support for `claude --dangerously-skip-permissions` flag
31+
32+
---
33+
34+
## Solution Architecture
35+
36+
### Infrastructure
37+
| Component | Value |
38+
|-----------|-------|
39+
| Base Image | `codercom/code-server:latest` |
40+
| Volume Mount | `/home/coder` (Railway volume) |
41+
| Service URL | `claude.sphinx.codes` |
42+
| Project ID | `59ae99d7-dc99-4642-ae06-642cd8d8c83a` |
43+
| Service ID | `34522d52-ba69-4fcf-83b7-210a765a0a76` |
44+
| Environment ID | `a921a831-e480-451b-b9c7-04ce2f647c68` |
45+
46+
### Key Files Modified
47+
48+
#### [Dockerfile](file:///E:/AI-Terminal/sphinxcode/code-server/Dockerfile)
49+
- Installs `gosu` for proper user switching
50+
- Installs Node.js 20 LTS as fallback
51+
- Installs Claude Code CLI to `/usr/local/bin/claude`
52+
- Installs essential tools: ripgrep, jq, htop, vim, nano
53+
- Sets up XDG directories for persistence
54+
- PATH prioritizes volume paths over image paths
55+
56+
#### [railway-entrypoint.sh](file:///E:/AI-Terminal/sphinxcode/code-server/railway-entrypoint.sh)
57+
- Configurable user via `RUN_AS_USER` variable
58+
- Shell profile setup (`.bashrc`, `.profile`) with PATH
59+
- Permission fixing via `chown` when switching users
60+
- User switching via `gosu` when `RUN_AS_USER=coder`
61+
- Root symlinks for persistence when staying as root
62+
- First-run initialization with welcome README
63+
- Environment verification logging
64+
65+
#### [README.md](file:///E:/AI-Terminal/sphinxcode/code-server/README.md)
66+
- Documentation for all configuration variables
67+
- Quick start guide for Claude Code
68+
- Update behavior explanation
69+
- Troubleshooting guide
70+
71+
---
72+
73+
## Configuration Variables
74+
75+
| Variable | Required | Default | Description |
76+
|----------|----------|---------|-------------|
77+
| `PASSWORD` | Yes | - | code-server login password |
78+
| `RUN_AS_USER` | No | `root` | Set to `coder` for non-root execution |
79+
| `CODER_HOME` | No | `/home/coder` | Volume mount path |
80+
| `CODER_UID` | No | `1000` | User ID when switching to coder |
81+
| `CODER_GID` | No | `1000` | Group ID when switching to coder |
82+
| `GIT_REPO` | No | - | Repository to auto-clone on startup |
83+
84+
---
85+
86+
## Persistence Strategy
87+
88+
### Volume-First PATH Priority
89+
```
90+
$HOME/.local/bin ← User-installed tools (Claude, etc.)
91+
$HOME/.local/node/bin ← User-installed Node.js
92+
$HOME/.claude/local ← Claude Code from volume
93+
/usr/local/bin ← Image fallback (Claude)
94+
/usr/bin ← Image fallback (Node.js)
95+
```
96+
97+
### What Persists (on volume)
98+
- Extensions: `~/.local/share/code-server/extensions/`
99+
- Claude Code: `~/.local/bin/claude` or `~/.claude/`
100+
- Claude auth: `~/.claude/` (API keys, settings)
101+
- Node.js: `~/.local/node/` (if user installs)
102+
- Shell config: `~/.bashrc`, `~/.profile`
103+
- Workspace: `~/workspace/`
104+
105+
### What Auto-Updates (from image)
106+
- Node.js fallback in `/usr/bin/node`
107+
- Claude Code fallback in `/usr/local/bin/claude`
108+
- System packages (git, curl, etc.)
109+
110+
---
111+
112+
## User Modes
113+
114+
### Root Mode (Default)
115+
```
116+
RUN_AS_USER=root (or not set)
117+
```
118+
- Stays as root user
119+
- Creates symlinks from `/root/``/home/coder/` for persistence
120+
- Compatible with existing volumes owned by root
121+
122+
### Coder Mode (Recommended for Claude)
123+
```
124+
RUN_AS_USER=coder
125+
```
126+
- Switches to coder user (UID 1000) via gosu
127+
- Fixes volume permissions before switching
128+
- No root warnings in code-server UI
129+
- Required for `claude --dangerously-skip-permissions`
130+
131+
---
132+
133+
## Issues Encountered & Resolved
134+
135+
### 1. Railway Start Command Override
136+
- **Problem:** Railway had a custom start command that bypassed our ENTRYPOINT
137+
- **Solution:** Cleared the start command via `mcp_railway_service_update`
138+
139+
### 2. Docker Layer Caching
140+
- **Problem:** Railway used cached layers, ignoring our changes
141+
- **Solution:** Added cache-bust comments to force rebuild
142+
143+
### 3. Claude Installs to ~/.local/bin
144+
- **Problem:** Assumed Claude installed to `~/.claude/local/`
145+
- **Solution:** Updated PATH to include `$HOME/.local/bin` first
146+
147+
### 4. Shell Profile Not Configured
148+
- **Problem:** New terminals didn't have PATH set
149+
- **Solution:** Entrypoint now writes to `.bashrc` and `.profile`
150+
151+
---
152+
153+
## Current Status
154+
155+
### Completed ✅
156+
- Dockerfile with gosu, Node.js, Claude Code
157+
- Entrypoint with RUN_AS_USER variable
158+
- Shell profile auto-configuration
159+
- PATH priority for volume-installed tools
160+
- README documentation
161+
- Removed conflicting `railway.json`
162+
- Cleared Railway start command override
163+
- Set `RUN_AS_USER=coder` on Railway
164+
165+
### Pending Verification 🔄
166+
- Confirm entrypoint output appears in Railway logs
167+
- Verify user switches to `coder` (not `root@xxx`)
168+
- Test `claude --dangerously-skip-permissions` works
169+
- Confirm Claude authentication persists
170+
171+
---
172+
173+
## Expected Startup Logs
174+
175+
```
176+
╔══════════════════════════════════════════════════════════════════════════╗
177+
║ VSCode Cloud IDE - Claude Code & Node.js Ready ║
178+
╚══════════════════════════════════════════════════════════════════════════╝
179+
180+
→ Initial user: root (UID: 0)
181+
→ RUN_AS_USER: coder
182+
→ HOME: /home/coder
183+
184+
→ Running setup as root...
185+
→ Setting up shell profile...
186+
✓ Shell profile configured
187+
→ Fixing permissions for coder user (UID: 1000)...
188+
✓ Permissions fixed
189+
→ Switching to coder user via gosu...
190+
191+
→ Running as: coder (UID: 1000)
192+
193+
Environment:
194+
→ Node.js: v20.x.x [volume/image]
195+
→ npm: x.x.x
196+
→ git: x.x.x
197+
→ claude: x.x.x [volume/image]
198+
199+
════════════════════════════════════════════════════════════════════════
200+
Starting code-server as coder...
201+
════════════════════════════════════════════════════════════════════════
202+
```
203+
204+
---
205+
206+
## Files Summary
207+
208+
| File | Location | Purpose |
209+
|------|----------|---------|
210+
| `Dockerfile` | sphinxcode/code-server | Image build configuration |
211+
| `railway-entrypoint.sh` | sphinxcode/code-server | Container startup script |
212+
| `README.md` | sphinxcode/code-server | User documentation |
213+
| `railway.toml` | sphinxcode/code-server | Railway deployment config |
214+
215+
---
216+
217+
## Next Steps
218+
219+
1. **Verify Deployment** - Check if entrypoint runs and user switches properly
220+
2. **Test Claude** - Authenticate and run `claude --dangerously-skip-permissions`
221+
3. **Create Railway Template** - Make template public for others to deploy
222+
4. **Update Template Docs** - Include volume attachment instructions

0 commit comments

Comments
 (0)