Skip to content

Commit

Permalink
Add the serverless deployment mode
Browse files Browse the repository at this point in the history
  • Loading branch information
183461750 committed Oct 3, 2023
1 parent 301a85d commit 19cc4c1
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
66 changes: 66 additions & 0 deletions serverless/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Type: Application
Name: start-nocobase
Provider:
- 阿里云
Version: 0.1.16
Description: 快速部署一个 nocobase 函数到阿里云函数计算
HomePage: https://github.com/183461750/nocobase
Tags:
- 函数计算
- 全栈应用
Category: 全栈应用
Service:
函数计算:
Authorities:
- AliyunFCFullAccess
- AliyunContainerRegistryFullAccess
Runtime: custom container
Parameters:
type: object
additionalProperties: false # 不允许增加其他属性
required: # 必填项
- region
- serviceName
- functionName
- imageNamespace
properties:
region:
title: 地域
type: string
default: cn-hangzhou
description: 创建应用所在的地区
enum:
- cn-beijing
- cn-hangzhou
- cn-shanghai
- cn-qingdao
- cn-zhangjiakou
- cn-huhehaote
- cn-shenzhen
- cn-chengdu
- cn-hongkong
- ap-southeast-1
- ap-southeast-2
- ap-southeast-3
- ap-southeast-5
- ap-northeast-1
- eu-central-1
- eu-west-1
- us-west-1
- us-east-1
- ap-south-1
serviceName:
title: 服务名
type: string
default: nocobase-service
description: 服务名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间
functionName:
title: 函数名
type: string
default: nocobase-function
description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间
imageNamespace:
title: 镜像仓库的命名空间
type: string
default: nocobase-namespace
description: 镜像仓库的命名空间,需要在 https://cr.console.aliyun.com/ 中开通服务、创建镜像仓库的命名空间以及设置访问凭证
56 changes: 56 additions & 0 deletions serverless/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# start-nocobase 帮助文档

<description>

快速部署一个 nocobase 函数到阿里云函数计算

</description>

<table>

## 前期准备
使用该项目,推荐您拥有以下的产品权限 / 策略:

| 服务/业务 | 函数计算 |
| --- | --- |
| 权限/策略 | AliyunFCFullAccess<br/>AliyunContainerRegistryFullAccess |

</table>

<codepre id="codepre">

# 代码 & 预览

- [ :smiley_cat: 源代码](https://github.com/183461750/nocobase)

</codepre>

<deploy>

## 部署 & 体验

<appcenter>

- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc-custom-container-websocket-nodejs14)
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc-custom-container-websocket-nodejs14) 该应用。

</appcenter>

- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config)
- 初始化项目:`s init start-nocobase -d start-nocobase`
- 进入项目,并进行项目部署:`cd start-nocobase && s deploy -y`

</deploy>

<appdetail id="flushContent">

# 应用详情



本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑



</appdetail>
9 changes: 9 additions & 0 deletions serverless/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM nocobase/nocobase:main
ARG LOCAL_STORAGE_BASE_URL=/storage/uploads

ENV DB_DIALECT=sqlite
ENV DB_STORAGE=/mnt/auto/nocobase/storage/db/nocobase.sqlite

COPY . .

EXPOSE 80 13000
48 changes: 48 additions & 0 deletions serverless/src/s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
edition: 1.0.0
name: nocobase-app
access: "{{ access }}"

vars: # 全局变量
region: "{{ region }}"
image_namespace: "{{ imageNamespace }}"
image_name: "{{ functionName }}"
service:
name: "{{ serviceName }}"
nasConfig: auto

services:
nocobaseService:
component: fc
actions:
pre-deploy:
- component: fc build --use-docker --dockerfile ./Dockerfile
props:
region: ${vars.region}
service: ${vars.service}
function:
name: "{{ functionName }}"
runtime: custom-container
timeout: 60
memorySize: 512
instanceConcurrency: 100
caPort: 13000
customContainerConfig:
image: "registry.${vars.region}.aliyuncs.com/${vars.image_namespace}/${vars.image_name}:v1.0"
triggers:
- name: httpTrigger
type: http
config:
authType: anonymous
methods:
- GET
- POST
- PUT
- DELETE
- HEAD
- OPTIONS
customDomains:
- domainName: Auto
protocol: HTTP
routeConfigs:
- path: /*

1 change: 1 addition & 0 deletions serverless/version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 兼容新版本

0 comments on commit 19cc4c1

Please sign in to comment.