From 91250c05702760c4f4c2ac5fb26c460d89094f55 Mon Sep 17 00:00:00 2001 From: Maslow Date: Sat, 10 Dec 2022 02:42:47 +0800 Subject: [PATCH] fix(server): add region api, fix init image version (#503) Signed-off-by: maslow --- deploy/scripts/install-on-linux.sh | 2 +- server/src/applications/specs.controller.ts | 11 +++++++++++ server/src/constants.ts | 17 +++++++++++++++++ server/src/initializer/initializer.service.ts | 8 ++++---- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/deploy/scripts/install-on-linux.sh b/deploy/scripts/install-on-linux.sh index a3c444ed64..ddec75c897 100644 --- a/deploy/scripts/install-on-linux.sh +++ b/deploy/scripts/install-on-linux.sh @@ -45,7 +45,7 @@ kubectl taint node $NODENAME node-role.kubernetes.io/control-plane- sealos run labring/helm:v3.8.2 sealos run labring/openebs:v1.9.0 sealos run labring/cert-manager:v1.8.0 -sealos run lafyun/laf:dev +sealos run lafyun/laf:latest # Optional installations #arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) diff --git a/server/src/applications/specs.controller.ts b/server/src/applications/specs.controller.ts index c26780cf9a..2cc2a0c03c 100644 --- a/server/src/applications/specs.controller.ts +++ b/server/src/applications/specs.controller.ts @@ -9,6 +9,17 @@ export class SpecsController { private readonly logger = new Logger(SpecsController.name) constructor(private readonly prisma: PrismaService) {} + /** + * Get region list + * @returns + */ + @ApiOperation({ summary: 'Get region list' }) + @Get('regions') + async getRegions() { + const data = await this.prisma.region.findMany() + return ResponseUtil.ok(data) + } + /** * Get runtime list * @returns diff --git a/server/src/constants.ts b/server/src/constants.ts index a445a8b6de..2c04cf081e 100644 --- a/server/src/constants.ts +++ b/server/src/constants.ts @@ -49,6 +49,23 @@ export class ServerConfig { static get APPID_LENGTH(): number { return parseInt(process.env.APPID_LENGTH || '6') } + + static get DEFAULT_RUNTIME_IMAGE() { + const image = + process.env.DEFAULT_RUNTIME_IMAGE || + 'docker.io/lafyun/runtime-node:latest' + + const initImage = + process.env.DEFAULT_RUNTIME_INIT_IMAGE || + 'docker.io/lafyun/runtime-node-init:latest' + return { + image: { + main: image, + init: initImage, + }, + version: 'latest', + } + } } export class ResourceLabels { diff --git a/server/src/initializer/initializer.service.ts b/server/src/initializer/initializer.service.ts index 404d81d356..a9441a2a8c 100644 --- a/server/src/initializer/initializer.service.ts +++ b/server/src/initializer/initializer.service.ts @@ -1,5 +1,5 @@ import { Injectable, Logger } from '@nestjs/common' -import { CPU_UNIT, MB } from 'src/constants' +import { CPU_UNIT, MB, ServerConfig } from 'src/constants' import { PrismaService } from 'src/prisma.service' @Injectable() @@ -64,10 +64,10 @@ export class InitializerService { name: 'node', type: 'node:laf', image: { - main: 'docker.io/lafyun/runtime-node:1.0.0-alpha.0', - init: 'docker.io/lafyun/runtime-node-init:1.0.0-alpha.0', + main: ServerConfig.DEFAULT_RUNTIME_IMAGE.image.main, + init: ServerConfig.DEFAULT_RUNTIME_IMAGE.image.init, }, - version: '1.0.0-alpha.0', + version: ServerConfig.DEFAULT_RUNTIME_IMAGE.version, latest: true, }, })