feat: complete OCI registry implementation with docker push/pull support

A lightweight OCI (Open Container Initiative) registry implementation written in Go.
This commit is contained in:
loveuer
2025-11-09 22:46:27 +08:00
commit 29088a6b54
45 changed files with 5629 additions and 0 deletions

70
internal/model/model.go Normal file
View File

@@ -0,0 +1,70 @@
package model
import (
"time"
"gorm.io/gorm"
)
// Repository ????
type Repository struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Name string `gorm:"uniqueIndex;not null" json:"name"` // ?????? "library/nginx"
}
// Blob blob ??
type Blob struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Digest string `gorm:"uniqueIndex;not null" json:"digest"` // SHA256 digest
Size int64 `gorm:"not null" json:"size"` // ??????
MediaType string `json:"media_type"` // ????
Repository string `gorm:"index" json:"repository"` // ???????????????
}
// Manifest manifest ??
type Manifest struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Repository string `gorm:"index;not null" json:"repository"` // ????
Tag string `gorm:"index;not null" json:"tag"` // tag ??
Digest string `gorm:"uniqueIndex;not null" json:"digest"` // manifest digest
MediaType string `json:"media_type"` // ????
Size int64 `gorm:"not null" json:"size"` // manifest ??
Content []byte `gorm:"type:blob" json:"-"` // manifest ???JSON?
}
// Tag tag ??????????
type Tag struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Repository string `gorm:"index;not null" json:"repository"` // ????
Tag string `gorm:"index;not null" json:"tag"` // tag ??
Digest string `gorm:"not null" json:"digest"` // ??? manifest digest
}
// BlobUpload ????? blob ??
type BlobUpload struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
UUID string `gorm:"uniqueIndex;not null" json:"uuid"` // ???? UUID
Repository string `gorm:"index;not null" json:"repository"` // ????
Path string `gorm:"not null" json:"path"` // ??????
Size int64 `gorm:"default:0" json:"size"` // ?????
}