wip: oci image management

This commit is contained in:
loveuer
2025-11-09 15:19:11 +08:00
commit 8de8234372
58 changed files with 6142 additions and 0 deletions

93
README.md Normal file
View File

@@ -0,0 +1,93 @@
# Cluster - OCI Registry
A lightweight OCI (Open Container Initiative) registry implementation written in Go using Fiber v3.
## Features
- OCI Registry API v2 compliant
- Blob upload/download with chunked upload support
- Manifest handling (Docker and OCI formats)
- Tag management and catalog listing
- SQLite database for metadata storage
- File system storage for blobs and manifests
- RESTful API v1 for image management
## Architecture
- **main.go**: Application entry point
- **api/**: API route definitions
- **handler/**: HTTP request handlers
- **controller/**: Business logic controllers
- **internal/**: Internal packages (config, database, middleware, model, rerr, storage)
## Development
### Backend (Go)
```bash
# Build
go mod tidy
go build -o cluster .
# Run
./cluster -debug -address 0.0.0.0:8080 -data-dir ./x-storage
# Or use Makefile
make build
make run
```
### Frontend (React/TypeScript)
```bash
cd frontend
# Install dependencies (requires pnpm)
pnpm install
# Approve build scripts (required for esbuild)
pnpm approve-builds
# Development server
pnpm dev
# Build for production
pnpm run build
```
**Note**: This project uses `pnpm` as the package manager. Install it if needed:
```bash
npm install -g pnpm
# or
curl -fsSL https://get.pnpm.io/install.sh | sh -
```
## API Endpoints
### OCI Registry API v2
- `GET /v2/` - Version check
- `POST /v2/{repo}/blobs/uploads/` - Start blob upload
- `PATCH /v2/{repo}/blobs/uploads/{uuid}` - Upload blob chunk
- `PUT /v2/{repo}/blobs/uploads/{uuid}?digest={digest}` - Complete blob upload
- `GET /v2/{repo}/blobs/{digest}` - Get blob
- `HEAD /v2/{repo}/blobs/{digest}` - Check blob existence
- `PUT /v2/{repo}/manifests/{tag}` - Put manifest
- `GET /v2/{repo}/manifests/{tag}` - Get manifest
- `DELETE /v2/{repo}/manifests/{tag}` - Delete manifest
- `GET /v2/{repo}/tags/list` - List tags
- `GET /v2/_catalog` - List repositories
### API v1
- `GET /api/v1/registry/image/list` - List images
## Configuration
- `-debug`: Enable debug logging
- `-address`: Server address (default: 0.0.0.0:8080)
- `-data-dir`: Data directory for storage (default: ./x-storage)
## License
[Add your license here]