|
| 1 | +# UTxO RPC Documentation Infrastructure |
| 2 | + |
| 3 | +This document describes the deployment architecture and infrastructure setup for the UTxO RPC documentation site. |
| 4 | + |
| 5 | +## Architecture Overview |
| 6 | + |
| 7 | +The application consists of two main services: |
| 8 | + |
| 9 | +1. **Nextra Documentation Site** - The main documentation site built with Next.js and Nextra |
| 10 | +2. **gRPC UI Service** - An embedded gRPC web interface for interactive API exploration |
| 11 | + |
| 12 | +## Services |
| 13 | + |
| 14 | +### Nextra Documentation (`nextra`) |
| 15 | +- **Port**: 8080 |
| 16 | +- **Framework**: Next.js with Nextra theme |
| 17 | +- **Purpose**: Serves the main documentation website |
| 18 | +- **Proxy**: Routes `/grpcui/*` requests to the gRPC UI service |
| 19 | + |
| 20 | +### gRPC UI Service (`grpcui`) |
| 21 | +- **Port**: 8081 |
| 22 | +- **Purpose**: Provides an interactive web UI for gRPC API exploration |
| 23 | +- **Integration**: Embedded as an iframe in the documentation site |
| 24 | + |
| 25 | +## Docker Configuration |
| 26 | + |
| 27 | +### Multi-Container Setup |
| 28 | + |
| 29 | +The application uses Docker Compose to orchestrate both services: |
| 30 | + |
| 31 | +```yaml |
| 32 | +services: |
| 33 | + nextra: |
| 34 | + build: |
| 35 | + context: . |
| 36 | + dockerfile: Dockerfile |
| 37 | + args: |
| 38 | + - GRPCUI_URL=http://grpcui:8081 |
| 39 | + ports: |
| 40 | + - "8080:8080" |
| 41 | + environment: |
| 42 | + - PORT=8080 |
| 43 | + |
| 44 | + grpcui: |
| 45 | + build: |
| 46 | + context: . |
| 47 | + dockerfile: Dockerfile.grpcui |
| 48 | + ports: |
| 49 | + - "8081:8081" |
| 50 | + environment: |
| 51 | + - USE_PLAINTEXT=false |
| 52 | + - GRPC_TARGET=mainnet.utxorpc-v0.demeter.run:443 |
| 53 | + - API_KEY=utxorpc13rfqzhrntg93wh7uwg8 |
| 54 | + - API_KEY_HEADER=dmtr-api-key |
| 55 | +``` |
| 56 | +
|
| 57 | +### Build Arguments & Environment Variables |
| 58 | +
|
| 59 | +#### Nextra Service |
| 60 | +- `GRPCUI_URL` (build arg): URL for proxying gRPC UI requests (configured at build time) |
| 61 | +- `PORT`: Port the Next.js server listens on |
| 62 | + |
| 63 | +#### gRPC UI Service |
| 64 | +- `USE_PLAINTEXT`: Whether to use plaintext connection (false for SSL/TLS) |
| 65 | +- `GRPC_TARGET`: Target gRPC server endpoint |
| 66 | +- `API_KEY`: Authentication key for the gRPC service |
| 67 | +- `API_KEY_HEADER`: Header name for the API key (default: "dmtr-api-key") |
| 68 | +- `GRPC_PORT`: Port for the gRPC UI service (default: 8081) |
| 69 | + |
| 70 | +## Deployment |
| 71 | + |
| 72 | +### Local Development |
| 73 | + |
| 74 | +1. **Start both services**: |
| 75 | + ```bash |
| 76 | + docker-compose up --build |
| 77 | + ``` |
| 78 | + |
| 79 | +2. **Access the application**: |
| 80 | + - Documentation: http://localhost:8080 |
| 81 | + - gRPC UI (direct): http://localhost:8081 |
| 82 | + - gRPC UI (embedded): http://localhost:8080/grpcui |
| 83 | + |
| 84 | +### Production Deployment |
| 85 | + |
| 86 | +For production deployments: |
| 87 | + |
| 88 | +1. **Update environment variables** in `docker-compose.yml`: |
| 89 | + ```yaml |
| 90 | + environment: |
| 91 | + - GRPC_TARGET=your-production-grpc-endpoint:443 |
| 92 | + - API_KEY=your-production-api-key |
| 93 | + - API_KEY_HEADER=your-auth-header-name |
| 94 | + ``` |
| 95 | + |
| 96 | +2. **Configure build arguments** for internal service communication: |
| 97 | + ```yaml |
| 98 | + args: |
| 99 | + - GRPCUI_URL=http://grpcui:8081 |
| 100 | + ``` |
| 101 | + |
| 102 | +3. **Deploy with Docker Compose**: |
| 103 | + ```bash |
| 104 | + docker-compose -f docker-compose.yml up -d |
| 105 | + ``` |
| 106 | + |
| 107 | +## Version Pinning |
| 108 | + |
| 109 | +The infrastructure uses pinned versions for reproducibility: |
| 110 | + |
| 111 | +- **Go**: `golang:1.24-alpine` |
| 112 | +- **Alpine Linux**: `alpine:3.21` |
| 113 | +- **Node.js**: `node:19-alpine` |
| 114 | +- **gRPC UI**: Commit hash `aa3edefac370a32da4524893ffdca9c591ba0aeb` |
| 115 | + |
| 116 | +## Network Configuration |
| 117 | + |
| 118 | +### Internal Communication |
| 119 | +- Services communicate via Docker's internal networking |
| 120 | +- The `nextra` service proxies requests to `grpcui:8081` |
| 121 | +- gRPC UI binds to `0.0.0.0:8081` to accept connections from other containers |
| 122 | + |
| 123 | +### External Access |
| 124 | +- **Port 8080**: Main documentation site |
| 125 | +- **Port 8081**: Direct access to gRPC UI (optional) |
| 126 | + |
| 127 | +## Configuration Examples |
| 128 | + |
| 129 | +### Different gRPC Endpoints |
| 130 | + |
| 131 | +**Local Development (Plaintext)**: |
| 132 | +```yaml |
| 133 | +environment: |
| 134 | + - USE_PLAINTEXT=true |
| 135 | + - GRPC_TARGET=localhost:50051 |
| 136 | + - API_KEY="" |
| 137 | +``` |
| 138 | + |
| 139 | +**Demeter Mainnet (SSL)**: |
| 140 | +```yaml |
| 141 | +environment: |
| 142 | + - USE_PLAINTEXT=false |
| 143 | + - GRPC_TARGET=mainnet.utxorpc-v0.demeter.run:443 |
| 144 | + - API_KEY=utxorpc13rfqzhrntg93wh7uwg8 |
| 145 | + - API_KEY_HEADER=dmtr-api-key |
| 146 | +``` |
| 147 | + |
| 148 | +**Custom Endpoint**: |
| 149 | +```yaml |
| 150 | +environment: |
| 151 | + - USE_PLAINTEXT=false |
| 152 | + - GRPC_TARGET=api.example.com:443 |
| 153 | + - API_KEY=your-api-key |
| 154 | + - API_KEY_HEADER=authorization |
| 155 | +``` |
| 156 | + |
| 157 | +## Troubleshooting |
| 158 | + |
| 159 | +### Common Issues |
| 160 | + |
| 161 | +1. **Connection Refused Errors**: |
| 162 | + - Ensure gRPC UI service binds to `0.0.0.0` not `127.0.0.1` |
| 163 | + - Check Docker network connectivity between services |
| 164 | + |
| 165 | +2. **Build-time vs Runtime Configuration**: |
| 166 | + - `GRPCUI_URL` must be set as a build argument for Next.js rewrites |
| 167 | + - gRPC connection settings can be runtime environment variables |
| 168 | + |
| 169 | +3. **SSL/TLS Issues**: |
| 170 | + - Set `USE_PLAINTEXT=false` for encrypted endpoints |
| 171 | + - Ensure the target endpoint supports TLS |
| 172 | + |
| 173 | +### Logs |
| 174 | + |
| 175 | +View service logs: |
| 176 | +```bash |
| 177 | +# All services |
| 178 | +docker-compose logs |
| 179 | +
|
| 180 | +# Specific service |
| 181 | +docker-compose logs nextra |
| 182 | +docker-compose logs grpcui |
| 183 | +``` |
| 184 | + |
| 185 | +## Security Considerations |
| 186 | + |
| 187 | +- API keys are passed as environment variables |
| 188 | +- Use Docker secrets for sensitive production deployments |
| 189 | +- The gRPC UI service only accepts connections from the documentation service |
| 190 | +- SSL/TLS is enforced for production gRPC endpoints |
0 commit comments