Spaces:
Paused
Paused
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,9 +2,113 @@
|
|
| 2 |
title: Seb TestSpace
|
| 3 |
emoji: 🐠
|
| 4 |
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
title: Seb TestSpace
|
| 3 |
emoji: 🐠
|
| 4 |
colorFrom: indigo
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# code-server POC
|
| 12 |
+
|
| 13 |
+
Open the Space through its direct `https://<space-subdomain>.hf.space` URL rather than the embedded App tab.
|
| 14 |
+
|
| 15 |
+
## Space secrets
|
| 16 |
+
|
| 17 |
+
Required:
|
| 18 |
+
|
| 19 |
+
- `PASSWORD` — code-server web-login password
|
| 20 |
+
|
| 21 |
+
Optional:
|
| 22 |
+
|
| 23 |
+
- `NGROK_AUTHTOKEN` — lets `ngrok http ...` authenticate without writing the token manually
|
| 24 |
+
- `OPENAI_API_KEY` — for the preinstalled OpenAI Python SDK
|
| 25 |
+
- `ANTHROPIC_API_KEY` — for the preinstalled Anthropic Python SDK
|
| 26 |
+
|
| 27 |
+
When you want Claude Code to use a Claude subscription login, do not set `ANTHROPIC_API_KEY` globally at first. An approved API key takes precedence over subscription OAuth. Authenticate interactively from the terminal instead:
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
claude
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
In a remote container, copy the displayed login URL into your local browser and paste the returned code into the terminal when prompted.
|
| 34 |
+
|
| 35 |
+
## Persistent layout
|
| 36 |
+
|
| 37 |
+
Hugging Face mounts persistent storage at `/data` only at runtime. This image stores:
|
| 38 |
+
|
| 39 |
+
- Workspace: `/data/workspace`, visible in the IDE as `/home/coder/workspace`
|
| 40 |
+
- Python 3.12 environment: `/data/workspace/.venv`
|
| 41 |
+
- code-server settings: `/data/code-server/user-data`
|
| 42 |
+
- code-server extensions: `/data/code-server/extensions`
|
| 43 |
+
- Claude Code configuration and login: `/data/claude`
|
| 44 |
+
- ngrok configuration: `/data/ngrok/ngrok.yml` (via `~/.config/ngrok`)
|
| 45 |
+
- uv and Hugging Face caches: `/data/cache`
|
| 46 |
+
|
| 47 |
+
The repository and prebuilt virtual environment are copied into an empty persistent workspace on first startup. Existing workspace files are not overwritten on later starts.
|
| 48 |
+
|
| 49 |
+
After changing image-seeded files, reset the disposable workspace and restart the Space to seed it again:
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
cd /home/coder
|
| 53 |
+
sudo rm -rf /data/workspace
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Do not run that command when the workspace contains anything you need to keep.
|
| 57 |
+
|
| 58 |
+
## Verify the environment
|
| 59 |
+
|
| 60 |
+
```bash
|
| 61 |
+
pwd
|
| 62 |
+
python --version
|
| 63 |
+
uv --version
|
| 64 |
+
claude --version
|
| 65 |
+
ngrok version
|
| 66 |
+
python -c "import anthropic, fastapi, openai; print('imports OK')"
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Expected workspace and interpreter:
|
| 70 |
+
|
| 71 |
+
```text
|
| 72 |
+
/home/coder/workspace
|
| 73 |
+
Python 3.12.x
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
Dependencies are declared in `pyproject.toml`. After editing it, update the environment with:
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
uv sync
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
## Run the sample FastAPI service
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
uv run uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### Reach it through code-server
|
| 89 |
+
|
| 90 |
+
code-server can proxy internal HTTP ports through its authenticated origin:
|
| 91 |
+
|
| 92 |
+
```text
|
| 93 |
+
https://<space-subdomain>.hf.space/proxy/8000/
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### Reach it through ngrok
|
| 97 |
+
|
| 98 |
+
Set the `NGROK_AUTHTOKEN` Space secret, then run in a second terminal:
|
| 99 |
+
|
| 100 |
+
```bash
|
| 101 |
+
ngrok http 8000
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
Open the HTTPS forwarding URL printed by ngrok. That endpoint is public unless you add access controls, so do not expose secrets or an unauthenticated administrative service.
|
| 105 |
+
|
| 106 |
+
To configure ngrok interactively instead of using the Space secret:
|
| 107 |
+
|
| 108 |
+
```bash
|
| 109 |
+
ngrok config add-authtoken YOUR_TOKEN
|
| 110 |
+
ngrok http 8000
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
The ngrok config is persisted under `/data/ngrok` through `~/.config/ngrok`. The `NGROK_AUTHTOKEN` environment variable is also accepted directly by the ngrok agent.
|
| 114 |
+
|