Skip to content

Commit

Permalink
Merge pull request #226 from SonicCloudOrg/dev
Browse files Browse the repository at this point in the history
rcReady
  • Loading branch information
ZhouYixun authored Jun 29, 2022
2 parents 961bc78 + 52ccdc0 commit 4446325
Show file tree
Hide file tree
Showing 32 changed files with 597 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
##################
# Service Config #
##################
SERVER_HOST=192.168.1.1
SERVER_PORT=3000
SONIC_SERVER_HOST=192.168.1.1
SONIC_SERVER_PORT=3000
SONIC_EUREKA_USERNAME=sonic
SONIC_EUREKA_PASSWORD=sonic
SONIC_EUREKA_PORT=9090
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- name: git Actions
uses: srt32/[email protected]
- name: get agent
run: git clone https://github.com/SonicCloudOrg/sonic-agent.git && cd sonic-agent && mvn package -Plinux-x86_64 && docker build -t sonicorg/sonic-agent-linux:v1.4.1-beta -f src/main/docker/Dockerfile .
run: git clone https://github.com/SonicCloudOrg/sonic-agent.git && cd sonic-agent && mvn package -Plinux-x86_64 && docker build -t sonicorg/sonic-agent-linux:v1.4.1-rc -f src/main/docker/Dockerfile .
- name: push
run: docker push sonicorg/sonic-agent-linux:v1.4.1-beta
run: docker push sonicorg/sonic-agent-linux:v1.4.1-rc
- name: login docker hub
run: echo "${{ secrets.ACCESS_TOKEN_ALIYUN }}" | docker login --username=小虫哔哔 registry.cn-hangzhou.aliyuncs.com --password-stdin
- name: tag
run: docker tag sonicorg/sonic-agent-linux:v1.4.1-beta registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-beta
run: docker tag sonicorg/sonic-agent-linux:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-rc
- name: push
run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-beta
run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-rc
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
- name: login docker hub
run: echo "${{ secrets.ACCESS_TOKEN_ALIYUN }}" | docker login --username=小虫哔哔 registry.cn-hangzhou.aliyuncs.com --password-stdin
- name: tag
run: docker tag sonicorg/sonic-server-eureka:v1.4.1-beta registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-beta && docker tag sonicorg/sonic-server-controller:v1.4.1-beta registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-beta && docker tag sonicorg/sonic-server-folder:v1.4.1-beta registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-beta && docker tag sonicorg/sonic-server-gateway:v1.4.1-beta registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-beta
run: docker tag sonicorg/sonic-server-eureka:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-rc && docker tag sonicorg/sonic-server-controller:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-rc && docker tag sonicorg/sonic-server-folder:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-rc && docker tag sonicorg/sonic-server-gateway:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-rc
- name: push
run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-beta && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-beta && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-beta && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-beta
run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-rc && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-rc && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-rc && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-rc
24 changes: 12 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
sonic-server-eureka:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-beta"
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-rc"
hostname: sonic-server-eureka
environment:
- SONIC_EUREKA_USERNAME
Expand All @@ -15,7 +15,7 @@ services:
ports:
- "${SONIC_EUREKA_PORT}:${SONIC_EUREKA_PORT}"
sonic-server-gateway:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-beta"
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-rc"
hostname: sonic-server-gateway
environment:
- SONIC_EUREKA_USERNAME
Expand All @@ -32,7 +32,7 @@ services:
- sonic-network
restart: on-failure
sonic-server-controller:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-beta"
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-rc"
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
Expand All @@ -43,8 +43,8 @@ services:
- MYSQL_DATABASE
- MYSQL_USERNAME
- MYSQL_PASSWORD
- SERVER_HOST
- SERVER_PORT
- SONIC_SERVER_HOST
- SONIC_SERVER_PORT
- SECRET_KEY
- EXPIRE_DAY
- REGISTER_ENABLE
Expand All @@ -64,14 +64,14 @@ services:
- sonic-server-eureka
restart: on-failure
sonic-server-folder:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-beta"
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-rc"
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
- SONIC_EUREKA_HOST=sonic-server-eureka
- SONIC_EUREKA_PORT
- SERVER_HOST
- SERVER_PORT
- SONIC_SERVER_HOST
- SONIC_SERVER_PORT
- SECRET_KEY
- EXPIRE_DAY
networks:
Expand All @@ -86,17 +86,17 @@ services:
- sonic-server-eureka
restart: on-failure
sonic-client-web:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-client-web:v1.4.1-beta"
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-client-web:v1.4.1-rc"
environment:
- SERVER_HOST
- SERVER_PORT
- SONIC_SERVER_HOST
- SONIC_SERVER_PORT
networks:
- sonic-network
depends_on:
- sonic-server-gateway
restart: on-failure
ports:
- "${SERVER_PORT}:80"
- "${SONIC_SERVER_PORT}:80"

networks:
sonic-network:
Expand Down
24 changes: 12 additions & 12 deletions docker-compose2.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
sonic-server-eureka:
image: "sonicorg/sonic-server-eureka:v1.4.1-beta"
image: "sonicorg/sonic-server-eureka:v1.4.1-rc"
hostname: sonic-server-eureka
environment:
- SONIC_EUREKA_USERNAME
Expand All @@ -15,7 +15,7 @@ services:
ports:
- "${SONIC_EUREKA_PORT}:${SONIC_EUREKA_PORT}"
sonic-server-gateway:
image: "sonicorg/sonic-server-gateway:v1.4.1-beta"
image: "sonicorg/sonic-server-gateway:v1.4.1-rc"
hostname: sonic-server-gateway
environment:
- SONIC_EUREKA_USERNAME
Expand All @@ -32,7 +32,7 @@ services:
- sonic-network
restart: on-failure
sonic-server-controller:
image: "sonicorg/sonic-server-controller:v1.4.1-beta"
image: "sonicorg/sonic-server-controller:v1.4.1-rc"
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
Expand All @@ -43,8 +43,8 @@ services:
- MYSQL_DATABASE
- MYSQL_USERNAME
- MYSQL_PASSWORD
- SERVER_HOST
- SERVER_PORT
- SONIC_SERVER_HOST
- SONIC_SERVER_PORT
- SECRET_KEY
- EXPIRE_DAY
- REGISTER_ENABLE
Expand All @@ -64,14 +64,14 @@ services:
- sonic-server-eureka
restart: on-failure
sonic-server-folder:
image: "sonicorg/sonic-server-folder:v1.4.1-beta"
image: "sonicorg/sonic-server-folder:v1.4.1-rc"
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
- SONIC_EUREKA_HOST=sonic-server-eureka
- SONIC_EUREKA_PORT
- SERVER_HOST
- SERVER_PORT
- SONIC_SERVER_HOST
- SONIC_SERVER_PORT
- SECRET_KEY
- EXPIRE_DAY
networks:
Expand All @@ -86,17 +86,17 @@ services:
- sonic-server-eureka
restart: on-failure
sonic-client-web:
image: "sonicorg/sonic-client-web:v1.4.1-beta"
image: "sonicorg/sonic-client-web:v1.4.1-rc"
environment:
- SERVER_HOST
- SERVER_PORT
- SONIC_SERVER_HOST
- SONIC_SERVER_PORT
networks:
- sonic-network
depends_on:
- sonic-server-gateway
restart: on-failure
ports:
- "${SERVER_PORT}:80"
- "${SONIC_SERVER_PORT}:80"

networks:
sonic-network:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<current.version>1.4.1-beta</current.version>
<current.version>1.4.1-rc</current.version>
</properties>

<!-- SpringCloud版本管理 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public String getToken(String username) {
.sign(Algorithm.HMAC256(TOKEN_SECRET));
}

public String getToken(String username, int day) {
Calendar now = Calendar.getInstance();
now.add(Calendar.DATE, day);
Date nowTime = now.getTime();
return JWT.create().withAudience(username, UUID.randomUUID().toString())
.withExpiresAt(nowTime)
.sign(Algorithm.HMAC256(TOKEN_SECRET));
}

/**
* @param token
* @return java.lang.String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ knife4j:
enable: true
setting:
enableHost: true
enableHostText: http://${SERVER_HOST:localhost}:${SERVER_PORT:3000}/server
enableHostText: http://${SONIC_SERVER_HOST:localhost}:${SONIC_SERVER_PORT:3000}/server
enableFooter: false
enableFooterCustom: true
footerCustomContent: Apache License | Copyright 2021 - [SonicCloudOrg/sonic-server](https://github.com/SonicCloudOrg/sonic-server/blob/main/LICENSE)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spring:

robot:
client:
host: http://${SERVER_HOST:localhost}:${SERVER_PORT:3000}/server
host: http://${SONIC_SERVER_HOST:localhost}:${SONIC_SERVER_PORT:3000}
img:
success: "https://gitee.com/sonic-cloud/sonic-cloud/raw/master/src/assets/suc.png"
warning: "https://gitee.com/sonic-cloud/sonic-cloud/raw/master/src/assets/warn.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ spring:

# 网关的IP地址
gateway:
host: http://${SERVER_HOST:localhost}:${SERVER_PORT:3000}/server
host: http://${SONIC_SERVER_HOST:localhost}:${SONIC_SERVER_PORT:3000}/server
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server:
port: 8094

filter:
white-list: /websockets,/users/login,/users/register,/users/loginConfig,/swagger-resources,/v2/api-docs,/folder/upload,/folder/upload/recordFiles,/keepFiles/,/imageFiles/,/recordFiles/,/logFiles/,/packageFiles/
white-list: /projects/list,/websockets,/users/login,/users/register,/users/loginConfig,/swagger-resources,/v2/api-docs,/folder/upload,/folder/upload/recordFiles,/keepFiles/,/imageFiles/,/recordFiles/,/logFiles/,/packageFiles/

spring:
cloud:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
package org.cloud.sonic.controller.config;

import lombok.extern.slf4j.Slf4j;
import org.cloud.sonic.controller.models.domain.ConfList;
import org.cloud.sonic.controller.models.interfaces.ConfType;
import org.cloud.sonic.controller.services.ConfListService;
import org.cloud.sonic.controller.services.ResourcesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Slf4j
@Component
public class SonicRunner implements ApplicationRunner {

@Autowired
private ResourcesService resourcesService;

@Autowired
private ConfListService confListService;

@Value("${spring.version}")
private String version;

@Override
public void run(ApplicationArguments args) throws Exception {
resourceInit();
}

/**
* 首次启动对项目里面的 url 资源进行初始化
* 每次启动对信息进行版本对比,不一致进行一起更新
*/
private void resourceInit() {
try {
if (resourcesService.count() == 0) {
resourcesService.init();
log.info("resource init finish!");
}else {
log.info("resource has been init...");

ConfList conf = confListService.searchByKey(ConfType.RESOURCE);
if (conf != null && Objects.equals(conf.getContent(), version)) {
log.info("version: {},resource has been init...", version);
return;
}
resourcesService.init();
log.info("version: {}, resource init finish!", version);
confListService.save(ConfType.RESOURCE, version, null);

}catch (Exception e) {
log.error("init resource error", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (C) [SonicCloudOrg] Sonic Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.cloud.sonic.controller.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.cloud.sonic.common.config.WebAspect;
import org.cloud.sonic.common.http.RespEnum;
import org.cloud.sonic.common.http.RespModel;
import org.cloud.sonic.controller.models.base.CommentPage;
import org.cloud.sonic.controller.models.domain.Packages;
import org.cloud.sonic.controller.models.dto.PackageDTO;
import org.cloud.sonic.controller.services.PackagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author yaming116, Eason
* @des
* @date 2022/5/26 1:22
*/
@Api(tags = "安装包管理")
@RestController
@RequestMapping("/packages")
public class PackageController {

@Autowired
private PackagesService packagesService;

@WebAspect
@ApiOperation(value = "添加安装包信息", notes = "添加安装包信息")
@PutMapping
public RespModel<String> save(@Validated @RequestBody PackageDTO pkg) {
packagesService.save(pkg.convertTo());
return new RespModel<>(RespEnum.UPDATE_OK);
}

@WebAspect
@ApiOperation(value = "查找所有安装包", notes = "查找所有安装包")
@GetMapping("/list")
public RespModel<CommentPage<PackageDTO>> findAll(@RequestParam(name = "projectId") int projectId,
@RequestParam(name = "branch", required = false) String branch,
@RequestParam(name = "platform", required = false) String platform,
@RequestParam(name = "page") int page,
@RequestParam(name = "pageSize") int pageSize) {

Page<Packages> pageable = new Page<>(page, pageSize);

return new RespModel<>(RespEnum.SEARCH_OK, packagesService.findByProjectId(projectId, branch, platform, pageable));
}
}
Loading

0 comments on commit 4446325

Please sign in to comment.