From 8973627b5fc24c5c709ca48d737ee8b6f776dc11 Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Thu, 12 Feb 2026 21:15:44 +0100 Subject: [PATCH 1/5] update doc --- docs/provider/deployment.md | 45 +++++++++++++++++++++---------------- docs/provider/quickstart.md | 12 ++++++++++ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/docs/provider/deployment.md b/docs/provider/deployment.md index 4ad21e78..99f0166a 100644 --- a/docs/provider/deployment.md +++ b/docs/provider/deployment.md @@ -6,30 +6,25 @@ Production deployment guide for Routstr Provider nodes. For production, use Docker Compose with persistent storage and optional Tor support. -### Basic Setup +### Unified Setup (All-in-one) +To build and run the node with the UI integrated in a single container using the multi-stage build: -Create a `compose.yml`: - -```yaml -services: - routstr: - image: ghcr.io/routstr/proxy:latest - container_name: routstr - restart: unless-stopped - ports: - - "8000:8000" - volumes: - - ./data:/app/data - - ./logs:/app/logs +```bash +docker build -f Dockerfile.full -t routstr-full . +docker run -d -p 8000:8000 --env-file .env routstr-full ``` -Start the node: +### Advanced Setup (Separated UI & Node) +Use the included `compose.yml` for a more flexible setup that separates the UI build process from the node execution. This is useful for development or when you want to manage Tor as a separate service. ```bash docker compose up -d ``` -Then configure everything via the [Admin Dashboard](http://localhost:8000/admin/). +This will: +1. **Build the UI**: Compiles the frontend and copies it to a shared volume. +2. **Start Routstr**: Runs the Python node, mounting the built UI. +3. **Start Tor**: Provides anonymous access via a `.onion` address. --- @@ -189,8 +184,20 @@ docker compose up -d ## Building from Source +### Unified Image (UI + Node) +The easiest way to build everything from source into a single production-ready image: + ```bash -git clone https://github.com/routstr/routstr-core.git -cd routstr-core -docker build -t routstr-local . +docker build -f Dockerfile.full -t routstr-full . +``` + +### Individual Components +If you prefer building them separately or using Docker Compose: + +```bash +# Build using compose +docker compose build + +# Or build the node only (requires manual UI build first) +docker build -t routstr-node . ``` diff --git a/docs/provider/quickstart.md b/docs/provider/quickstart.md index 2771c1f3..8aabc5d9 100644 --- a/docs/provider/quickstart.md +++ b/docs/provider/quickstart.md @@ -26,6 +26,8 @@ You bring the API keys, Routstr handles the billing, payments, and client manage ## 1. Start the Node +You can run the pre-built image directly: + ```bash docker run -d \ --name routstr \ @@ -34,6 +36,16 @@ docker run -d \ ghcr.io/routstr/proxy:latest ``` +### Build from Source (Recommended) +If you want to build the node and UI yourself from source, use the unified Dockerfile: + +```bash +git clone https://github.com/routstr/routstr-core.git +cd routstr-core +docker build -f Dockerfile.full -t routstr-local . +docker run -d -p 8000:8000 --name routstr routstr-local +``` + Verify it's running: ```bash From af658136d4e8bc89a19c9b671880c088af3ff808 Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Thu, 12 Feb 2026 21:18:22 +0100 Subject: [PATCH 2/5] add docker file --- Dockerfile.full | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Dockerfile.full diff --git a/Dockerfile.full b/Dockerfile.full new file mode 100644 index 00000000..923b6e8f --- /dev/null +++ b/Dockerfile.full @@ -0,0 +1,50 @@ +# Multi-stage Dockerfile for Routstr (includes UI build) +# Stage 1: Build the UI +FROM node:23-alpine AS ui-builder +WORKDIR /app/ui + +# Install pnpm +RUN corepack enable pnpm && corepack prepare pnpm@latest --activate + +# Copy UI source +COPY ui/package.json ui/pnpm-lock.yaml* ./ +RUN pnpm install --frozen-lockfile + +COPY ui/ ./ +ENV NEXT_TELEMETRY_DISABLED=1 +# Next.js build produces a static export in 'out' directory +RUN pnpm run build + +# Stage 2: Build the Routstr Node +FROM ghcr.io/astral-sh/uv:python3.11-alpine AS runner + +# Install system dependencies +RUN apk add --no-cache \ + pkgconf \ + build-base \ + automake \ + autoconf \ + libtool \ + m4 \ + perl \ + git + +WORKDIR /app + +# Copy the rest of the application (required for uv sync to find the package) +COPY . . + +# Install dependencies including the specific secp256k1 branch +RUN uv add git+https://github.com/saschanaz/secp256k1-py.git#branch=upgrade060 +RUN uv sync --no-dev + +# Copy the built UI from the ui-builder stage +COPY --from=ui-builder /app/ui/out ./ui_out + +ENV PORT=8000 +ENV PYTHONUNBUFFERED=1 + +EXPOSE 8000 + +# Run the application +CMD ["/app/.venv/bin/fastapi", "run", "routstr", "--host", "0.0.0.0"] From d889274f845eae2bd626c72f916e69a67e609781 Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Thu, 12 Feb 2026 23:25:59 +0100 Subject: [PATCH 3/5] update doc --- docs/provider/configuration.md | 107 +++++++++++++++++++++------------ docs/provider/quickstart.md | 28 +++++++-- 2 files changed, 92 insertions(+), 43 deletions(-) diff --git a/docs/provider/configuration.md b/docs/provider/configuration.md index aaa00e86..05e7e2ac 100644 --- a/docs/provider/configuration.md +++ b/docs/provider/configuration.md @@ -6,6 +6,37 @@ For automated deployments, you can optionally pre-configure settings via environ --- +## Initial Setup (.env file) + +Before running your node, you should create a `.env` file in the project root. This file is used to bootstrap the initial configuration and store sensitive secrets. + +### Example .env + +```bash +# Security (CRITICAL) +ADMIN_PASSWORD=your-secure-password + +# Node Identity +NAME="My AI Node" +DESCRIPTION="Fast access to models" + +# Upstream AI Provider +UPSTREAM_BASE_URL=https://openrouter.ai/api/v1 +UPSTREAM_API_KEY=sk-or-v1-... + +# Lightning Payouts +RECEIVE_LN_ADDRESS=yourname@wallet.com +``` + +### Setting the UI Password + +There are two ways to set or change your Admin Dashboard password: + +1. **Via Environment Variable**: Set `ADMIN_PASSWORD` in your `.env` file before starting the container. This will be the password used for the first login. +2. **Via Dashboard**: Once logged in, go to **Settings** → **Security** to update your password. Dashboard settings override the `.env` file once saved. + +--- + ## Admin Dashboard (Primary) Access the dashboard at `/admin/` on your node. @@ -14,29 +45,29 @@ Access the dashboard at `/admin/` on your node. Connect to your AI provider(s): -| Setting | Description | -|---------|-------------| +| Setting | Description | +| ---------------- | ------------------------------------------------ | | **Upstream URL** | API endpoint (e.g., `https://api.openai.com/v1`) | -| **API Key** | Your provider's API key | +| **API Key** | Your provider's API key | ### Node Identity How your node appears to clients: -| Setting | Description | -|---------|-------------| -| **Name** | Display name (e.g., "Fast GPT-4 Node") | -| **Description** | Brief description of your service | +| Setting | Description | +| --------------- | -------------------------------------- | +| **Name** | Display name (e.g., "Fast GPT-4 Node") | +| **Description** | Brief description of your service | ### Pricing Control your profit margins: -| Setting | Description | Default | -|---------|-------------|---------| -| **Fixed Pricing** | Charge flat rate per request vs. per-token | Off | -| **Exchange Fee** | Buffer for BTC volatility | 1.005 (0.5%) | -| **Upstream Fee** | Your profit markup | 1.10 (10%) | +| Setting | Description | Default | +| ----------------- | ------------------------------------------ | ------------ | +| **Fixed Pricing** | Charge flat rate per request vs. per-token | Off | +| **Exchange Fee** | Buffer for BTC volatility | 1.005 (0.5%) | +| **Upstream Fee** | Your profit markup | 1.10 (10%) | See [Pricing](pricing.md) for detailed strategies. @@ -44,33 +75,33 @@ See [Pricing](pricing.md) for detailed strategies. Which mints to accept payments from: -| Setting | Description | -|---------|-------------| +| Setting | Description | +| --------- | ------------------------------- | | **Mints** | List of trusted Cashu mint URLs | ### Lightning Withdrawals Automatic profit withdrawal: -| Setting | Description | -|---------|-------------| +| Setting | Description | +| --------------------- | ------------------------------- | | **Lightning Address** | Your LN address for withdrawals | ### Security -| Setting | Description | -|---------|-------------| +| Setting | Description | +| ------------------ | ----------------------------- | | **Admin Password** | Password for dashboard access | ### Nostr Discovery Announce your node on the network: -| Setting | Description | -|---------|-------------| -| **Npub** | Your Nostr public key | -| **Nsec** | Your Nostr private key (for signing) | -| **Relays** | Relays to publish announcements | +| Setting | Description | +| ---------- | ------------------------------------ | +| **Npub** | Your Nostr public key | +| **Nsec** | Your Nostr private key (for signing) | +| **Relays** | Relays to publish announcements | See [Discovery](discovery.md) for details. @@ -86,21 +117,21 @@ Use environment variables for: ### All Variables -| Variable | Description | Default | -|----------|-------------|---------| -| `UPSTREAM_BASE_URL` | Upstream API endpoint | — | -| `UPSTREAM_API_KEY` | Upstream API key | — | -| `ADMIN_PASSWORD` | Dashboard password | (none) | -| `DATABASE_URL` | Database connection string | `sqlite+aiosqlite:///keys.db` | -| `NAME` | Node display name | `ARoutstrNode` | -| `DESCRIPTION` | Node description | `A Routstr Node` | -| `NPUB` | Nostr public key (bech32) | — | -| `NSEC` | Nostr private key | — | -| `CASHU_MINTS` | Comma-separated mint URLs | `https://mint.minibits.cash/Bitcoin` | -| `RECEIVE_LN_ADDRESS` | Lightning address for withdrawals | — | -| `TOR_PROXY_URL` | SOCKS5 proxy for Tor | `socks5://127.0.0.1:9050` | -| `CORS_ORIGINS` | Allowed CORS origins | `*` | -| `RELAYS` | Nostr relays (comma-separated) | (default set) | +| Variable | Description | Default | +| -------------------- | --------------------------------- | ------------------------------------ | +| `UPSTREAM_BASE_URL` | Upstream API endpoint | — | +| `UPSTREAM_API_KEY` | Upstream API key | — | +| `ADMIN_PASSWORD` | Dashboard password | (none) | +| `DATABASE_URL` | Database connection string | `sqlite+aiosqlite:///keys.db` | +| `NAME` | Node display name | `ARoutstrNode` | +| `DESCRIPTION` | Node description | `A Routstr Node` | +| `NPUB` | Nostr public key (bech32) | — | +| `NSEC` | Nostr private key | — | +| `CASHU_MINTS` | Comma-separated mint URLs | `https://mint.minibits.cash/Bitcoin` | +| `RECEIVE_LN_ADDRESS` | Lightning address for withdrawals | — | +| `TOR_PROXY_URL` | SOCKS5 proxy for Tor | `socks5://127.0.0.1:9050` | +| `CORS_ORIGINS` | Allowed CORS origins | `*` | +| `RELAYS` | Nostr relays (comma-separated) | (default set) | ### Priority diff --git a/docs/provider/quickstart.md b/docs/provider/quickstart.md index 8aabc5d9..69e05d82 100644 --- a/docs/provider/quickstart.md +++ b/docs/provider/quickstart.md @@ -24,7 +24,20 @@ You bring the API keys, Routstr handles the billing, payments, and client manage --- -## 1. Start the Node +## 1. Prepare Configuration + +Create a `.env` file in the root of the project to store your secrets: + +```bash +# Initial Admin Password +ADMIN_PASSWORD=mysecretpassword + +# Your AI Provider Key +UPSTREAM_BASE_URL=https://api.openai.com/v1 +UPSTREAM_API_KEY=sk-proj-... +``` + +## 2. Start the Node You can run the pre-built image directly: @@ -32,6 +45,7 @@ You can run the pre-built image directly: docker run -d \ --name routstr \ -p 8000:8000 \ + --env-file .env \ -v routstr-data:/app/data \ ghcr.io/routstr/proxy:latest ``` @@ -42,8 +56,12 @@ If you want to build the node and UI yourself from source, use the unified Docke ```bash git clone https://github.com/routstr/routstr-core.git cd routstr-core +# Edit your .env with ADMIN_PASSWORD and API keys +cp .env.example .env +nano .env + docker build -f Dockerfile.full -t routstr-local . -docker run -d -p 8000:8000 --name routstr routstr-local +docker run -d -p 8000:8000 --env-file .env --name routstr routstr-local ``` Verify it's running: @@ -54,12 +72,12 @@ curl http://localhost:8000/v1/info --- -## 2. Configure via Dashboard +## 3. Configure via Dashboard Open the **Admin Dashboard** at [http://localhost:8000/admin/](http://localhost:8000/admin/). -!!! note "Default Access" - The dashboard has no password by default. Set one immediately in Settings for production use. +!!! note "Login" + Use the `ADMIN_PASSWORD` you defined in your `.env` file to log in. If you didn't set one, the dashboard will prompt you to set one on first visit. ### Connect Your AI Providers From 5f376d716d35611964122d69f4a4c19aedcfaeba Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Fri, 13 Feb 2026 21:15:33 +0100 Subject: [PATCH 4/5] clean up --- docs/provider/configuration.md | 5 ----- docs/provider/quickstart.md | 17 +++++++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/provider/configuration.md b/docs/provider/configuration.md index 05e7e2ac..633ccd10 100644 --- a/docs/provider/configuration.md +++ b/docs/provider/configuration.md @@ -13,17 +13,12 @@ Before running your node, you should create a `.env` file in the project root. T ### Example .env ```bash -# Security (CRITICAL) ADMIN_PASSWORD=your-secure-password # Node Identity NAME="My AI Node" DESCRIPTION="Fast access to models" -# Upstream AI Provider -UPSTREAM_BASE_URL=https://openrouter.ai/api/v1 -UPSTREAM_API_KEY=sk-or-v1-... - # Lightning Payouts RECEIVE_LN_ADDRESS=yourname@wallet.com ``` diff --git a/docs/provider/quickstart.md b/docs/provider/quickstart.md index 69e05d82..1e7654b5 100644 --- a/docs/provider/quickstart.md +++ b/docs/provider/quickstart.md @@ -13,7 +13,7 @@ A **Routstr Provider Node** acts as a gateway that: You bring the API keys, Routstr handles the billing, payments, and client management. !!! tip "Future: Node-to-Node Routing" - In future versions, you'll be able to run a node that connects to other Routstr nodes—eliminating the need to configure upstream providers yourself. For now, you'll need your own API credentials. +In future versions, you'll be able to run a node that connects to other Routstr nodes—eliminating the need to configure upstream providers yourself. For now, you'll need your own API credentials. --- @@ -32,9 +32,13 @@ Create a `.env` file in the root of the project to store your secrets: # Initial Admin Password ADMIN_PASSWORD=mysecretpassword -# Your AI Provider Key -UPSTREAM_BASE_URL=https://api.openai.com/v1 -UPSTREAM_API_KEY=sk-proj-... +# Node Identity +NAME="My AI Node" +DESCRIPTION="Fast access to models" + +# Lightning Payouts +RECEIVE_LN_ADDRESS=yourname@wallet.com + ``` ## 2. Start the Node @@ -51,6 +55,7 @@ docker run -d \ ``` ### Build from Source (Recommended) + If you want to build the node and UI yourself from source, use the unified Dockerfile: ```bash @@ -58,7 +63,7 @@ git clone https://github.com/routstr/routstr-core.git cd routstr-core # Edit your .env with ADMIN_PASSWORD and API keys cp .env.example .env -nano .env +nano .env docker build -f Dockerfile.full -t routstr-local . docker run -d -p 8000:8000 --env-file .env --name routstr routstr-local @@ -77,7 +82,7 @@ curl http://localhost:8000/v1/info Open the **Admin Dashboard** at [http://localhost:8000/admin/](http://localhost:8000/admin/). !!! note "Login" - Use the `ADMIN_PASSWORD` you defined in your `.env` file to log in. If you didn't set one, the dashboard will prompt you to set one on first visit. +Use the `ADMIN_PASSWORD` you defined in your `.env` file to log in. If you didn't set one, the dashboard will prompt you to set one on first visit. ### Connect Your AI Providers From 030c2f65e4d800e4c0c0844e9d7ba85aad9b1db8 Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Fri, 13 Feb 2026 22:22:41 +0100 Subject: [PATCH 5/5] add missing info --- docs/provider/quickstart.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/provider/quickstart.md b/docs/provider/quickstart.md index 1e7654b5..28e6c593 100644 --- a/docs/provider/quickstart.md +++ b/docs/provider/quickstart.md @@ -54,6 +54,8 @@ docker run -d \ ghcr.io/routstr/proxy:latest ``` +*Note: The pre-built image does not contain the UI. For the all-in-one experience with the Admin Dashboard, use the Build from Source instructions below.* + ### Build from Source (Recommended) If you want to build the node and UI yourself from source, use the unified Dockerfile: