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
|
# Dependencies
|
||||||
node_modules
|
node_modules/
|
||||||
npm-debug.log*
|
npm-debug.log
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
|
|
||||||
# Testing
|
# Build outputs
|
||||||
coverage
|
dist/
|
||||||
.nyc_output
|
.wrangler/
|
||||||
test-results
|
wrangler-dist/
|
||||||
|
|
||||||
# Production build
|
# Tests
|
||||||
dist
|
test/
|
||||||
build
|
coverage/
|
||||||
|
*.test.js
|
||||||
|
|
||||||
# Environment variables
|
# Documentation
|
||||||
.env
|
*.md
|
||||||
.env.local
|
docs/
|
||||||
.env.development.local
|
.github/
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
|
|
||||||
# IDE and editor files
|
# Git
|
||||||
.vscode
|
.git/
|
||||||
.idea
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# OS generated files
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.DS_Store?
|
|
||||||
._*
|
|
||||||
.Spotlight-V100
|
|
||||||
.Trashes
|
|
||||||
ehthumbs.db
|
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
# Logs
|
# CI/CD
|
||||||
logs
|
.github/workflows/
|
||||||
|
|
||||||
|
# Config files not needed in build
|
||||||
|
.prettierrc
|
||||||
|
.prettierignore
|
||||||
|
.eslintrc*
|
||||||
|
tsconfig.json
|
||||||
|
vitest.config.js
|
||||||
|
|
||||||
|
# Misc
|
||||||
*.log
|
*.log
|
||||||
|
.env
|
||||||
# Git
|
.env.*
|
||||||
.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
|
|
||||||
@@ -13,6 +13,10 @@ on:
|
|||||||
- '.editorconfig'
|
- '.editorconfig'
|
||||||
- '.vscode/**'
|
- '.vscode/**'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
- '.prettierrc*'
|
||||||
|
- '.eslintrc*'
|
||||||
|
- '.github/ISSUE_TEMPLATE/**'
|
||||||
|
- '.github/PULL_REQUEST_TEMPLATE/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
+24
-60
@@ -4,28 +4,33 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- develop
|
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'docs/**'
|
- 'LICENSE'
|
||||||
- 'test/**'
|
|
||||||
- 'scripts/**'
|
|
||||||
- '.gitignore'
|
- '.gitignore'
|
||||||
- '.editorconfig'
|
- '.editorconfig'
|
||||||
- 'LICENSE'
|
- '.vscode/**'
|
||||||
|
- 'docs/**'
|
||||||
|
- '.prettierrc*'
|
||||||
|
- '.eslintrc*'
|
||||||
|
- '.github/ISSUE_TEMPLATE/**'
|
||||||
|
- '.github/PULL_REQUEST_TEMPLATE/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'docs/**'
|
- 'LICENSE'
|
||||||
- 'test/**'
|
|
||||||
- 'scripts/**'
|
|
||||||
- '.gitignore'
|
- '.gitignore'
|
||||||
- '.editorconfig'
|
- '.editorconfig'
|
||||||
- 'LICENSE'
|
- '.vscode/**'
|
||||||
|
- 'docs/**'
|
||||||
|
- '.prettierrc*'
|
||||||
|
- '.eslintrc*'
|
||||||
|
- '.github/ISSUE_TEMPLATE/**'
|
||||||
|
- '.github/PULL_REQUEST_TEMPLATE/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -35,30 +40,26 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
image-tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
image-digest: ${{ steps.build-and-push.outputs.digest }}
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
id-token: write
|
id-token: write
|
||||||
attestations: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Container Registry
|
- name: Log in to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -69,61 +70,24 @@ jobs:
|
|||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
type=sha,prefix={{branch}}-
|
type=sha
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
- name: Build and push image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
platforms: linux/amd64
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Generate artifact attestation
|
- name: Generate artifact attestation
|
||||||
uses: actions/attest-build-provenance@v3
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
with:
|
with:
|
||||||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
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
|
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
|
## 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)
|
## Technology Stack
|
||||||
- Intelligent caching with 30-minute default TTL
|
|
||||||
- Automatic retry mechanism (3 retries with linear backoff)
|
- **Runtime**: Cloudflare Workers (serverless edge computing)
|
||||||
- Enterprise-grade security headers
|
- **Language**: JavaScript (ES2022) with JSDoc type annotations
|
||||||
- HTTP/3 and multi-compression support
|
- **Testing**: Vitest with `@cloudflare/vitest-pool-workers`
|
||||||
- Special handling for Git, Docker, and AI inference protocols
|
- **Deployment**: Wrangler CLI + GitHub Actions
|
||||||
|
- **Code Quality**: ESLint + Prettier
|
||||||
|
- **Type Checking**: TypeScript via JSDoc (no build step)
|
||||||
|
|
||||||
## Development Commands
|
## 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)
|
# Testing
|
||||||
- `npm run test:run` - Run tests once without watch mode
|
npm test # Run Vitest in watch mode
|
||||||
- `npm run test:watch` - Run tests in watch mode
|
npm run test:run # Run tests once (CI mode)
|
||||||
- `npm run test:ui` - Run tests with Vitest UI
|
npm run test:coverage # Run tests with coverage report
|
||||||
- `npm run test:coverage` - Generate test coverage report (80% threshold for branches/functions/lines/statements)
|
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
|
# Deployment
|
||||||
- `npm run lint:fix` - Auto-fix ESLint issues
|
npm run deploy # Deploy to Cloudflare Workers
|
||||||
- `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
|
|
||||||
|
|
||||||
## Architecture
|
## 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
|
### 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
|
2. **Configuration** ([src/config/index.js](src/config/index.js))
|
||||||
- `isGitRequest()`, `isDockerRequest()`, `isAIInferenceRequest()` - Protocol detection functions
|
- `createConfig(env)` - runtime config with environment overrides
|
||||||
- `validateRequest()` - Security validation (method whitelist, path length limits)
|
- `CONFIG` object with defaults (cache TTL, timeouts, retries)
|
||||||
- `PerformanceMonitor` - Tracks request performance metrics
|
|
||||||
- Docker authentication handling ([src/index.js](src/index.js):219-266, 354-371, 579-634)
|
|
||||||
|
|
||||||
**[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)
|
### Request Flow
|
||||||
- `transformPath()` - Unified path transformation logic for all platforms
|
|
||||||
- Special transformations for crates.io, Homebrew, Jenkins
|
|
||||||
|
|
||||||
**[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
|
### Protocol Detection
|
||||||
- Default values: 30s timeout, 3 retries, 1800s cache, 2048 char max path length
|
|
||||||
|
|
||||||
### Platform Categories
|
The system handles different protocols with specialized logic:
|
||||||
|
|
||||||
1. **Code Repositories**: gh (GitHub), gl (GitLab), gitea, codeberg, sf (SourceForge), aosp
|
- **Git requests**: Via `/info/refs`, `/git-upload-pack` endpoints, User-Agent patterns
|
||||||
2. **Package Managers**: npm, pypi, conda, maven, gradle, nuget, crates, etc.
|
- **Git LFS**: LFS-specific headers and endpoints
|
||||||
3. **Container Registries**: cr-docker (Docker Hub), cr-ghcr, cr-gcr, cr-mcr, cr-quay, etc. (prefixed with `cr-`)
|
- **Docker/OCI registries**: `/v2/` prefix, Docker headers, token auth flow
|
||||||
4. **AI Inference Providers**: ip-openai, ip-anthropic, ip-gemini, etc. (prefixed with `ip-`)
|
- **AI inference**: `/ip/` prefix for AI API proxying
|
||||||
5. **Model/Dataset Platforms**: hf (Hugging Face), civitai
|
- **Regular downloads**: Default behavior with intelligent caching
|
||||||
6. **Linux Distributions**: debian, ubuntu, fedora, arch, etc.
|
|
||||||
|
|
||||||
### 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
|
- `Strict-Transport-Security` (HSTS)
|
||||||
- Allows POST method, sets Git-specific headers
|
- `X-Frame-Options: DENY`
|
||||||
- Skips caching to ensure real-time data
|
- `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}`)
|
- Method whitelist (GET/HEAD default, POST/PUT/PATCH for Git/Docker/AI)
|
||||||
- Detected via LFS headers (`Accept: application/vnd.git-lfs+json`) or User-Agent (`git-lfs/`)
|
- Path length limit (2048 characters)
|
||||||
- Supports batch API for efficient object transfers
|
- 30-second timeout protection
|
||||||
- Sets appropriate content-type headers for LFS operations
|
|
||||||
- Skips caching to ensure real-time data synchronization
|
|
||||||
|
|
||||||
**Docker/Container Registries** ([src/index.js](src/index.js):42-65)
|
### Caching Strategy
|
||||||
|
|
||||||
- Detected via `/v2/` paths, User-Agent, or Accept headers
|
- **Cache bypass**: Git, Git LFS, Docker, AI inference requests skip cache
|
||||||
- Handles Docker authentication flow with token fetching
|
- **Cache TTL**: 1800 seconds (30 minutes) default
|
||||||
- Supports anonymous access to public repositories
|
- **Range requests**: Full support for HTTP 206 partial content
|
||||||
- All requests must use `/cr/` prefix (e.g., `/cr/ghcr/owner/repo`)
|
- **Smart cache keys**: Different keys for Range vs full-content requests
|
||||||
- **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
|
|
||||||
|
|
||||||
**AI Inference APIs** ([src/index.js](src/index.js):110-146)
|
### Content Transformation
|
||||||
|
|
||||||
- Detected via `/ip/` paths or common AI endpoints
|
- **PyPI URLs**: Rewrites `files.pythonhosted.org` URLs in HTML responses
|
||||||
- Allows POST/PUT/PATCH methods
|
- **npm URLs**: Rewrites tarball URLs in JSON registry responses
|
||||||
- Sets JSON content-type and preserves all request headers
|
- **Streaming**: Uses `ReadableStream` for efficient large file handling
|
||||||
- Skips caching for real-time inference
|
|
||||||
|
|
||||||
**URL Rewriting** ([src/index.js](src/index.js):689-724)
|
## Testing
|
||||||
|
|
||||||
- PyPI: Rewrites `files.pythonhosted.org` URLs to go through `/pypi/files`
|
### Test Structure
|
||||||
- npm: Rewrites `registry.npmjs.org` tarball URLs to go through `/npm/`
|
|
||||||
|
|
||||||
## Testing Practices
|
Tests are organized by functionality in `test/`:
|
||||||
|
|
||||||
- Tests use Cloudflare Workers test environment via `@cloudflare/vitest-pool-workers`
|
- `index.test.js` - Core request handling
|
||||||
- Use `SELF.fetch()` to make requests to the worker in tests
|
- `integration.test.js` - End-to-end platform tests
|
||||||
- Test files are organized by functionality: platforms, security, integration, performance, range-cache
|
- `security.test.js` - Security headers and validation
|
||||||
- Fixtures in [test/fixtures/responses.js](test/fixtures/responses.js)
|
- `performance.test.js` - Performance monitoring
|
||||||
- Test utilities in [test/helpers/test-utils.js](test/helpers/test-utils.js)
|
- `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)
|
- Branches
|
||||||
- `MAX_RETRIES` - Max retry attempts (default: 3)
|
- Functions
|
||||||
- `RETRY_DELAY_MS` - Delay between retries (default: 1000)
|
- Lines
|
||||||
- `CACHE_DURATION` - Cache TTL in seconds (default: 1800)
|
- Statements
|
||||||
- `ALLOWED_METHODS` - Comma-separated HTTP methods (default: GET,HEAD)
|
|
||||||
- `MAX_PATH_LENGTH` - Maximum URL path length (default: 2048)
|
|
||||||
|
|
||||||
## 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)
|
# Run tests matching pattern
|
||||||
2. Add path transformation logic in `transformPath()` if needed (most platforms don't need special handling)
|
npm test -- --grep "Docker"
|
||||||
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)
|
|
||||||
|
|
||||||
## Security Considerations
|
# Run with coverage
|
||||||
|
npm run test:coverage
|
||||||
|
```
|
||||||
|
|
||||||
- All responses include strict security headers (HSTS, X-Frame-Options, CSP, etc.)
|
## Code Style
|
||||||
- HTTP method whitelist enforced (except for Git/Docker/AI operations)
|
|
||||||
- Path length validation to prevent excessively long URLs
|
- **JSDoc annotations**: All functions must have JSDoc type annotations
|
||||||
- 30-second request timeout to prevent resource exhaustion
|
- **ES modules**: Use `import/export`, not `require()`
|
||||||
- Input sanitization in URL transformations
|
- **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
|
# --- Stage 1: build the Worker with Wrangler -----------------------
|
||||||
FROM node:20-alpine
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json first to leverage Docker cache for dependencies
|
# Install dependencies & wrangler
|
||||||
COPY package.json package-lock.json* ./
|
COPY package*.json wrangler.toml ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
# Install dependencies - use npm ci for reproducible builds if package-lock.json exists, otherwise npm install
|
# Copy source and build
|
||||||
RUN if [ -f package-lock.json ]; then npm ci --only=production; else npm install --only=production; fi
|
COPY src ./src
|
||||||
|
RUN npx wrangler deploy --dry-run --outdir=dist
|
||||||
|
|
||||||
# Copy the rest of the application code
|
# --- Stage 2: minimal runtime with workerd -------------------------
|
||||||
COPY . .
|
FROM node:22-slim AS runtime
|
||||||
|
|
||||||
# Create a non-root user for security
|
# Install ca-certificates for SSL, then install workerd via npm
|
||||||
RUN addgroup -g 1001 -S nodejs && \
|
RUN apt-get update && \
|
||||||
adduser -S xget -u 1001
|
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
|
WORKDIR /worker
|
||||||
RUN chown -R xget:nodejs /app
|
|
||||||
|
|
||||||
# Switch to the non-root user
|
# Bring in the compiled Worker bundle and config
|
||||||
USER xget
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY config.capnp ./config.capnp
|
||||||
|
|
||||||
# Expose the port the app runs on
|
# Expose the port workerd listens on
|
||||||
EXPOSE 3000
|
EXPOSE 8080
|
||||||
|
|
||||||
# Set environment variables
|
CMD ["workerd", "serve", "config.capnp"]
|
||||||
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"]
|
|
||||||
+298
-232
@@ -46,10 +46,10 @@
|
|||||||
[](#arxiv-paper-download)
|
[](#arxiv-paper-download)
|
||||||
[](#f-droid-repository-mirror)
|
[](#f-droid-repository-mirror)
|
||||||
[](#jenkins-plugin-download)
|
[](#jenkins-plugin-download)
|
||||||
[](#ai-inference-providers)
|
|
||||||
[](#container-registries)
|
[](#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)***.
|
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/...` |
|
| arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` |
|
||||||
| F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` |
|
| 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/...` |
|
| 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) |
|
| 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
|
### 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
|
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
|
#### AI Inference Providers
|
||||||
|
|
||||||
Xget supports API acceleration for many mainstream AI inference providers, using the `ip/[AI Provider Prefix]` format:
|
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).
|
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
|
## 🎯 Use Cases
|
||||||
|
|
||||||
### Git Operations and Configuration
|
### 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
|
### AI Inference API Acceleration
|
||||||
|
|
||||||
#### OpenAI API
|
#### 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
|
||||||
|
|
||||||
### Deployment Steps
|
### Deploy to Cloudflare Workers
|
||||||
|
|
||||||
|
#### Deployment Steps
|
||||||
|
|
||||||
1. **Fork this repository**: [Fork xixu-me/Xget](https://github.com/xixu-me/Xget/fork)
|
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`
|
- Worker domain: `your-worker-name.your-subdomain.workers.dev`
|
||||||
- Custom domain: `your-domain.com` (if bound)
|
- 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:
|
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: *)
|
- `ALLOWED_ORIGINS`: Allowed CORS origins (default: *)
|
||||||
- `MAX_PATH_LENGTH`: Maximum path length (default: 2048)
|
- `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
|
||||||
|
|
||||||
### Configuration Parameters
|
### Configuration Parameters
|
||||||
|
|||||||
@@ -46,10 +46,10 @@
|
|||||||
[](#arxiv-论文下载)
|
[](#arxiv-论文下载)
|
||||||
[](#f-droid-存储库镜像)
|
[](#f-droid-存储库镜像)
|
||||||
[](#jenkins-插件下载)
|
[](#jenkins-插件下载)
|
||||||
[](#ai-推理提供商)
|
|
||||||
[](#容器注册表)
|
[](#容器注册表)
|
||||||
|
[](#ai-推理提供商)
|
||||||
|
|
||||||
面向开发者资源的超高性能、安全、一体化加速引擎,其性能显著优于传统解决方案,为代码存储库、软件包注册表、AI 推理 API、容器镜像、模型、数据集及更多资源提供统一且高效的加速。
|
面向开发者资源的超高性能、安全、一体化加速引擎,其性能显著优于传统解决方案,为代码存储库、模型和数据集中心、软件包注册表、容器注册表、AI 推理提供商等提供统一、高效的加速。
|
||||||
|
|
||||||
技术深度解析文章已发布:**[《深入剖析 Xget:一个高性能、多协议、高安全性的开发者资源加速引擎》](https://blog.xi-xu.me/2025/10/07/deep-dive-into-xget-technology.html)**。
|
技术深度解析文章已发布:**[《深入剖析 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/...` |
|
| arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` |
|
||||||
| F-Droid | `fdroid` | `https://f-droid.org/...` | `https://xget.xi-xu.me/fdroid/...` |
|
| 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/...` |
|
| Jenkins 插件 | `jenkins` | `https://updates.jenkins.io/...` | `https://xget.xi-xu.me/jenkins/...` |
|
||||||
| AI 推理提供商 | `ip` | 见 [AI 推理提供商](#ai-推理提供商) | 见 [AI 推理提供商](#ai-推理提供商) |
|
|
||||||
| 容器注册表 | `cr` | 见[容器注册表](#容器注册表) | 见[容器注册表](#容器注册表) |
|
| 容器注册表 | `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
|
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 推理提供商
|
#### AI 推理提供商
|
||||||
|
|
||||||
Xget 支持众多主流 AI 推理提供商的 API 加速,使用 `ip/[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-加速)。
|
应用场景见 [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 操作与配置
|
### 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 加速
|
### AI 推理 API 加速
|
||||||
|
|
||||||
#### OpenAI 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)
|
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`
|
- Worker 域名:`your-worker-name.your-subdomain.workers.dev`
|
||||||
- 自定义域名:`your-domain.com`(如果已绑定)
|
- 自定义域名:`your-domain.com`(如果已绑定)
|
||||||
|
|
||||||
### 环境变量配置
|
#### 环境变量配置
|
||||||
|
|
||||||
你可以在 Cloudflare Workers 控制台中设置以下环境变量来自定义配置:
|
你可以在 Cloudflare Workers 控制台中设置以下环境变量来自定义配置:
|
||||||
|
|
||||||
@@ -2397,6 +2399,70 @@ sudo systemctl restart containerd
|
|||||||
- `ALLOWED_ORIGINS`:允许的 CORS 源(默认:*)
|
- `ALLOWED_ORIGINS`:允许的 CORS 源(默认:*)
|
||||||
- `MAX_PATH_LENGTH`:最大路径长度(默认:2048)
|
- `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