From eae4e5082c56fcccc61a0be17457d942e299378f Mon Sep 17 00:00:00 2001 From: tabliang Date: Mon, 17 Aug 2020 15:57:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20deno=20=E5=BA=94=E7=94=A8=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E6=94=B9=E4=B8=BA=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20denon=20=E6=9D=A5=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/framework-plugin-deno/README.md | 16 ++++++++++++++-- packages/framework-plugin-deno/assets/Dockerfile | 6 +++--- packages/framework-plugin-deno/package.json | 2 +- packages/framework-plugin-deno/src/builder.ts | 11 ----------- packages/framework-plugin-deno/src/index.ts | 4 +--- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/framework-plugin-deno/README.md b/packages/framework-plugin-deno/README.md index d25e04223..3b8bb73b0 100644 --- a/packages/framework-plugin-deno/README.md +++ b/packages/framework-plugin-deno/README.md @@ -87,9 +87,21 @@ cloudbase framework:deploy 选填,入口文件,字符串格式,默认值 `'entry.ts'` -### `runOptions` +## 关于 denon -选填,Deno 执行选项,字符串数组格式,默认值 `['--allow-all']` +服务使用 [denon](https://github.com/denosaurs/denon) 来管理 deno 进程,以便于管理 deno 启动参数 + +```yml +# denon.yml +allow: + - net + - env + +scripts: + start: deno run entry.ts +``` + +`cloudbase init` 之后会自动提供一个默认的 denon.yml,请根据应用需求来修改 ## 更多插件 diff --git a/packages/framework-plugin-deno/assets/Dockerfile b/packages/framework-plugin-deno/assets/Dockerfile index 43969a622..2c9c4c2ce 100644 --- a/packages/framework-plugin-deno/assets/Dockerfile +++ b/packages/framework-plugin-deno/assets/Dockerfile @@ -9,12 +9,12 @@ ENV DENO_DIR="/root/.cache/deno" ENV DENO_INSTALL="/root/.deno" ENV PATH="$DENO_INSTALL/bin:$PATH" ENV PORT=80 - EXPOSE 80 -ENTRYPOINT ["deno"] WORKDIR /usr/src/app COPY . . +RUN deno install --allow-read --allow-run --allow-write --allow-net -f -q --unstable https://deno.land/x/denon/denon.ts RUN deno install <%= entry %> -CMD ["run", <%- denoRunOptions %>, "<%= entry %>"] +ENTRYPOINT ["denon"] +CMD ["start"] diff --git a/packages/framework-plugin-deno/package.json b/packages/framework-plugin-deno/package.json index f4b2316e8..ddb7038c1 100644 --- a/packages/framework-plugin-deno/package.json +++ b/packages/framework-plugin-deno/package.json @@ -1,6 +1,6 @@ { "name": "@cloudbase/framework-plugin-deno", - "version": "0.1.0", + "version": "0.2.0", "description": "云开发 Tencent CloudBase Framework Deno Server Plugin 插件,将项目下的 Deno 应用一键部署云开发环境,提供自动弹性伸缩的高性能 Deno 服务", "author": "Tencent CloudBase Team", "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme", diff --git a/packages/framework-plugin-deno/src/builder.ts b/packages/framework-plugin-deno/src/builder.ts index d57bf77c6..50c2a3aa7 100644 --- a/packages/framework-plugin-deno/src/builder.ts +++ b/packages/framework-plugin-deno/src/builder.ts @@ -14,8 +14,6 @@ interface BuilderBuildOptions { runtime?: string; // 启动入口文件 entry?: string; - // 启动参数 - runOptions?: Array; // 路径 path: string; // 服务名 @@ -43,15 +41,6 @@ export class DenoBuilder extends Builder { spec.denoVersion = `-s ${spec.runtime}` } - spec.denoRunOptions = ''; - if (!spec.runOptions || spec.runOptions.length <= 0) { - spec.denoRunOptions = '"--allow-env",' - } else { - spec.denoRunOptions = spec.runOptions.map((option:string) => { - return `"${option}"`; - }).join(',') - } - fs.ensureDirSync(appDir); await Promise.all([ diff --git a/packages/framework-plugin-deno/src/index.ts b/packages/framework-plugin-deno/src/index.ts index 4b46982b3..fb8235e14 100644 --- a/packages/framework-plugin-deno/src/index.ts +++ b/packages/framework-plugin-deno/src/index.ts @@ -22,10 +22,9 @@ class DenoPlugin extends Plugin { const DEFAULT_INPUTS = { dockerImage: 'debian:buster-slim', - // example: v1.2.0 + // runtime example: v1.2.0 runtime: 'latest', entry: 'entry.ts', - runOptions: ['--allow-all'], serviceName: 'deno-app', servicePath: '/deno-app', projectPath: '.', @@ -63,7 +62,6 @@ class DenoPlugin extends Plugin { dockerImage: this.resolvedInputs.dockerImage, runtime: this.resolvedInputs.runtime, entry: this.resolvedInputs.entry, - runOptions: this.resolvedInputs.runOptions, name: this.resolvedInputs.serviceName || 'deno-app', path: this.resolvedInputs.servicePath || '/deno-app', }