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"] 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