center.gf

command module
v0.2.8-beta17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 11 Imported by: 0

README

center.gf 私有云仓库

介绍

使用goframe框架实现 maven/golang/flutter/npm/docker 等中央仓库功能。

部署服务器我们推荐使用*nix服务器系列(包括:Linux, MacOS, *BSD),以下说明文档以Ubuntu系统为例。

软件架构

  • 使用golang开发语言开发,服务端使用goframe框架
  • 数据库使用了sqlite本地数据库,用于存储系统配置文件等相关信息
  • 系统采用了前后端分离开发,前端开发语言为vue

内置功能

中央仓库功能实现
  • [实现中] 1.支持maven私有仓库功能
  • [实现中] 2.支持golang私有仓库功能
  • 3.支持npm私有仓库功能
  • 4.支持flutter私有仓库功能
  • 5.支持docker私有仓库功能
  • [已实现] 6.支持数据通过websocket实时推到前端
  • 7.支持可动态配置并存储服务的配置信息
  • [已实现] 8.支持中央仓库数据缓存
  • [已实现] 9.自定义常用指令实现
1.支持maven私有仓库功能
  • 支持使用mvn指令:

    • 初始化: mvn help:system
    • 编译: mvn compile
    • 清理: mvn clean
    • 测试: mvn test
    • 打包: mvn package
    • 安装到repository: mvn install (具有编译和打包的功能)
    • 部署到tomcat: mvn deploy
  • 支持配置public仓库,并对鉴权控制

  • 支持配置私有仓库,并对鉴权控制

  • 支持部署服务中,如本地缓存存在资源时则直接返回,如不存在时则获取互联网maven仓库资源,并将数据缓存一份到本地缓存

2.支持golang私有仓库功能
  • 支持使用go指令:
    • go mod tidy
    • go mod install
  • 支持私有仓库,并对鉴权控制
  • 支持部署服务中,如本地缓存存在资源时则直接返回,如不存在时则获取互联网maven仓库资源,并将数据缓存一份到本地缓存
3.支持npm私有仓库功能

功能验证完善中...

4.支持flutter私有仓库功能

功能验证完善中...

5.支持docker私有仓库功能

功能验证完善中...

6.支持数据通过websocket实时推到前端
  • 支持将服务消息通过websocket推送到前端
  • 支持推送:服务器状态消息,如CPU,内存,(内外网)请求流量,缓存文件数量,缓存文件存储大小
  • 支持推送:代理仓库各子仓库系统文件存储数量,大小,(内外网)请求流量
  • 支持推送:每次服务请求的请求操作行为
  • 支持推送:获取服务端websocket信息
7.支持可动态配置并存储服务的配置信息
  • 支持将配置信息初始化到sqlite本地数据库中
  • 支持通过调用接口修改,同步响应更新配置信息
8.中央仓库数据缓存

实现通过配置文件将私有仓库请求的依赖缓存文件

  • 支持缓存文件到tencentCos
  • 支持缓存文件到自荐minio
  • 支持缓存文件到本地文件夹中
  • [待实现]支持缓存文件到aliyunCos
  • 数据缓存配置文件参数标识:本地embedFs/持久化nutsdb/本地Cos服务minioCos/七牛Cos服务qiniuCos/腾讯Cos服务tencentCos
9.自定义常用指令实现
- 完成情况 - - 指令 - - 描述 -
[x] ./center version 查看系统环境变量
实现中 ./center ctl
实现中 ./center ctl pack 系统配置初始化文件
实现中 ./center ctl reset 系统操作配置重置
[x] ./center service
[x] ./center service install 安装开机启动服务
[x] ./center service uninstall 卸载开机启动服务
[x] ./center service restart 重启服务
[x] ./center service stop 启动服务
[x] ./center service start 停止服务
[x] ./center service status 服务状态
前端功能页面
  • 前后端分离开发
代理仓库服务config.yaml配置文件描述
database:
  default:
    ## sqlite数据库在开发模式下可以使用相对路径,相对路径由项目路径开始(程序部署默认将配置文件放到了./config下)
    link: "sqlite::@file(config/center.sqlite3)"
    debug: true
服务部署后-代理仓库服务使用用法
Maven代理仓库
步骤一:修改maven配置修改

参数描述:

  • id 建议为配置文件下repository节点id值
  • username 建议为配置文件下authUser节点对应的用户名称
  • password 建议为配置文件下authUser节点对应的用户密码
<!-- 这里是需要上传的账号密码 -->
<servers>
    <server>
        <!--建议为配置文件下repository节点的名称 -->
        <id>private</id>
        <!--建议为配置文件下authUser节点对应的用户名称 -->
        <username>admin</username>
        <!--建议为配置文件下authUser节点对应的用户密码 -->
        <password>password</password>
    </server>
</servers>
步骤二:代理服务仓库修改

参数描述:

  • id 建议为配置文件下repository节点id值
  • name 建议为配置文件下repository节点name值
  • url 为当前服务ip:port/maven/public

<mirrors>
    <mirror>
        <id>public</id>
        <name>public repository</name>
        <url>http://localhost:10010/proxy/maven/public</url>
        <mirrorOf>publicCentral</mirrorOf>
    </mirror>
    <mirror>
        <id>private</id>
        <name>private repository</name>
        <url>http://localhost:10010/proxy/maven/private</url>
        <mirrorOf>privateCentral</mirrorOf>
    </mirror>
</mirrors>
步骤三:springboot工程项目中pom.xml文件修改

<project>
    <distributionManagement>
        <repository>
            <id>public</id>
            <name>public repository</name>
            <url>http://localhost:10010/proxy/maven/public</url>
        </repository>
        <snapshotRepository>
            <id>private</id>
            <name>private repository</name>
            <url>http://localhost:10010/proxy/maven/private</url>
        </snapshotRepository>
    </distributionManagement>
    <profiles>
        <profile>
            <id>public</id>
            <repositories>
                <repository>
                    <id>public</id>
                    <url>http://localhost:10010/proxy/maven/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>private</id>
                    <url>http://localhost:10010/proxy/maven/private</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
</project>
gradle 配置指南
  • 在 build.gradle 文件中加入以下代码:
allprojects {
  repositories {
    maven {
      url 'http://localhost:10010/proxy/maven/public'
    }
    mavenLocal()
    mavenCentral()
  }
}
  • 如果想使用其它代理仓,以使用spring仓为例,代码如下:
allprojects {
  repositories {
    maven {
      url 'http://localhost:10010/proxy/maven/public'
    }
    maven {
      url 'https://maven.aliyun.com/repository/spring/'
    }
    mavenLocal()
    mavenCentral()
  }
}
  • 加入你要引用的文件信息:
dependencies {
  compile '[GROUP_ID]:[ARTIFACT_ID]:[VERSION]'
}
  • 执行命令:gradle dependencies 或 ./gradlew dependencies安装依赖
golang代理仓库
golang代理仓库使用用法

使用说明:只支持Go 1.13 及以上

(推荐)打开你的终端并执行
go env -w GO111MODULE=on
go env -w GOPROXY=http://127.0.0.1:10010/proxy/golang,direct
macOS 或 Linux
go env -w GO111MODULE=on
go env -w GOPROXY=http://127.0.0.1:10010/proxy/golang,direct
Windows
  • 打开你的终端并执行
C:\> $env:GO111MODULE = "on"
C:\> $env:GOPROXY = "http://127.0.0.1:10010/proxy/golang,direct"
  • 或者
1. 打开“开始”并搜索“env”
2. 选择“编辑系统环境变量”
3. 点击“环境变量…”按钮
4. 在“<你的用户名> 的用户变量”章节下(上半部分)
5. 点击“新建…”按钮
6. 选择“变量名”输入框并输入“GO111MODULE”
7. 选择“变量值”输入框并输入“on”
8. 点击“确定”按钮
9. 点击“新建…”按钮
10. 选择“变量名”输入框并输入“GOPROXY”
11. 选择“变量值”输入框并输入"http://127.0.0.1:10010/proxy/golang,direct"
12. 点击“确定”按钮
npm代理仓库
方法一:清修改镜像源
  • 清除工程原镜像源 npm config rm registry
  • 添加新的nexus镜像源 npm config set registry=http://127.0.0.1:10010/proxy/npm
  • 删除原始缓存 手动删除 node_modules
  • 重新构建
    • npm update
    • npm install
  • 查看是否已使用最新的私有仓库(如果打印的是设置的registry就是成功了)
    • npm get registry (或 npm config ls
  • 其他途径验证是否是私有仓库
    • 点击 package-lock.json ---->查看 resolved 字段的值是不是 http://127.0.0.1:10010/proxy/npm
    • 如果是,就是对的
方法二:项目根目录下配置.npmrc文件

注意:这种方法配置更简单,还不用更改原电脑的npm镜像源,它会优先拉取私有仓库的依赖,没有的才根据自己电脑的npm镜像源拉取依赖

部署运行方式

服务器我们推荐使用*nix服务器系列(包括:Linux, MacOS, *BSD)

  • 1.支持使用Docker部署
  • 2.支持自编译docker部署
  • 3.支持独立部署服务

项目开发使用Go版本为: go version go1.18.8 linux/amd64

服务部署说明

本服务支持独立部署与容器部署两种方式

(推荐)支持使用Docker部署
#docker 仓库还在部署中
docker pull xxx/center:latest
#
docker run -d --name center-test \
  -v $PWD/apps/config/config.yaml:/apps/config/config.yaml \
  -v $PWD/apps/config/center.sqlite3:/apps/config/center.sqlite3 \
  -v $PWD/apps:/apps \
  --restart always \
  -p 10010:10010 \
  xxx/center:latest
  
支持自编译docker部署
  • git下载源码 https://gitee.com/linngc/center.gf.git
  • 加载依赖命令 go mod tidy
  • 手动编译命令 gf build
  • 编译golang二进制文件后,再进入 center.gf/manifest/docker
  • 默认使用linux_amd64 编译后的二进制文件(默认编译成功后文件夹下会创建dist目录)
  • 执行docker容器编译 :docker build -f Dockerfile -t center:alpine ./
  • 运行docker容器: docker run center:alpine
  • 登录web端,配置 系统默认参数 信息项
  • 设置对应的代理仓库操作,方可使用
独立部署服务
  • git下载源码 https://gitee.com/linngc/center.gf.git
  • 编译golang二进制文件后,再进入 center.gf/manifest/docker/dist 拷贝对应系统版本的二进制文件(默认编译成功后文件夹下会创建dist目录)
  • 将二进制文件和 ./config 文件放在同一个目录下
  • 再执行启动 ./center --gf.gcfg.path=./config
  • 登录web端,配置 系统默认参数 信息项
  • 设置对应的代理仓库操作,方可使用
演示图

略略略略

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
功能参考
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Overview

Package main @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License

Directories

Path Synopsis
api
v1
Package v1 @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package v1 @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
v1/business/home
Package home @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package home @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
v1/business/xproxy
Package xproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package xproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
v1/platform/admin
Package admin @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package admin @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
v1/platform/common
Package common @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package common @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
v1/platform/system
Package system @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package system @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
v1/websocket
Package websocket @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @title 操作行为:如登录,请求get等 @License
Package websocket @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @title 操作行为:如登录,请求get等 @License
contrib
module/cacher Module
plugins/speed Module
xproxy/cacher Module
internal
cmd
Package cmd @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package cmd @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
cmd/boot
Package boot @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @title 用于初始化应用数据
Package boot @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @title 用于初始化应用数据
cmd/hook
Package hook @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @title 服务加载之前
Package hook @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @title 服务加载之前
cmd/router
Package router @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @Title 路由配置
Package router @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @Title 路由配置
cmd/scheduled
Package scheduled @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @title 定时任务
Package scheduled @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License @title 定时任务
consts
Package consts @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package consts @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
controller
Package controller @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package controller @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
controller/business/home
Package home @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package home @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
controller/business/xproxy
Package xproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package xproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
controller/platform/admin
Package admin @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package admin @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
controller/platform/common
Package common @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package common @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
controller/websocket
Package websocket @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @title 操作行为:如登录,请求get等 @License
Package websocket @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @title 操作行为:如登录,请求get等 @License
logic
Package logic @Link https://gitee.com/center/center.gf @Copyright Copyright (c) 2022 center CLI @Author cheng.li @License
Package logic @Link https://gitee.com/center/center.gf @Copyright Copyright (c) 2022 center CLI @Author cheng.li @License
logic/business
Package business @Link https://gitee.com/center/center.gf @Copyright Copyright (c) 2022 center CLI @Author cheng.li @License
Package business @Link https://gitee.com/center/center.gf @Copyright Copyright (c) 2022 center CLI @Author cheng.li @License
logic/middleware
Package middleware @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package middleware @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
logic/platform/admin
Package admin @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package admin @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
logic/platform/system
Package system @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package system @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
model/vo/business/system
Package system @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package system @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
model/vo/middleware
Package middleware @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package middleware @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
model/vo/platform/system
Package system @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package system @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
model/vo/websocket
Package websocket @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @title 操作行为:如登录,请求get等 @License
Package websocket @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @title 操作行为:如登录,请求get等 @License
packed
Package packed @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package packed @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
service/middleware
Package middleware @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package middleware @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
service/platform/admin
Package admin @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package admin @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
service/platform/system
Package system @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package system @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
utility
frame/response
Package response @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package response @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
ldflags
Package ldflags @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package ldflags @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
tools/env
Package env @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package env @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
tools/http
Package http @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
Package http @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License
tools/tree
Package tree @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License
Package tree @Link https://gitee.com/linngc/webos.gf @Copyright Copyright (c) 2022 webos CLI @Author linngc @License

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL