Update docs, Dockerfile, and CI for container registry support
Expanded documentation in both English and Chinese READMEs to include detailed container registry acceleration usage and deployment instructions. Refactored Dockerfile to use a multi-stage build with workerd for self-hosted deployment. Improved .dockerignore for cleaner builds. Updated GitHub Actions workflows to refine path ignores and metadata extraction. Added config.capnp for workerd configuration. Removed obsolete .html file and enhanced CLAUDE.md with comprehensive architecture and development guidance.
This commit is contained in:
1 parent
04410291e2
commit
ad2bf1933c
9 files changed
+886
-728
No files matched your search
+36
-65
@@ -1,78 +1,49 @@
|
||||
# Dependencies
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
# Testing
|
||||
coverage
|
||||
.nyc_output
|
||||
test-results
|
||||
# Build outputs
|
||||
dist/
|
||||
.wrangler/
|
||||
wrangler-dist/
|
||||
|
||||
# Production build
|
||||
dist
|
||||
build
|
||||
# Tests
|
||||
test/
|
||||
coverage/
|
||||
*.test.js
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
# Documentation
|
||||
*.md
|
||||
docs/
|
||||
.github/
|
||||
|
||||
# IDE and editor files
|
||||
.vscode
|
||||
.idea
|
||||
# Git
|
||||
.git/
|
||||
.gitignore
|
||||
.gitattributes
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS generated files
|
||||
# OS
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
logs
|
||||
# CI/CD
|
||||
.github/workflows/
|
||||
|
||||
# Config files not needed in build
|
||||
.prettierrc
|
||||
.prettierignore
|
||||
.eslintrc*
|
||||
tsconfig.json
|
||||
vitest.config.js
|
||||
|
||||
# Misc
|
||||
*.log
|
||||
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# GitHub
|
||||
.github
|
||||
|
||||
# Temporary files
|
||||
tmp
|
||||
temp
|
||||
|
||||
# Documentation
|
||||
*.md
|
||||
!README.md
|
||||
|
||||
# Cloudflare Workers
|
||||
wrangler.toml
|
||||
|
||||
# ESLint
|
||||
.eslintcache
|
||||
|
||||
# Package manager
|
||||
.npm
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
.env
|
||||
.env.*
|
||||
@@ -13,6 +13,10 @@ on:
|
||||
- '.editorconfig'
|
||||
- '.vscode/**'
|
||||
- 'docs/**'
|
||||
- '.prettierrc*'
|
||||
- '.eslintrc*'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
- '.github/PULL_REQUEST_TEMPLATE/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
+24
-60
@@ -4,28 +4,33 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
tags:
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
- 'test/**'
|
||||
- 'scripts/**'
|
||||
- 'LICENSE'
|
||||
- '.gitignore'
|
||||
- '.editorconfig'
|
||||
- 'LICENSE'
|
||||
- '.vscode/**'
|
||||
- 'docs/**'
|
||||
- '.prettierrc*'
|
||||
- '.eslintrc*'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
- '.github/PULL_REQUEST_TEMPLATE/**'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'docs/**'
|
||||
- 'test/**'
|
||||
- 'scripts/**'
|
||||
- 'LICENSE'
|
||||
- '.gitignore'
|
||||
- '.editorconfig'
|
||||
- 'LICENSE'
|
||||
- '.vscode/**'
|
||||
- 'docs/**'
|
||||
- '.prettierrc*'
|
||||
- '.eslintrc*'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
- '.github/PULL_REQUEST_TEMPLATE/**'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
@@ -35,30 +40,26 @@ env:
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
image-tags: ${{ steps.meta.outputs.tags }}
|
||||
image-digest: ${{ steps.build-and-push.outputs.digest }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
attestations: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Container Registry
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
@@ -69,61 +70,24 @@ jobs:
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha,prefix={{branch}}-
|
||||
type=sha
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push image
|
||||
id: build-and-push
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Generate artifact attestation
|
||||
uses: actions/attest-build-provenance@v3
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: actions/attest-build-provenance@v2
|
||||
with:
|
||||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||
subject-digest: ${{ steps.build-and-push.outputs.digest }}
|
||||
subject-digest: ${{ steps.meta.outputs.digest }}
|
||||
push-to-registry: true
|
||||
|
||||
security-scan:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-push
|
||||
if: github.event_name != 'pull_request'
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Debug outputs
|
||||
run: |
|
||||
echo "Image tags: ${{ needs.build-and-push.outputs.image-tags }}"
|
||||
echo "Image digest: ${{ needs.build-and-push.outputs.image-digest }}"
|
||||
echo "Registry: ${{ env.REGISTRY }}"
|
||||
echo "Image name: ${{ env.IMAGE_NAME }}"
|
||||
|
||||
- name: Set image for scanning
|
||||
id: scan-image
|
||||
run: |
|
||||
FIRST_TAG=$(echo "${{ needs.build-and-push.outputs.image-tags }}" | head -n1)
|
||||
echo "image-ref=${FIRST_TAG}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run Trivy vulnerability scanner
|
||||
uses: aquasecurity/trivy-action@master
|
||||
with:
|
||||
image-ref: ${{ steps.scan-image.outputs.image-ref }}
|
||||
format: 'sarif'
|
||||
output: 'trivy-results.sarif'
|
||||
|
||||
- name: Upload Trivy scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@v4
|
||||
if: always()
|
||||
with:
|
||||
sarif_file: 'trivy-results.sarif'
|
||||
@@ -1,4 +0,0 @@
|
||||
<h1 style="display: inline-flex; align-items: center; gap: 8px; margin: 0">
|
||||
<img src="https://xuc.xi-xu.me/Xget.png" alt="Xget Logo" width="80" height="80" />
|
||||
<span>Xget</span>
|
||||
</h1>
|
||||
@@ -4,151 +4,226 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Project Overview
|
||||
|
||||
Xget is a high-performance, secure acceleration engine for developer resources, built on Cloudflare Workers. It provides a unified proxy for accessing code repositories, package managers, AI inference APIs, container registries, and more with enhanced performance through Cloudflare's global edge network.
|
||||
**Xget** is a high-performance acceleration engine for developer resources deployed on Cloudflare Workers. It acts as a unified proxy/acceleration layer for 40+ platforms including code repositories (GitHub, GitLab, Gitea), package managers (npm, PyPI, conda, Maven, etc.), AI inference providers (OpenAI, Anthropic, Gemini), container registries (Docker Hub, GHCR), and Linux distributions.
|
||||
|
||||
**Key Features:**
|
||||
**Primary purpose**: Accelerate access to developer resources for users in regions with connectivity challenges, particularly mainland China.
|
||||
|
||||
- Multi-platform support (50+ platforms including GitHub, npm, PyPI, Docker registries, AI APIs)
|
||||
- Intelligent caching with 30-minute default TTL
|
||||
- Automatic retry mechanism (3 retries with linear backoff)
|
||||
- Enterprise-grade security headers
|
||||
- HTTP/3 and multi-compression support
|
||||
- Special handling for Git, Docker, and AI inference protocols
|
||||
## Technology Stack
|
||||
|
||||
- **Runtime**: Cloudflare Workers (serverless edge computing)
|
||||
- **Language**: JavaScript (ES2022) with JSDoc type annotations
|
||||
- **Testing**: Vitest with `@cloudflare/vitest-pool-workers`
|
||||
- **Deployment**: Wrangler CLI + GitHub Actions
|
||||
- **Code Quality**: ESLint + Prettier
|
||||
- **Type Checking**: TypeScript via JSDoc (no build step)
|
||||
|
||||
## Development Commands
|
||||
|
||||
### Testing
|
||||
```bash
|
||||
# Development
|
||||
npm run dev # Start Wrangler dev server (same as npm start)
|
||||
|
||||
- `npm test` - Run all tests with Vitest (uses Cloudflare Workers test environment)
|
||||
- `npm run test:run` - Run tests once without watch mode
|
||||
- `npm run test:watch` - Run tests in watch mode
|
||||
- `npm run test:ui` - Run tests with Vitest UI
|
||||
- `npm run test:coverage` - Generate test coverage report (80% threshold for branches/functions/lines/statements)
|
||||
# Testing
|
||||
npm test # Run Vitest in watch mode
|
||||
npm run test:run # Run tests once (CI mode)
|
||||
npm run test:coverage # Run tests with coverage report
|
||||
npm run test:ui # Open Vitest UI
|
||||
|
||||
### Code Quality
|
||||
# Code Quality
|
||||
npm run lint # Run ESLint
|
||||
npm run lint:fix # Fix ESLint errors automatically
|
||||
npm run format # Format code with Prettier
|
||||
npm run format:check # Check formatting without changes
|
||||
npm run type-check # TypeScript/JSDoc type checking (no emit)
|
||||
|
||||
- `npm run lint` - Run ESLint on src/ and test/ directories
|
||||
- `npm run lint:fix` - Auto-fix ESLint issues
|
||||
- `npm run format` - Format code with Prettier
|
||||
- `npm run format:check` - Check code formatting without making changes
|
||||
- `npm run type-check` - Run TypeScript type checking (noEmit mode)
|
||||
|
||||
### Development & Deployment
|
||||
|
||||
- `npm run dev` or `npm start` - Start local development server with Wrangler
|
||||
- `npm run deploy` - Deploy to Cloudflare Workers
|
||||
# Deployment
|
||||
npm run deploy # Deploy to Cloudflare Workers
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
### Request Flow
|
||||
|
||||
1. **Request Reception** ([src/index.js](src/index.js):275-806) - `handleRequest()` is the main entry point
|
||||
2. **Validation** ([src/index.js](src/index.js):155-175) - Security validation via `validateRequest()`
|
||||
3. **Platform Detection** ([src/index.js](src/index.js):320-338) - Identifies platform from URL prefix
|
||||
4. **Path Transformation** ([src/config/platforms.js](src/config/platforms.js):99-191) - Converts proxy path to target platform path
|
||||
5. **Cache Check** ([src/index.js](src/index.js):379-409) - Checks Cloudflare cache (skipped for Git/Docker/AI)
|
||||
6. **Upstream Fetch** ([src/index.js](src/index.js):519-662) - Fetches from origin with retry logic
|
||||
7. **Response Processing** ([src/index.js](src/index.js):689-724) - URL rewriting for npm/PyPI responses
|
||||
8. **Cache Storage** ([src/index.js](src/index.js):762-795) - Stores successful 200 responses in cache
|
||||
|
||||
### Core Components
|
||||
|
||||
**[src/index.js](src/index.js)** - Main worker logic
|
||||
1. **Main Request Handler** ([src/index.js](src/index.js))
|
||||
- Entry point with `fetch()` event handler
|
||||
- Protocol detection (Git, Git LFS, Docker, AI inference)
|
||||
- Request validation, retry logic, timeout handling
|
||||
- Performance monitoring (`PerformanceMonitor` class)
|
||||
- Security header management
|
||||
|
||||
- `handleRequest()` - Primary request handler with caching, retries, security
|
||||
- `isGitRequest()`, `isDockerRequest()`, `isAIInferenceRequest()` - Protocol detection functions
|
||||
- `validateRequest()` - Security validation (method whitelist, path length limits)
|
||||
- `PerformanceMonitor` - Tracks request performance metrics
|
||||
- Docker authentication handling ([src/index.js](src/index.js):219-266, 354-371, 579-634)
|
||||
2. **Configuration** ([src/config/index.js](src/config/index.js))
|
||||
- `createConfig(env)` - runtime config with environment overrides
|
||||
- `CONFIG` object with defaults (cache TTL, timeouts, retries)
|
||||
|
||||
**[src/config/platforms.js](src/config/platforms.js)** - Platform definitions and URL transformations
|
||||
3. **Platform Definitions** ([src/config/platforms.js](src/config/platforms.js))
|
||||
- `PLATFORMS` object mapping prefixes to base URLs (40+ entries)
|
||||
- `transformPath()` function for URL transformations
|
||||
- Platform-specific special cases (crates.io API, Jenkins paths, etc.)
|
||||
|
||||
- `PLATFORMS` object - Maps platform keys to base URLs (50+ platforms)
|
||||
- `transformPath()` - Unified path transformation logic for all platforms
|
||||
- Special transformations for crates.io, Homebrew, Jenkins
|
||||
### Request Flow
|
||||
|
||||
**[src/config/index.js](src/config/index.js)** - Configuration management
|
||||
```
|
||||
Request → Validate → Detect Protocol → Transform URL → Check Cache
|
||||
→ Fetch Upstream (with retries) → Handle Docker Auth → Rewrite Response
|
||||
→ Add Security Headers → Cache → Return with Performance Metrics
|
||||
```
|
||||
|
||||
- `createConfig()` - Merges environment variables with defaults
|
||||
- Default values: 30s timeout, 3 retries, 1800s cache, 2048 char max path length
|
||||
### Protocol Detection
|
||||
|
||||
### Platform Categories
|
||||
The system handles different protocols with specialized logic:
|
||||
|
||||
1. **Code Repositories**: gh (GitHub), gl (GitLab), gitea, codeberg, sf (SourceForge), aosp
|
||||
2. **Package Managers**: npm, pypi, conda, maven, gradle, nuget, crates, etc.
|
||||
3. **Container Registries**: cr-docker (Docker Hub), cr-ghcr, cr-gcr, cr-mcr, cr-quay, etc. (prefixed with `cr-`)
|
||||
4. **AI Inference Providers**: ip-openai, ip-anthropic, ip-gemini, etc. (prefixed with `ip-`)
|
||||
5. **Model/Dataset Platforms**: hf (Hugging Face), civitai
|
||||
6. **Linux Distributions**: debian, ubuntu, fedora, arch, etc.
|
||||
- **Git requests**: Via `/info/refs`, `/git-upload-pack` endpoints, User-Agent patterns
|
||||
- **Git LFS**: LFS-specific headers and endpoints
|
||||
- **Docker/OCI registries**: `/v2/` prefix, Docker headers, token auth flow
|
||||
- **AI inference**: `/ip/` prefix for AI API proxying
|
||||
- **Regular downloads**: Default behavior with intelligent caching
|
||||
|
||||
### Special Handling
|
||||
### Security Features
|
||||
|
||||
**Git Operations** ([src/index.js](src/index.js):73-102)
|
||||
All responses include security headers:
|
||||
|
||||
- Detected via User-Agent, endpoints (`/info/refs`, `/git-upload-pack`, `/git-receive-pack`), or query params
|
||||
- Allows POST method, sets Git-specific headers
|
||||
- Skips caching to ensure real-time data
|
||||
- `Strict-Transport-Security` (HSTS)
|
||||
- `X-Frame-Options: DENY`
|
||||
- `X-XSS-Protection`
|
||||
- `Content-Security-Policy`
|
||||
- `Referrer-Policy`
|
||||
- `Permissions-Policy`
|
||||
|
||||
**Git LFS (Large File Storage) Operations** ([src/index.js](src/index.js):104-141)
|
||||
Request validation:
|
||||
|
||||
- Detected via LFS-specific endpoints (`/info/lfs`, `/objects/batch`, `/objects/{oid}`)
|
||||
- Detected via LFS headers (`Accept: application/vnd.git-lfs+json`) or User-Agent (`git-lfs/`)
|
||||
- Supports batch API for efficient object transfers
|
||||
- Sets appropriate content-type headers for LFS operations
|
||||
- Skips caching to ensure real-time data synchronization
|
||||
- Method whitelist (GET/HEAD default, POST/PUT/PATCH for Git/Docker/AI)
|
||||
- Path length limit (2048 characters)
|
||||
- 30-second timeout protection
|
||||
|
||||
**Docker/Container Registries** ([src/index.js](src/index.js):42-65)
|
||||
### Caching Strategy
|
||||
|
||||
- Detected via `/v2/` paths, User-Agent, or Accept headers
|
||||
- Handles Docker authentication flow with token fetching
|
||||
- Supports anonymous access to public repositories
|
||||
- All requests must use `/cr/` prefix (e.g., `/cr/ghcr/owner/repo`)
|
||||
- **Docker Hub Special Handling** ([src/index.js](src/index.js):600-604): Official images (single-name like `nginx`) are automatically prefixed with `library/` for authentication scope, while user images (namespace/image) are passed through unchanged
|
||||
- **Cache bypass**: Git, Git LFS, Docker, AI inference requests skip cache
|
||||
- **Cache TTL**: 1800 seconds (30 minutes) default
|
||||
- **Range requests**: Full support for HTTP 206 partial content
|
||||
- **Smart cache keys**: Different keys for Range vs full-content requests
|
||||
|
||||
**AI Inference APIs** ([src/index.js](src/index.js):110-146)
|
||||
### Content Transformation
|
||||
|
||||
- Detected via `/ip/` paths or common AI endpoints
|
||||
- Allows POST/PUT/PATCH methods
|
||||
- Sets JSON content-type and preserves all request headers
|
||||
- Skips caching for real-time inference
|
||||
- **PyPI URLs**: Rewrites `files.pythonhosted.org` URLs in HTML responses
|
||||
- **npm URLs**: Rewrites tarball URLs in JSON registry responses
|
||||
- **Streaming**: Uses `ReadableStream` for efficient large file handling
|
||||
|
||||
**URL Rewriting** ([src/index.js](src/index.js):689-724)
|
||||
## Testing
|
||||
|
||||
- PyPI: Rewrites `files.pythonhosted.org` URLs to go through `/pypi/files`
|
||||
- npm: Rewrites `registry.npmjs.org` tarball URLs to go through `/npm/`
|
||||
### Test Structure
|
||||
|
||||
## Testing Practices
|
||||
Tests are organized by functionality in `test/`:
|
||||
|
||||
- Tests use Cloudflare Workers test environment via `@cloudflare/vitest-pool-workers`
|
||||
- Use `SELF.fetch()` to make requests to the worker in tests
|
||||
- Test files are organized by functionality: platforms, security, integration, performance, range-cache
|
||||
- Fixtures in [test/fixtures/responses.js](test/fixtures/responses.js)
|
||||
- Test utilities in [test/helpers/test-utils.js](test/helpers/test-utils.js)
|
||||
- `index.test.js` - Core request handling
|
||||
- `integration.test.js` - End-to-end platform tests
|
||||
- `security.test.js` - Security headers and validation
|
||||
- `performance.test.js` - Performance monitoring
|
||||
- `platforms.test.js` - URL transformation logic
|
||||
- `container-registry.test.js` - Docker/OCI registry flows
|
||||
- `range-cache.test.js` - HTTP Range requests
|
||||
- Platform-specific: `npm-fix.test.js`, `crates.test.js`, `homebrew.test.js`, `opensuse.test.js`, `cran.test.js`, `jenkins.test.js`
|
||||
|
||||
## Configuration
|
||||
### Coverage Requirements
|
||||
|
||||
Runtime configuration can be overridden via Cloudflare Workers environment variables:
|
||||
Minimum 80% coverage for:
|
||||
|
||||
- `TIMEOUT_SECONDS` - Request timeout (default: 30)
|
||||
- `MAX_RETRIES` - Max retry attempts (default: 3)
|
||||
- `RETRY_DELAY_MS` - Delay between retries (default: 1000)
|
||||
- `CACHE_DURATION` - Cache TTL in seconds (default: 1800)
|
||||
- `ALLOWED_METHODS` - Comma-separated HTTP methods (default: GET,HEAD)
|
||||
- `MAX_PATH_LENGTH` - Maximum URL path length (default: 2048)
|
||||
- Branches
|
||||
- Functions
|
||||
- Lines
|
||||
- Statements
|
||||
|
||||
## Adding New Platforms
|
||||
### Running Specific Tests
|
||||
|
||||
To add a new platform:
|
||||
```bash
|
||||
# Run specific test file
|
||||
npm test -- index.test.js
|
||||
|
||||
1. Add entry to `PLATFORMS` object in [src/config/platforms.js](src/config/platforms.js)
|
||||
2. Add path transformation logic in `transformPath()` if needed (most platforms don't need special handling)
|
||||
3. Update tests in [test/platforms.test.js](test/platforms.test.js)
|
||||
4. For platforms requiring special protocol handling (like Git/Docker), add detection function in [src/index.js](src/index.js)
|
||||
# Run tests matching pattern
|
||||
npm test -- --grep "Docker"
|
||||
|
||||
## Security Considerations
|
||||
# Run with coverage
|
||||
npm run test:coverage
|
||||
```
|
||||
|
||||
- All responses include strict security headers (HSTS, X-Frame-Options, CSP, etc.)
|
||||
- HTTP method whitelist enforced (except for Git/Docker/AI operations)
|
||||
- Path length validation to prevent excessively long URLs
|
||||
- 30-second request timeout to prevent resource exhaustion
|
||||
- Input sanitization in URL transformations
|
||||
## Code Style
|
||||
|
||||
- **JSDoc annotations**: All functions must have JSDoc type annotations
|
||||
- **ES modules**: Use `import/export`, not `require()`
|
||||
- **Async/await**: Prefer over Promise chains
|
||||
- **Error handling**: All fetch operations must have retry logic and timeout protection
|
||||
|
||||
## Important Patterns
|
||||
|
||||
### Adding a New Platform
|
||||
|
||||
1. Add entry to `PLATFORMS` object in [src/config/platforms.js](src/config/platforms.js):
|
||||
|
||||
```js
|
||||
'prefix': 'https://example.com'
|
||||
```
|
||||
|
||||
2. If special URL transformation needed, add case in `transformPath()`:
|
||||
|
||||
```js
|
||||
if (platform === 'prefix' && /* condition */) {
|
||||
// Custom transformation
|
||||
}
|
||||
```
|
||||
|
||||
3. Add integration test in [test/integration.test.js](test/integration.test.js)
|
||||
|
||||
4. Update README.md with usage examples
|
||||
|
||||
### Retry Logic Pattern
|
||||
|
||||
All upstream fetches use:
|
||||
|
||||
```js
|
||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
// Fetch with AbortController for timeout
|
||||
const response = await fetch(url, { signal: controller.signal });
|
||||
// Handle response
|
||||
break;
|
||||
} catch (error) {
|
||||
// Only retry on 5xx or network errors, not 4xx
|
||||
if (attempt === maxRetries || isClientError(response)) throw error;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Performance Monitoring
|
||||
|
||||
Use `PerformanceMonitor` class to track timing:
|
||||
|
||||
```js
|
||||
const perfMon = new PerformanceMonitor();
|
||||
perfMon.mark('operation_start');
|
||||
// ... do work ...
|
||||
perfMon.mark('operation_complete');
|
||||
const metrics = perfMon.getMetrics(); // Returns timing data
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
- **Target**: Cloudflare Workers
|
||||
- **Config**: [wrangler.toml](wrangler.toml)
|
||||
- **CI/CD**: GitHub Actions ([.github/workflows/depoly.yml](.github/workflows/depoly.yml))
|
||||
- **Secrets required**: `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Configuration can be overridden via Cloudflare Workers environment variables:
|
||||
|
||||
- `CACHE_TTL` - Cache time-to-live in seconds (default: 1800)
|
||||
- `MAX_RETRIES` - Maximum retry attempts (default: 3)
|
||||
- `TIMEOUT` - Request timeout in milliseconds (default: 30000)
|
||||
- Platform-specific base URLs can be overridden by setting env var matching platform key
|
||||
|
||||
## Key Files to Reference
|
||||
|
||||
- [src/index.js](src/index.js) - Main application logic (~900 lines)
|
||||
- [src/config/platforms.js](src/config/platforms.js) - All platform definitions and transformations
|
||||
- [src/config/index.js](src/config/index.js) - Configuration management
|
||||
- [wrangler.toml](wrangler.toml) - Cloudflare Workers deployment config
|
||||
- [vitest.config.js](vitest.config.js) - Test configuration
|
||||
+24
-28
@@ -1,38 +1,34 @@
|
||||
# Use the official Node.js runtime as the base image
|
||||
FROM node:20-alpine
|
||||
# --- Stage 1: build the Worker with Wrangler -----------------------
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json first to leverage Docker cache for dependencies
|
||||
COPY package.json package-lock.json* ./
|
||||
# Install dependencies & wrangler
|
||||
COPY package*.json wrangler.toml ./
|
||||
RUN npm ci
|
||||
|
||||
# Install dependencies - use npm ci for reproducible builds if package-lock.json exists, otherwise npm install
|
||||
RUN if [ -f package-lock.json ]; then npm ci --only=production; else npm install --only=production; fi
|
||||
# Copy source and build
|
||||
COPY src ./src
|
||||
RUN npx wrangler deploy --dry-run --outdir=dist
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
# --- Stage 2: minimal runtime with workerd -------------------------
|
||||
FROM node:22-slim AS runtime
|
||||
|
||||
# Create a non-root user for security
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S xget -u 1001
|
||||
# Install ca-certificates for SSL, then install workerd via npm
|
||||
RUN apt-get update && \
|
||||
apt-get install -y ca-certificates && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
npm install -g @cloudflare/workerd-linux-64 && \
|
||||
ln -s /usr/local/lib/node_modules/@cloudflare/workerd-linux-64/bin/workerd /usr/local/bin/workerd && \
|
||||
workerd --version
|
||||
|
||||
# Change ownership of the app directory to the nodejs user
|
||||
RUN chown -R xget:nodejs /app
|
||||
WORKDIR /worker
|
||||
|
||||
# Switch to the non-root user
|
||||
USER xget
|
||||
# Bring in the compiled Worker bundle and config
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY config.capnp ./config.capnp
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 3000
|
||||
# Expose the port workerd listens on
|
||||
EXPOSE 8080
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "server.js"]
|
||||
CMD ["workerd", "serve", "config.capnp"]
|
||||
+298
-232
@@ -46,10 +46,10 @@
|
||||
[](#arxiv-paper-download)
|
||||
[](#f-droid-repository-mirror)
|
||||
[](#jenkins-plugin-download)
|
||||
[](#ai-inference-providers)
|
||||
[](#container-registries)
|
||||
[](#ai-inference-providers)
|
||||
|
||||
Ultra-high-performance, secure, all-in-one acceleration engine for developer resources that significantly outperforms traditional solutions, delivering unified, efficient acceleration across code repositories, package registries, AI inference APIs, container images, models, datasets, and more.
|
||||
Ultra-high-performance, secure, all-in-one acceleration engine for developer resources that significantly outperforms traditional solutions, delivering unified, efficient acceleration across code repositories, model and dataset hubs, package registries, container registries, AI inference providers and more.
|
||||
|
||||
In-depth technical analysis article published: ***[Deep Dive into Xget: A High-Performance, Multi-Protocol, and Secure Acceleration Engine for Developer Resources](https://blog.xi-xu.me/2025/10/07/deep-dive-into-xget-technology-en.html)***.
|
||||
|
||||
@@ -172,8 +172,8 @@ Using the pre-deployed instance **`xget.xi-xu.me`** or your own deployed instanc
|
||||
| arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` |
|
||||
| F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` |
|
||||
| Jenkins Plugins | `jenkins` | `https://updates.jenkins.io/...` | `https://xget.xi-xu.me/jenkins/...` |
|
||||
| AI Inference Providers | `ip` | See [AI Inference Providers](#ai-inference-providers) | See [AI Inference Providers](#ai-inference-providers) |
|
||||
| Container Registries | `cr` | See [Container Registries](#container-registries) | See [Container Registries](#container-registries) |
|
||||
| AI Inference Providers | `ip` | See [AI Inference Providers](#ai-inference-providers) | See [AI Inference Providers](#ai-inference-providers) |
|
||||
|
||||
### Platform Conversion Examples
|
||||
|
||||
@@ -637,6 +637,58 @@ https://updates.jenkins.io/download/plugins/maven-plugin/3.27/maven-plugin.hpi
|
||||
https://xget.xi-xu.me/jenkins/download/plugins/maven-plugin/3.27/maven-plugin.hpi
|
||||
```
|
||||
|
||||
#### Container Registries
|
||||
|
||||
Xget supports multiple container registries, using the `cr/[Registry Prefix]` format:
|
||||
|
||||
| Container Registry | Registry Prefix | Original URL Format | Accelerated URL Format |
|
||||
|-------------------|----------------|---------------------|------------------------|
|
||||
| Docker Hub | `docker` | `https://registry-1.docker.io/...` | `https://xget.xi-xu.me/cr/docker/...` |
|
||||
| Quay.io | `quay` | `https://quay.io/...` | `https://xget.xi-xu.me/cr/quay/...` |
|
||||
| Google Container Registry | `gcr` | `https://gcr.io/...` | `https://xget.xi-xu.me/cr/gcr/...` |
|
||||
| Microsoft Container Registry | `mcr` | `https://mcr.microsoft.com/...` | `https://xget.xi-xu.me/cr/mcr/...` |
|
||||
| Amazon Public ECR | `ecr` | `https://public.ecr.aws/...` | `https://xget.xi-xu.me/cr/ecr/...` |
|
||||
| GitHub Container Registry | `ghcr` | `https://ghcr.io/...` | `https://xget.xi-xu.me/cr/ghcr/...` |
|
||||
| GitLab Container Registry | `gitlab` | `https://registry.gitlab.com/...` | `https://xget.xi-xu.me/cr/gitlab/...` |
|
||||
| Red Hat Registry | `redhat` | `https://registry.redhat.io/...` | `https://xget.xi-xu.me/cr/redhat/...` |
|
||||
| Oracle Container Registry | `oracle` | `https://container-registry.oracle.com/...` | `https://xget.xi-xu.me/cr/oracle/...` |
|
||||
| Cloudsmith | `cloudsmith` | `https://docker.cloudsmith.io/...` | `https://xget.xi-xu.me/cr/cloudsmith/...` |
|
||||
| DigitalOcean Registry | `digitalocean` | `https://registry.digitalocean.com/...` | `https://xget.xi-xu.me/cr/digitalocean/...` |
|
||||
| VMware Registry | `vmware` | `https://projects.registry.vmware.com/...` | `https://xget.xi-xu.me/cr/vmware/...` |
|
||||
| Kubernetes Registry | `k8s` | `https://registry.k8s.io/...` | `https://xget.xi-xu.me/cr/k8s/...` |
|
||||
| Heroku Registry | `heroku` | `https://registry.heroku.com/...` | `https://xget.xi-xu.me/cr/heroku/...` |
|
||||
| SUSE Registry | `suse` | `https://registry.suse.com/...` | `https://xget.xi-xu.me/cr/suse/...` |
|
||||
| openSUSE Registry | `opensuse` | `https://registry.opensuse.org/...` | `https://xget.xi-xu.me/cr/opensuse/...` |
|
||||
| Gitpod Registry | `gitpod` | `https://registry.gitpod.io/...` | `https://xget.xi-xu.me/cr/gitpod/...` |
|
||||
|
||||
```url
|
||||
# Docker Hub original URL (official images)
|
||||
https://registry-1.docker.io/v2/library/nginx/manifests/latest
|
||||
|
||||
# Converted (add cr/docker prefix)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginx/manifests/latest
|
||||
|
||||
# Docker Hub original URL (user images)
|
||||
https://registry-1.docker.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# Converted (add cr/docker prefix)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# GitHub Container Registry original URL
|
||||
https://ghcr.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# Converted (add cr/ghcr prefix)
|
||||
https://xget.xi-xu.me/cr/ghcr/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# Google Container Registry original URL
|
||||
https://gcr.io/v2/distroless/base/manifests/latest
|
||||
|
||||
# Converted (add cr/gcr prefix)
|
||||
https://xget.xi-xu.me/cr/gcr/v2/distroless/base/manifests/latest
|
||||
```
|
||||
|
||||
For use cases, see [Container Image Acceleration](#container-image-acceleration).
|
||||
|
||||
#### AI Inference Providers
|
||||
|
||||
Xget supports API acceleration for many mainstream AI inference providers, using the `ip/[AI Provider Prefix]` format:
|
||||
@@ -700,58 +752,6 @@ https://xget.xi-xu.me/ip/huggingface/hf-inference/models/openai/whisper-large-v3
|
||||
|
||||
For use cases, see [AI Inference API Acceleration](#ai-inference-api-acceleration).
|
||||
|
||||
#### Container Registries
|
||||
|
||||
Xget supports multiple container registries, using the `cr/[Registry Prefix]` format:
|
||||
|
||||
| Container Registry | Registry Prefix | Original URL Format | Accelerated URL Format |
|
||||
|-------------------|----------------|---------------------|------------------------|
|
||||
| Docker Hub | `docker` | `https://registry-1.docker.io/...` | `https://xget.xi-xu.me/cr/docker/...` |
|
||||
| Quay.io | `quay` | `https://quay.io/...` | `https://xget.xi-xu.me/cr/quay/...` |
|
||||
| Google Container Registry | `gcr` | `https://gcr.io/...` | `https://xget.xi-xu.me/cr/gcr/...` |
|
||||
| Microsoft Container Registry | `mcr` | `https://mcr.microsoft.com/...` | `https://xget.xi-xu.me/cr/mcr/...` |
|
||||
| Amazon Public ECR | `ecr` | `https://public.ecr.aws/...` | `https://xget.xi-xu.me/cr/ecr/...` |
|
||||
| GitHub Container Registry | `ghcr` | `https://ghcr.io/...` | `https://xget.xi-xu.me/cr/ghcr/...` |
|
||||
| GitLab Container Registry | `gitlab` | `https://registry.gitlab.com/...` | `https://xget.xi-xu.me/cr/gitlab/...` |
|
||||
| Red Hat Registry | `redhat` | `https://registry.redhat.io/...` | `https://xget.xi-xu.me/cr/redhat/...` |
|
||||
| Oracle Container Registry | `oracle` | `https://container-registry.oracle.com/...` | `https://xget.xi-xu.me/cr/oracle/...` |
|
||||
| Cloudsmith | `cloudsmith` | `https://docker.cloudsmith.io/...` | `https://xget.xi-xu.me/cr/cloudsmith/...` |
|
||||
| DigitalOcean Registry | `digitalocean` | `https://registry.digitalocean.com/...` | `https://xget.xi-xu.me/cr/digitalocean/...` |
|
||||
| VMware Registry | `vmware` | `https://projects.registry.vmware.com/...` | `https://xget.xi-xu.me/cr/vmware/...` |
|
||||
| Kubernetes Registry | `k8s` | `https://registry.k8s.io/...` | `https://xget.xi-xu.me/cr/k8s/...` |
|
||||
| Heroku Registry | `heroku` | `https://registry.heroku.com/...` | `https://xget.xi-xu.me/cr/heroku/...` |
|
||||
| SUSE Registry | `suse` | `https://registry.suse.com/...` | `https://xget.xi-xu.me/cr/suse/...` |
|
||||
| openSUSE Registry | `opensuse` | `https://registry.opensuse.org/...` | `https://xget.xi-xu.me/cr/opensuse/...` |
|
||||
| Gitpod Registry | `gitpod` | `https://registry.gitpod.io/...` | `https://xget.xi-xu.me/cr/gitpod/...` |
|
||||
|
||||
```url
|
||||
# Docker Hub original URL (official images)
|
||||
https://registry-1.docker.io/v2/library/nginx/manifests/latest
|
||||
|
||||
# Converted (add cr/docker prefix)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginx/manifests/latest
|
||||
|
||||
# Docker Hub original URL (user images)
|
||||
https://registry-1.docker.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# Converted (add cr/docker prefix)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# GitHub Container Registry original URL
|
||||
https://ghcr.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# Converted (add cr/ghcr prefix)
|
||||
https://xget.xi-xu.me/cr/ghcr/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# Google Container Registry original URL
|
||||
https://gcr.io/v2/distroless/base/manifests/latest
|
||||
|
||||
# Converted (add cr/gcr prefix)
|
||||
https://xget.xi-xu.me/cr/gcr/v2/distroless/base/manifests/latest
|
||||
```
|
||||
|
||||
For use cases, see [Container Image Acceleration](#container-image-acceleration).
|
||||
|
||||
## 🎯 Use Cases
|
||||
|
||||
### Git Operations and Configuration
|
||||
@@ -1970,6 +1970,181 @@ pipeline {
|
||||
}
|
||||
```
|
||||
|
||||
### Container Image Acceleration
|
||||
|
||||
#### Docker Configuration
|
||||
|
||||
```bash
|
||||
# Configure Docker to use Xget image acceleration
|
||||
# Edit /etc/docker/daemon.json (Linux) or ~/.docker/daemon.json (macOS/Windows)
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"https://xget.xi-xu.me/cr/ghcr"
|
||||
]
|
||||
}
|
||||
|
||||
# Restart Docker service
|
||||
sudo systemctl restart docker # Linux
|
||||
# Or restart service in Docker Desktop
|
||||
|
||||
# Verify configuration
|
||||
docker info | grep -A 10 "Registry Mirrors"
|
||||
```
|
||||
|
||||
#### Pull Images Directly
|
||||
|
||||
```bash
|
||||
# Pull GitHub Container Registry images
|
||||
docker pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
|
||||
# Pull Google Container Registry images
|
||||
docker pull xget.xi-xu.me/cr/gcr/distroless/base:latest
|
||||
|
||||
# Pull Microsoft Container Registry images
|
||||
docker pull xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0
|
||||
```
|
||||
|
||||
#### Kubernetes Deployment Configuration
|
||||
|
||||
```yaml
|
||||
# deployment.yaml - Use Xget's images
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- name: redis
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
```
|
||||
|
||||
#### Docker Compose Configuration
|
||||
|
||||
```yaml
|
||||
# docker-compose.yml - Use Xget accelerated images
|
||||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./html:/usr/share/nginx/html
|
||||
|
||||
database:
|
||||
image: xget.xi-xu.me/cr/mcr/mssql/server:2022-latest
|
||||
environment:
|
||||
ACCEPT_EULA: Y
|
||||
SA_PASSWORD: "MyStrongPassword123!"
|
||||
volumes:
|
||||
- mssql_data:/var/opt/mssql
|
||||
|
||||
cache:
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
volumes:
|
||||
mssql_data:
|
||||
```
|
||||
|
||||
#### Dockerfile Optimization
|
||||
|
||||
```dockerfile
|
||||
# Use Xget accelerated base images in Dockerfile
|
||||
FROM xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Use Microsoft Container Registry's .NET image
|
||||
FROM xget.xi-xu.me/cr/mcr/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/publish .
|
||||
ENTRYPOINT ["dotnet", "MyApp.dll"]
|
||||
```
|
||||
|
||||
#### CI/CD Integration
|
||||
|
||||
```yaml
|
||||
# GitHub Actions - Use Xget to accelerate container builds
|
||||
name: Build and Deploy
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build with accelerated base images
|
||||
run: |
|
||||
# Build using Xget's base images
|
||||
docker build -t myapp:latest \
|
||||
--build-arg BASE_IMAGE=xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine .
|
||||
|
||||
- name: Test with accelerated images
|
||||
run: |
|
||||
# Test using accelerated images
|
||||
docker run --rm \
|
||||
xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0 \
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
#### Podman Configuration
|
||||
|
||||
```bash
|
||||
# Configure Podman to use Xget image acceleration
|
||||
# Edit /etc/containers/registries.conf
|
||||
[[registry]]
|
||||
prefix = "ghcr.io"
|
||||
location = "xget.xi-xu.me/cr/ghcr"
|
||||
|
||||
# Or pull directly
|
||||
podman pull xget.xi-xu.me/cr/ghcr/alpine/alpine:latest
|
||||
podman pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
```
|
||||
|
||||
#### containerd Configuration
|
||||
|
||||
```toml
|
||||
# Configure containerd to use Xget
|
||||
# Edit /etc/containerd/config.toml
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/ghcr"]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/gcr"]
|
||||
```
|
||||
|
||||
```bash
|
||||
# Restart containerd
|
||||
sudo systemctl restart containerd
|
||||
```
|
||||
|
||||
### AI Inference API Acceleration
|
||||
|
||||
#### OpenAI API
|
||||
@@ -2172,184 +2347,11 @@ client = OpenAI(
|
||||
)
|
||||
```
|
||||
|
||||
### Container Image Acceleration
|
||||
|
||||
#### Docker Configuration
|
||||
|
||||
```bash
|
||||
# Configure Docker to use Xget image acceleration
|
||||
# Edit /etc/docker/daemon.json (Linux) or ~/.docker/daemon.json (macOS/Windows)
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"https://xget.xi-xu.me/cr/ghcr"
|
||||
]
|
||||
}
|
||||
|
||||
# Restart Docker service
|
||||
sudo systemctl restart docker # Linux
|
||||
# Or restart service in Docker Desktop
|
||||
|
||||
# Verify configuration
|
||||
docker info | grep -A 10 "Registry Mirrors"
|
||||
```
|
||||
|
||||
#### Pull Images Directly
|
||||
|
||||
```bash
|
||||
# Pull GitHub Container Registry images
|
||||
docker pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
|
||||
# Pull Google Container Registry images
|
||||
docker pull xget.xi-xu.me/cr/gcr/distroless/base:latest
|
||||
|
||||
# Pull Microsoft Container Registry images
|
||||
docker pull xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0
|
||||
```
|
||||
|
||||
#### Kubernetes Deployment Configuration
|
||||
|
||||
```yaml
|
||||
# deployment.yaml - Use Xget's images
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- name: redis
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
```
|
||||
|
||||
#### Docker Compose Configuration
|
||||
|
||||
```yaml
|
||||
# docker-compose.yml - Use Xget accelerated images
|
||||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./html:/usr/share/nginx/html
|
||||
|
||||
database:
|
||||
image: xget.xi-xu.me/cr/mcr/mssql/server:2022-latest
|
||||
environment:
|
||||
ACCEPT_EULA: Y
|
||||
SA_PASSWORD: "MyStrongPassword123!"
|
||||
volumes:
|
||||
- mssql_data:/var/opt/mssql
|
||||
|
||||
cache:
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
volumes:
|
||||
mssql_data:
|
||||
```
|
||||
|
||||
#### Dockerfile Optimization
|
||||
|
||||
```dockerfile
|
||||
# Use Xget accelerated base images in Dockerfile
|
||||
FROM xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Use Microsoft Container Registry's .NET image
|
||||
FROM xget.xi-xu.me/cr/mcr/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/publish .
|
||||
ENTRYPOINT ["dotnet", "MyApp.dll"]
|
||||
```
|
||||
|
||||
#### CI/CD Integration
|
||||
|
||||
```yaml
|
||||
# GitHub Actions - Use Xget to accelerate container builds
|
||||
name: Build and Deploy
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build with accelerated base images
|
||||
run: |
|
||||
# Build using Xget's base images
|
||||
docker build -t myapp:latest \
|
||||
--build-arg BASE_IMAGE=xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine .
|
||||
|
||||
- name: Test with accelerated images
|
||||
run: |
|
||||
# Test using accelerated images
|
||||
docker run --rm \
|
||||
xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0 \
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
#### Podman Configuration
|
||||
|
||||
```bash
|
||||
# Configure Podman to use Xget image acceleration
|
||||
# Edit /etc/containers/registries.conf
|
||||
[[registry]]
|
||||
prefix = "ghcr.io"
|
||||
location = "xget.xi-xu.me/cr/ghcr"
|
||||
|
||||
# Or pull directly
|
||||
podman pull xget.xi-xu.me/cr/ghcr/alpine/alpine:latest
|
||||
podman pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
```
|
||||
|
||||
#### containerd Configuration
|
||||
|
||||
```toml
|
||||
# Configure containerd to use Xget
|
||||
# Edit /etc/containerd/config.toml
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/ghcr"]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/gcr"]
|
||||
```
|
||||
|
||||
```bash
|
||||
# Restart containerd
|
||||
sudo systemctl restart containerd
|
||||
```
|
||||
|
||||
## 🚀 Deployment
|
||||
|
||||
### Deployment Steps
|
||||
### Deploy to Cloudflare Workers
|
||||
|
||||
#### Deployment Steps
|
||||
|
||||
1. **Fork this repository**: [Fork xixu-me/Xget](https://github.com/xixu-me/Xget/fork)
|
||||
|
||||
@@ -2375,7 +2377,7 @@ After deployment completes, your Xget service will be available at:
|
||||
- Worker domain: `your-worker-name.your-subdomain.workers.dev`
|
||||
- Custom domain: `your-domain.com` (if bound)
|
||||
|
||||
### Environment Variable Configuration
|
||||
#### Environment Variable Configuration
|
||||
|
||||
You can set the following environment variables in the Cloudflare Workers console to customize configuration:
|
||||
|
||||
@@ -2387,6 +2389,70 @@ You can set the following environment variables in the Cloudflare Workers consol
|
||||
- `ALLOWED_ORIGINS`: Allowed CORS origins (default: *)
|
||||
- `MAX_PATH_LENGTH`: Maximum path length (default: 2048)
|
||||
|
||||
### Self-Hosted Deployment
|
||||
|
||||
If you prefer to run Xget on your own server, you can use Docker deployment:
|
||||
|
||||
#### Using Pre-built Image
|
||||
|
||||
Pull and run the pre-built image from GitHub Container Registry:
|
||||
|
||||
```bash
|
||||
# Pull the latest image
|
||||
docker pull ghcr.io/xixu-me/xget:latest
|
||||
|
||||
# Run the container
|
||||
docker run -d \
|
||||
--name xget \
|
||||
-p 8080:8080 \
|
||||
ghcr.io/xixu-me/xget:latest
|
||||
```
|
||||
|
||||
#### Building Locally
|
||||
|
||||
Build the Docker image from source:
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/xixu-me/Xget.git
|
||||
cd Xget
|
||||
|
||||
# Build the image
|
||||
docker build -t xget:local .
|
||||
|
||||
# Run the container
|
||||
docker run -d \
|
||||
--name xget \
|
||||
-p 8080:8080 \
|
||||
xget:local
|
||||
```
|
||||
|
||||
#### Using Docker Compose
|
||||
|
||||
Create a `docker-compose.yml` file:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
xget:
|
||||
image: ghcr.io/xixu-me/xget:latest
|
||||
container_name: xget
|
||||
ports:
|
||||
- "8080:8080"
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
After deployment, Xget will be available at `http://localhost:8080`.
|
||||
|
||||
**Note**: Self-hosted deployment does not include Cloudflare Workers' global edge network acceleration. Performance depends on your server configuration and network environment.
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Configuration Parameters
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
[](#arxiv-论文下载)
|
||||
[](#f-droid-存储库镜像)
|
||||
[](#jenkins-插件下载)
|
||||
[](#ai-推理提供商)
|
||||
[](#容器注册表)
|
||||
[](#ai-推理提供商)
|
||||
|
||||
面向开发者资源的超高性能、安全、一体化加速引擎,其性能显著优于传统解决方案,为代码存储库、软件包注册表、AI 推理 API、容器镜像、模型、数据集及更多资源提供统一且高效的加速。
|
||||
面向开发者资源的超高性能、安全、一体化加速引擎,其性能显著优于传统解决方案,为代码存储库、模型和数据集中心、软件包注册表、容器注册表、AI 推理提供商等提供统一、高效的加速。
|
||||
|
||||
技术深度解析文章已发布:**[《深入剖析 Xget:一个高性能、多协议、高安全性的开发者资源加速引擎》](https://blog.xi-xu.me/2025/10/07/deep-dive-into-xget-technology.html)**。
|
||||
|
||||
@@ -181,8 +181,8 @@
|
||||
| arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` |
|
||||
| F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` |
|
||||
| Jenkins 插件 | `jenkins` | `https://updates.jenkins.io/...` | `https://xget.xi-xu.me/jenkins/...` |
|
||||
| AI 推理提供商 | `ip` | 见 [AI 推理提供商](#ai-推理提供商) | 见 [AI 推理提供商](#ai-推理提供商) |
|
||||
| 容器注册表 | `cr` | 见[容器注册表](#容器注册表) | 见[容器注册表](#容器注册表) |
|
||||
| AI 推理提供商 | `ip` | 见 [AI 推理提供商](#ai-推理提供商) | 见 [AI 推理提供商](#ai-推理提供商) |
|
||||
|
||||
### 各平台转换示例
|
||||
|
||||
@@ -646,6 +646,58 @@ https://updates.jenkins.io/download/plugins/maven-plugin/3.27/maven-plugin.hpi
|
||||
https://xget.xi-xu.me/jenkins/download/plugins/maven-plugin/3.27/maven-plugin.hpi
|
||||
```
|
||||
|
||||
#### 容器注册表
|
||||
|
||||
Xget 支持多个容器注册表,使用 `cr/[容器注册表前缀]` 格式:
|
||||
|
||||
| 容器注册表 | 容器注册表前缀 | 原始 URL 格式 | 加速 URL 格式 |
|
||||
|----------|------|--------------|--------------|
|
||||
| Docker Hub | `docker` | `https://registry-1.docker.io/...` | `https://xget.xi-xu.me/cr/docker/...` |
|
||||
| Quay.io | `quay` | `https://quay.io/...` | `https://xget.xi-xu.me/cr/quay/...` |
|
||||
| 谷歌容器注册表 | `gcr` | `https://gcr.io/...` | `https://xget.xi-xu.me/cr/gcr/...` |
|
||||
| 微软容器注册表 | `mcr` | `https://mcr.microsoft.com/...` | `https://xget.xi-xu.me/cr/mcr/...` |
|
||||
| 亚马逊公共弹性容器注册表 | `ecr` | `https://public.ecr.aws/...` | `https://xget.xi-xu.me/cr/ecr/...` |
|
||||
| GitHub 容器注册表 | `ghcr` | `https://ghcr.io/...` | `https://xget.xi-xu.me/cr/ghcr/...` |
|
||||
| GitLab 容器注册表 | `gitlab` | `https://registry.gitlab.com/...` | `https://xget.xi-xu.me/cr/gitlab/...` |
|
||||
| 红帽注册表 | `redhat` | `https://registry.redhat.io/...` | `https://xget.xi-xu.me/cr/redhat/...` |
|
||||
| 甲骨文容器注册表 | `oracle` | `https://container-registry.oracle.com/...` | `https://xget.xi-xu.me/cr/oracle/...` |
|
||||
| Cloudsmith | `cloudsmith` | `https://docker.cloudsmith.io/...` | `https://xget.xi-xu.me/cr/cloudsmith/...` |
|
||||
| DigitalOcean 注册表 | `digitalocean` | `https://registry.digitalocean.com/...` | `https://xget.xi-xu.me/cr/digitalocean/...` |
|
||||
| VMware 注册表 | `vmware` | `https://projects.registry.vmware.com/...` | `https://xget.xi-xu.me/cr/vmware/...` |
|
||||
| Kubernetes 注册表 | `k8s` | `https://registry.k8s.io/...` | `https://xget.xi-xu.me/cr/k8s/...` |
|
||||
| Heroku 注册表 | `heroku` | `https://registry.heroku.com/...` | `https://xget.xi-xu.me/cr/heroku/...` |
|
||||
| SUSE 注册表 | `suse` | `https://registry.suse.com/...` | `https://xget.xi-xu.me/cr/suse/...` |
|
||||
| openSUSE 注册表 | `opensuse` | `https://registry.opensuse.org/...` | `https://xget.xi-xu.me/cr/opensuse/...` |
|
||||
| Gitpod 注册表 | `gitpod` | `https://registry.gitpod.io/...` | `https://xget.xi-xu.me/cr/gitpod/...` |
|
||||
|
||||
```url
|
||||
# Docker Hub 原始 URL(官方镜像)
|
||||
https://registry-1.docker.io/v2/library/nginx/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/docker 前缀)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginx/manifests/latest
|
||||
|
||||
# Docker Hub 原始 URL(用户镜像)
|
||||
https://registry-1.docker.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/docker 前缀)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# GitHub 容器注册表原始 URL
|
||||
https://ghcr.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/ghcr 前缀)
|
||||
https://xget.xi-xu.me/cr/ghcr/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# 谷歌容器注册表原始 URL
|
||||
https://gcr.io/v2/distroless/base/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/gcr 前缀)
|
||||
https://xget.xi-xu.me/cr/gcr/v2/distroless/base/manifests/latest
|
||||
```
|
||||
|
||||
应用场景见[容器镜像加速](#容器镜像加速)。
|
||||
|
||||
#### AI 推理提供商
|
||||
|
||||
Xget 支持众多主流 AI 推理提供商的 API 加速,使用 `ip/[AI 推理提供商前缀]` 格式:
|
||||
@@ -709,58 +761,6 @@ https://xget.xi-xu.me/ip/huggingface/hf-inference/models/openai/whisper-large-v3
|
||||
|
||||
应用场景见 [AI 推理 API 加速](#ai-推理-api-加速)。
|
||||
|
||||
#### 容器注册表
|
||||
|
||||
Xget 支持多个容器注册表,使用 `cr/[容器注册表前缀]` 格式:
|
||||
|
||||
| 容器注册表 | 容器注册表前缀 | 原始 URL 格式 | 加速 URL 格式 |
|
||||
|----------|------|--------------|--------------|
|
||||
| Docker Hub | `docker` | `https://registry-1.docker.io/...` | `https://xget.xi-xu.me/cr/docker/...` |
|
||||
| Quay.io | `quay` | `https://quay.io/...` | `https://xget.xi-xu.me/cr/quay/...` |
|
||||
| 谷歌容器注册表 | `gcr` | `https://gcr.io/...` | `https://xget.xi-xu.me/cr/gcr/...` |
|
||||
| 微软容器注册表 | `mcr` | `https://mcr.microsoft.com/...` | `https://xget.xi-xu.me/cr/mcr/...` |
|
||||
| 亚马逊公共弹性容器注册表 | `ecr` | `https://public.ecr.aws/...` | `https://xget.xi-xu.me/cr/ecr/...` |
|
||||
| GitHub 容器注册表 | `ghcr` | `https://ghcr.io/...` | `https://xget.xi-xu.me/cr/ghcr/...` |
|
||||
| GitLab 容器注册表 | `gitlab` | `https://registry.gitlab.com/...` | `https://xget.xi-xu.me/cr/gitlab/...` |
|
||||
| 红帽注册表 | `redhat` | `https://registry.redhat.io/...` | `https://xget.xi-xu.me/cr/redhat/...` |
|
||||
| 甲骨文容器注册表 | `oracle` | `https://container-registry.oracle.com/...` | `https://xget.xi-xu.me/cr/oracle/...` |
|
||||
| Cloudsmith | `cloudsmith` | `https://docker.cloudsmith.io/...` | `https://xget.xi-xu.me/cr/cloudsmith/...` |
|
||||
| DigitalOcean 注册表 | `digitalocean` | `https://registry.digitalocean.com/...` | `https://xget.xi-xu.me/cr/digitalocean/...` |
|
||||
| VMware 注册表 | `vmware` | `https://projects.registry.vmware.com/...` | `https://xget.xi-xu.me/cr/vmware/...` |
|
||||
| Kubernetes 注册表 | `k8s` | `https://registry.k8s.io/...` | `https://xget.xi-xu.me/cr/k8s/...` |
|
||||
| Heroku 注册表 | `heroku` | `https://registry.heroku.com/...` | `https://xget.xi-xu.me/cr/heroku/...` |
|
||||
| SUSE 注册表 | `suse` | `https://registry.suse.com/...` | `https://xget.xi-xu.me/cr/suse/...` |
|
||||
| openSUSE 注册表 | `opensuse` | `https://registry.opensuse.org/...` | `https://xget.xi-xu.me/cr/opensuse/...` |
|
||||
| Gitpod 注册表 | `gitpod` | `https://registry.gitpod.io/...` | `https://xget.xi-xu.me/cr/gitpod/...` |
|
||||
|
||||
```url
|
||||
# Docker Hub 原始 URL(官方镜像)
|
||||
https://registry-1.docker.io/v2/library/nginx/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/docker 前缀)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginx/manifests/latest
|
||||
|
||||
# Docker Hub 原始 URL(用户镜像)
|
||||
https://registry-1.docker.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/docker 前缀)
|
||||
https://xget.xi-xu.me/cr/docker/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# GitHub 容器注册表原始 URL
|
||||
https://ghcr.io/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/ghcr 前缀)
|
||||
https://xget.xi-xu.me/cr/ghcr/v2/nginxinc/nginx-unprivileged/manifests/latest
|
||||
|
||||
# 谷歌容器注册表原始 URL
|
||||
https://gcr.io/v2/distroless/base/manifests/latest
|
||||
|
||||
# 转换后(添加 cr/gcr 前缀)
|
||||
https://xget.xi-xu.me/cr/gcr/v2/distroless/base/manifests/latest
|
||||
```
|
||||
|
||||
应用场景见[容器镜像加速](#容器镜像加速)。
|
||||
|
||||
## 🎯 应用场景
|
||||
|
||||
### Git 操作与配置
|
||||
@@ -1980,6 +1980,181 @@ pipeline {
|
||||
}
|
||||
```
|
||||
|
||||
### 容器镜像加速
|
||||
|
||||
#### Docker 配置
|
||||
|
||||
```bash
|
||||
# 配置 Docker 使用 Xget 镜像加速
|
||||
# 编辑 /etc/docker/daemon.json(Linux)或 ~/.docker/daemon.json(macOS/Windows)
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"https://xget.xi-xu.me/cr/ghcr"
|
||||
]
|
||||
}
|
||||
|
||||
# 重启 Docker 服务
|
||||
sudo systemctl restart docker # Linux
|
||||
# 或在 Docker Desktop 中重启服务
|
||||
|
||||
# 验证配置
|
||||
docker info | grep -A 10 "Registry Mirrors"
|
||||
```
|
||||
|
||||
#### 直接拉取镜像
|
||||
|
||||
```bash
|
||||
# 拉取 GitHub 容器注册表镜像
|
||||
docker pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
|
||||
# 拉取谷歌容器注册表镜像
|
||||
docker pull xget.xi-xu.me/cr/gcr/distroless/base:latest
|
||||
|
||||
# 拉取微软容器注册表镜像
|
||||
docker pull xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0
|
||||
```
|
||||
|
||||
#### Kubernetes 部署配置
|
||||
|
||||
```yaml
|
||||
# deployment.yaml - 使用 Xget 的镜像
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- name: redis
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
```
|
||||
|
||||
#### Docker Compose 配置
|
||||
|
||||
```yaml
|
||||
# docker-compose.yml - 使用 Xget 加速镜像
|
||||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./html:/usr/share/nginx/html
|
||||
|
||||
database:
|
||||
image: xget.xi-xu.me/cr/mcr/mssql/server:2022-latest
|
||||
environment:
|
||||
ACCEPT_EULA: Y
|
||||
SA_PASSWORD: "MyStrongPassword123!"
|
||||
volumes:
|
||||
- mssql_data:/var/opt/mssql
|
||||
|
||||
cache:
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
volumes:
|
||||
mssql_data:
|
||||
```
|
||||
|
||||
#### Dockerfile 优化
|
||||
|
||||
```dockerfile
|
||||
# 在 Dockerfile 中使用 Xget 加速基础镜像
|
||||
FROM xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# 生产阶段
|
||||
FROM xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# 使用微软容器注册表的 .NET 镜像
|
||||
FROM xget.xi-xu.me/cr/mcr/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/publish .
|
||||
ENTRYPOINT ["dotnet", "MyApp.dll"]
|
||||
```
|
||||
|
||||
#### CI/CD 集成
|
||||
|
||||
```yaml
|
||||
# GitHub Actions - 使用 Xget 加速容器构建
|
||||
name: Build and Deploy
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build with accelerated base images
|
||||
run: |
|
||||
# 构建时使用 Xget 的基础镜像
|
||||
docker build -t myapp:latest \
|
||||
--build-arg BASE_IMAGE=xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine .
|
||||
|
||||
- name: Test with accelerated images
|
||||
run: |
|
||||
# 使用加速镜像进行测试
|
||||
docker run --rm \
|
||||
xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0 \
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
#### Podman 配置
|
||||
|
||||
```bash
|
||||
# 配置 Podman 使用 Xget 镜像加速
|
||||
# 编辑 /etc/containers/registries.conf
|
||||
[[registry]]
|
||||
prefix = "ghcr.io"
|
||||
location = "xget.xi-xu.me/cr/ghcr"
|
||||
|
||||
# 或者直接拉取
|
||||
podman pull xget.xi-xu.me/cr/ghcr/alpine/alpine:latest
|
||||
podman pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
```
|
||||
|
||||
#### containerd 配置
|
||||
|
||||
```toml
|
||||
# 配置 containerd 使用 Xget
|
||||
# 编辑 /etc/containerd/config.toml
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/ghcr"]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/gcr"]
|
||||
```
|
||||
|
||||
```bash
|
||||
# 重启 containerd
|
||||
sudo systemctl restart containerd
|
||||
```
|
||||
|
||||
### AI 推理 API 加速
|
||||
|
||||
#### OpenAI API
|
||||
@@ -2182,184 +2357,11 @@ client = OpenAI(
|
||||
)
|
||||
```
|
||||
|
||||
### 容器镜像加速
|
||||
|
||||
#### Docker 配置
|
||||
|
||||
```bash
|
||||
# 配置 Docker 使用 Xget 镜像加速
|
||||
# 编辑 /etc/docker/daemon.json(Linux)或 ~/.docker/daemon.json(macOS/Windows)
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"https://xget.xi-xu.me/cr/ghcr"
|
||||
]
|
||||
}
|
||||
|
||||
# 重启 Docker 服务
|
||||
sudo systemctl restart docker # Linux
|
||||
# 或在 Docker Desktop 中重启服务
|
||||
|
||||
# 验证配置
|
||||
docker info | grep -A 10 "Registry Mirrors"
|
||||
```
|
||||
|
||||
#### 直接拉取镜像
|
||||
|
||||
```bash
|
||||
# 拉取 GitHub 容器注册表镜像
|
||||
docker pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
|
||||
# 拉取谷歌容器注册表镜像
|
||||
docker pull xget.xi-xu.me/cr/gcr/distroless/base:latest
|
||||
|
||||
# 拉取微软容器注册表镜像
|
||||
docker pull xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0
|
||||
```
|
||||
|
||||
#### Kubernetes 部署配置
|
||||
|
||||
```yaml
|
||||
# deployment.yaml - 使用 Xget 的镜像
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-deployment
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- name: redis
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
```
|
||||
|
||||
#### Docker Compose 配置
|
||||
|
||||
```yaml
|
||||
# docker-compose.yml - 使用 Xget 加速镜像
|
||||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
image: xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./html:/usr/share/nginx/html
|
||||
|
||||
database:
|
||||
image: xget.xi-xu.me/cr/mcr/mssql/server:2022-latest
|
||||
environment:
|
||||
ACCEPT_EULA: Y
|
||||
SA_PASSWORD: "MyStrongPassword123!"
|
||||
volumes:
|
||||
- mssql_data:/var/opt/mssql
|
||||
|
||||
cache:
|
||||
image: xget.xi-xu.me/cr/ghcr/bitnami/redis:alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
volumes:
|
||||
mssql_data:
|
||||
```
|
||||
|
||||
#### Dockerfile 优化
|
||||
|
||||
```dockerfile
|
||||
# 在 Dockerfile 中使用 Xget 加速基础镜像
|
||||
FROM xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# 生产阶段
|
||||
FROM xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# 使用微软容器注册表的 .NET 镜像
|
||||
FROM xget.xi-xu.me/cr/mcr/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/publish .
|
||||
ENTRYPOINT ["dotnet", "MyApp.dll"]
|
||||
```
|
||||
|
||||
#### CI/CD 集成
|
||||
|
||||
```yaml
|
||||
# GitHub Actions - 使用 Xget 加速容器构建
|
||||
name: Build and Deploy
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build with accelerated base images
|
||||
run: |
|
||||
# 构建时使用 Xget 的基础镜像
|
||||
docker build -t myapp:latest \
|
||||
--build-arg BASE_IMAGE=xget.xi-xu.me/cr/ghcr/nodejs/node:18-alpine .
|
||||
|
||||
- name: Test with accelerated images
|
||||
run: |
|
||||
# 使用加速镜像进行测试
|
||||
docker run --rm \
|
||||
xget.xi-xu.me/cr/mcr/dotnet/runtime:8.0 \
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
#### Podman 配置
|
||||
|
||||
```bash
|
||||
# 配置 Podman 使用 Xget 镜像加速
|
||||
# 编辑 /etc/containers/registries.conf
|
||||
[[registry]]
|
||||
prefix = "ghcr.io"
|
||||
location = "xget.xi-xu.me/cr/ghcr"
|
||||
|
||||
# 或者直接拉取
|
||||
podman pull xget.xi-xu.me/cr/ghcr/alpine/alpine:latest
|
||||
podman pull xget.xi-xu.me/cr/ghcr/nginxinc/nginx-unprivileged:latest
|
||||
```
|
||||
|
||||
#### containerd 配置
|
||||
|
||||
```toml
|
||||
# 配置 containerd 使用 Xget
|
||||
# 编辑 /etc/containerd/config.toml
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/ghcr"]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."gcr.io"]
|
||||
endpoint = ["https://xget.xi-xu.me/cr/gcr"]
|
||||
```
|
||||
|
||||
```bash
|
||||
# 重启 containerd
|
||||
sudo systemctl restart containerd
|
||||
```
|
||||
|
||||
## 🚀 部署
|
||||
|
||||
### 部署步骤
|
||||
### 部署到 Cloudflare Workers
|
||||
|
||||
#### 部署步骤
|
||||
|
||||
1. **fork 本存储库**:[Fork xixu-me/Xget](https://github.com/xixu-me/Xget/fork)
|
||||
|
||||
@@ -2385,7 +2387,7 @@ sudo systemctl restart containerd
|
||||
- Worker 域名:`your-worker-name.your-subdomain.workers.dev`
|
||||
- 自定义域名:`your-domain.com`(如果已绑定)
|
||||
|
||||
### 环境变量配置
|
||||
#### 环境变量配置
|
||||
|
||||
你可以在 Cloudflare Workers 控制台中设置以下环境变量来自定义配置:
|
||||
|
||||
@@ -2397,6 +2399,70 @@ sudo systemctl restart containerd
|
||||
- `ALLOWED_ORIGINS`:允许的 CORS 源(默认:*)
|
||||
- `MAX_PATH_LENGTH`:最大路径长度(默认:2048)
|
||||
|
||||
### 自托管部署
|
||||
|
||||
如果你希望在自己的服务器上运行 Xget,可以使用 Docker 部署:
|
||||
|
||||
#### 使用预构建镜像
|
||||
|
||||
从 GitHub Container Registry 拉取并运行预构建的镜像:
|
||||
|
||||
```bash
|
||||
# 拉取最新镜像
|
||||
docker pull ghcr.io/xixu-me/xget:latest
|
||||
|
||||
# 运行容器
|
||||
docker run -d \
|
||||
--name xget \
|
||||
-p 8080:8080 \
|
||||
ghcr.io/xixu-me/xget:latest
|
||||
```
|
||||
|
||||
#### 本地构建
|
||||
|
||||
从源码构建 Docker 镜像:
|
||||
|
||||
```bash
|
||||
# 克隆存储库
|
||||
git clone https://github.com/xixu-me/Xget.git
|
||||
cd Xget
|
||||
|
||||
# 构建镜像
|
||||
docker build -t xget:local .
|
||||
|
||||
# 运行容器
|
||||
docker run -d \
|
||||
--name xget \
|
||||
-p 8080:8080 \
|
||||
xget:local
|
||||
```
|
||||
|
||||
#### 使用 Docker Compose
|
||||
|
||||
创建 `docker-compose.yml` 文件:
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
xget:
|
||||
image: ghcr.io/xixu-me/xget:latest
|
||||
container_name: xget
|
||||
ports:
|
||||
- "8080:8080"
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
然后运行:
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
部署完成后,Xget 将在 `http://localhost:8080` 可用。
|
||||
|
||||
**注意**:自托管部署不包括 Cloudflare Workers 的全球边缘网络加速,性能取决于你的服务器配置和网络环境。
|
||||
|
||||
## 🔧 配置
|
||||
|
||||
### 配置参数
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using Workerd = import "/workerd/workerd.capnp";
|
||||
|
||||
const config :Workerd.Config = (
|
||||
services = [
|
||||
(name = "main", worker = .worker),
|
||||
],
|
||||
sockets = [
|
||||
(service = "main", name = "http", address = "*:8080", http = ()),
|
||||
],
|
||||
);
|
||||
|
||||
const worker :Workerd.Worker = (
|
||||
modules = [
|
||||
(name = "worker", esModule = embed "dist/index.js"),
|
||||
],
|
||||
# Match the compatibility_date in wrangler.toml
|
||||
compatibilityDate = "2024-10-22",
|
||||
# Enable Node.js compatibility to match wrangler.toml
|
||||
compatibilityFlags = ["nodejs_compat"],
|
||||
);
|
||||
Reference in new issue
Block a user