Skip to content

Commit 3d1b9b9

Browse files
JAORMXclaude
andcommitted
Add custom package registries documentation
Document the build environment configuration feature for custom package registries (toolhive#2742). This allows enterprise environments to configure environment variables like NPM_CONFIG_REGISTRY, GOPROXY, and PIP_INDEX_URL that are injected into Dockerfiles during protocol scheme builds. Adds: - New "Custom package registries" section in build-containers guide - CLI commands: set-build-env, get-build-env, unset-build-env - Table of common environment variables for npm, Go, and pip/uv - Troubleshooting section for custom registry issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5ea2fca commit 3d1b9b9

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

docs/toolhive/guides-cli/build-containers.mdx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ you need to pre-build containers before deploying them.
261261
```
262262

263263
3. **Deploy to Kubernetes** using the pre-built image:
264+
264265
```yaml
265266
apiVersion: toolhive.stacklok.dev/v1alpha1
266267
kind: MCPServer
@@ -330,6 +331,46 @@ thv build uvx://internal-mcp-server
330331
thv build --ca-cert /path/to/special-ca.crt uvx://special-server
331332
```
332333

334+
### Custom package registries
335+
336+
Enterprise environments often use private package registries or mirrors instead
337+
of public registries like npm or PyPI. ToolHive supports configuring build
338+
environment variables that are injected into the Dockerfile during builds,
339+
allowing you to use custom registries for all protocol scheme builds.
340+
341+
#### Set build environment variables
342+
343+
Use the `thv config set-build-env` command to configure environment variables
344+
that will be included in all builds:
345+
346+
```bash
347+
thv config set-build-env <KEY> <VALUE>
348+
```
349+
350+
Common environment variables for package registries:
351+
352+
| Package manager | Environment variable | Example value |
353+
| --------------- | --------------------- | -------------------------------------- |
354+
| npm | `NPM_CONFIG_REGISTRY` | `https://npm.corp.example.com` |
355+
| Go | `GOPROXY` | `https://goproxy.corp.example.com` |
356+
| Go | `GOPRIVATE` | `github.com/mycompany/*` |
357+
| pip/uv | `PIP_INDEX_URL` | `https://pypi.corp.example.com/simple` |
358+
| pip/uv | `PIP_TRUSTED_HOST` | `pypi.corp.example.com` |
359+
360+
Example configuration for an enterprise environment:
361+
362+
```bash
363+
# Configure npm to use a corporate registry
364+
thv config set-build-env NPM_CONFIG_REGISTRY https://npm.corp.example.com
365+
366+
# Configure Go proxy for private modules
367+
thv config set-build-env GOPROXY https://goproxy.corp.example.com
368+
thv config set-build-env GOPRIVATE "github.com/mycompany/*"
369+
370+
# Configure Python/uv to use a corporate PyPI mirror
371+
thv config set-build-env PIP_INDEX_URL https://pypi.corp.example.com/simple
372+
```
373+
333374
### Build local Go projects
334375

335376
Build MCP servers from local Go projects:
@@ -381,9 +422,11 @@ If builds fail with network connectivity issues:
381422

382423
1. **Check internet connectivity** for downloading packages
383424
2. **Configure CA certificates** for corporate environments:
425+
384426
```bash
385427
thv config set-ca-cert /path/to/corporate-ca.crt
386428
```
429+
387430
3. **Use proxy settings** if required by your network
388431
4. **Verify package names** and versions exist in the respective registries
389432

@@ -430,3 +473,29 @@ If the build fails because a package cannot be found:
430473
3. **For Go modules**, ensure the path includes the correct import path
431474

432475
</details>
476+
477+
<details>
478+
<summary>Custom registry not being used</summary>
479+
480+
If your custom package registry configuration isn't being applied:
481+
482+
1. **Verify your build environment configuration**:
483+
484+
```bash
485+
thv config get-build-env
486+
```
487+
488+
2. **Check the environment variable names** match what your package manager
489+
expects (for example, `NPM_CONFIG_REGISTRY` for npm, `GOPROXY` for Go)
490+
491+
3. **Use `--dry-run` to inspect the generated Dockerfile** and verify your
492+
environment variables are being injected:
493+
494+
```bash
495+
thv build --dry-run uvx://my-package
496+
```
497+
498+
4. **Ensure network connectivity** to your custom registry from inside the
499+
container build environment
500+
501+
</details>

0 commit comments

Comments
 (0)