feat: as docker mirror registry
feat: add global proxy config upgrade: upgrade front(angular) to 19 chore: deployment staff 1. Dockerfile: build frontend, backend, and run in nginx base image
This commit is contained in:
@ -6,16 +6,18 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/samber/lo"
|
||||
"github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"nf-repo/internal/interfaces"
|
||||
"nf-repo/internal/model"
|
||||
"nf-repo/internal/util/rerr"
|
||||
"nf-repo/internal/util/tools"
|
||||
"nf-repo/internal/tool/rerr"
|
||||
"nf-repo/internal/tool/tools"
|
||||
|
||||
"github.com/loveuer/nf/nft/log"
|
||||
"github.com/samber/lo"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
type pm struct {
|
||||
@ -56,7 +58,7 @@ func (m *dbManifests) Get(ctx context.Context, repo string, target string) (io.R
|
||||
return io.NopCloser(bytes.NewReader(pd.Content)), pd.ContentType, nil
|
||||
}
|
||||
|
||||
var pm = new(model.PackageManifest)
|
||||
pm := new(model.PackageManifest)
|
||||
|
||||
if err = m.db.TX(tools.Timeout(5)).
|
||||
Model(&model.PackageManifest{}).
|
||||
@ -80,11 +82,7 @@ func (m *dbManifests) Get(ctx context.Context, repo string, target string) (io.R
|
||||
Where("id", pm.DigestId).
|
||||
Take(pd).
|
||||
Error; err != nil {
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Get").
|
||||
WithField("digest", pm.DigestId).
|
||||
WithField("err", err.Error()).
|
||||
Error()
|
||||
log.Error("dbManifests: get err, digest = %s, err = %s", pm.Digest, err.Error())
|
||||
return nil, "", rerr.ErrInternal(err)
|
||||
}
|
||||
|
||||
@ -92,7 +90,6 @@ func (m *dbManifests) Get(ctx context.Context, repo string, target string) (io.R
|
||||
}
|
||||
|
||||
func (m *dbManifests) Put(ctx context.Context, repo string, tag string, digest string, mf *model.RepoSimpleManifest) *rerr.RepositoryError {
|
||||
|
||||
var (
|
||||
err error
|
||||
pm = &model.PackageManifest{
|
||||
@ -132,13 +129,11 @@ func (m *dbManifests) Put(ctx context.Context, repo string, tag string, digest s
|
||||
Column: clause.Column{Name: "size"},
|
||||
Value: pd.Size,
|
||||
},
|
||||
}}).
|
||||
},
|
||||
}).
|
||||
Create(pd).
|
||||
Error; err != nil {
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Put.Create").
|
||||
WithField("err", err.Error()).
|
||||
Error()
|
||||
log.Error("dbManifests: put create err, err = %s", err.Error())
|
||||
return rerr.ErrInternal(err)
|
||||
}
|
||||
|
||||
@ -156,10 +151,7 @@ func (m *dbManifests) Put(ctx context.Context, repo string, tag string, digest s
|
||||
"digest_id": pm.DigestId,
|
||||
}).
|
||||
Error; err != nil {
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Put.Updates").
|
||||
WithField("err", err.Error()).
|
||||
Debug()
|
||||
log.Debug("dbManifests: put updates err, err = %s", err.Error())
|
||||
return rerr.ErrInternal(err)
|
||||
}
|
||||
|
||||
@ -167,9 +159,7 @@ func (m *dbManifests) Put(ctx context.Context, repo string, tag string, digest s
|
||||
}
|
||||
|
||||
func (m *dbManifests) Delete(ctx context.Context, repo string, target string) *rerr.RepositoryError {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
var err error
|
||||
|
||||
if err = m.db.TX(tools.Timeout(5)).
|
||||
Where("repo", repo).
|
||||
@ -286,12 +276,7 @@ func (m *dbManifests) Referrers(ctx context.Context, repo string, target string)
|
||||
}
|
||||
}
|
||||
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Referrers.Take").
|
||||
WithField("repo", repo).
|
||||
WithField("target", target).
|
||||
WithField("err", err.Error()).
|
||||
Debug()
|
||||
log.Debug("dbManifests: referrers take err, repo = %s, target = %s, err = %s", repo, target, err.Error())
|
||||
|
||||
return nil, rerr.ErrInternal(err)
|
||||
}
|
||||
@ -309,11 +294,7 @@ func (m *dbManifests) Referrers(ctx context.Context, repo string, target string)
|
||||
}
|
||||
}
|
||||
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Referrers.Take").
|
||||
WithField("repo", repo).
|
||||
WithField("target", target).
|
||||
Error()
|
||||
log.Error("dbManifests: referrers take err, repo = %s, target = %s, err = %s", repo, target, err.Error())
|
||||
|
||||
return nil, rerr.ErrInternal(err)
|
||||
}
|
||||
@ -323,23 +304,14 @@ func (m *dbManifests) Referrers(ctx context.Context, repo string, target string)
|
||||
Take(pd).
|
||||
Error; err != nil {
|
||||
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Referrers.Take").
|
||||
WithField("repo", repo).
|
||||
WithField("target", target).
|
||||
Error()
|
||||
log.Error("dbManifests: referrers take err, repo = %s, target = %s, err = %s", repo, target, err.Error())
|
||||
|
||||
return nil, rerr.ErrInternal(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(pd.Content, manifest); err != nil {
|
||||
logrus.
|
||||
WithField("path", "dbManifests.Referrers.Unmarshal").
|
||||
WithField("repo", repo).
|
||||
WithField("target", target).
|
||||
WithField("err", err.Error()).
|
||||
Debug()
|
||||
log.Debug("dbManifests: referrers unmarshal err, repo %s, target = %s, err = %s", repo, target, err.Error())
|
||||
return nil, rerr.ErrInternal(err)
|
||||
}
|
||||
|
||||
@ -347,18 +319,13 @@ func (m *dbManifests) Referrers(ctx context.Context, repo string, target string)
|
||||
}
|
||||
|
||||
func NewManifestDBHandler(tx interfaces.Database) interfaces.ManifestHandler {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
var err error
|
||||
|
||||
if err = tx.TX(tools.Timeout(5)).AutoMigrate(
|
||||
&model.PackageManifest{},
|
||||
&model.PackageDigest{},
|
||||
); err != nil {
|
||||
logrus.
|
||||
WithField("path", "NewManifestDBHandler").
|
||||
WithField("method", "AutoMigrate").
|
||||
Panic(err)
|
||||
log.Panic("NewManifestDBHandler: db auto_migrate failed, err = %s", err.Error())
|
||||
}
|
||||
|
||||
return &dbManifests{db: tx}
|
||||
|
@ -5,16 +5,18 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
"nf-repo/internal/interfaces"
|
||||
"nf-repo/internal/model"
|
||||
"nf-repo/internal/model/types"
|
||||
"nf-repo/internal/util/rerr"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"nf-repo/internal/interfaces"
|
||||
"nf-repo/internal/model"
|
||||
"nf-repo/internal/model/types"
|
||||
"nf-repo/internal/tool/rerr"
|
||||
|
||||
"github.com/loveuer/nf/nft/log"
|
||||
)
|
||||
|
||||
type memManifest struct {
|
||||
@ -203,7 +205,7 @@ func (m *memManifest) Put(ctx context.Context, repo string, target string, diges
|
||||
}
|
||||
} else {
|
||||
// TODO: Probably want to do an existence check for blobs.
|
||||
logrus.Warnf("TODO: Check blobs for %q", desc.Digest)
|
||||
log.Warn("TODO: Check blobs for %q", desc.Digest)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user