serverless云函数初体验
- 0
#讨论区
00条评论
实时对话
loading...
之前个人项目都是部署在云服务器上,导致买了4台服务器才满足了场景 准备逐步迁移到
serverless
上
我们使用阿里云函数来部署
githubaction
和jenkins
都可以cicd
到serverless
s.yaml
配置文件+cicd工具
进发布yaml
yaml
yaml
edition: 1.0.0
access: "default"
services:
framework: # 业务名称/模块名称
component: fc # 组件名称
actions:
pre-deploy:
- run: pnpm i --frozen-lockfile
path: ./
- run: pnpm run build
path: ./
props: # 组件的属性值
region: cn-shanghai
service:
name: node-service
description: "Serverless Devs Website Service"
function:
name: blog
description: "Serverless Devs Website Docusaurus Function"
runtime: custom
codeUri: ./
timeout: 30
memorySize: 512
caPort: 9800
customRuntimeConfig:
command:
- npm
args:
- 'run'
- 'start'
triggers:
- name: httpTrigger
type: http
config:
authType: anonymous
methods:
- GET
- POST
- PUT
- DELETE
customDomains:
- domainName: auto
protocol: HTTP
routeConfigs:
- path: /*
edition: 1.0.0
access: "default"
services:
framework: # 业务名称/模块名称
component: fc # 组件名称
actions:
pre-deploy:
- run: pnpm i --frozen-lockfile
path: ./
- run: pnpm run doc:build
path: ./
- plugin: website-fc
props: # 组件的属性值
region: cn-shanghai
service:
name: web-service
description: "Serverless Devs Website Service"
function:
name: design
description: "Serverless Devs Website Docusaurus Function"
codeUri: ./dist
timeout: 30
memorySize: 512
triggers:
- name: httpTrigger
type: http
config:
authType: anonymous
methods:
- GET
- POST
- PUT
- DELETE
customDomains:
- domainName: auto
protocol: HTTP
routeConfigs:
- path: /*
#s.yaml
edition: 1.0.0
access: "default"
services:
framework: # 业务名称/模块名称
component: fc # 组件名称
actions:
pre-deploy:
- run: mvn clean package -DskipTests
path: ./
props: # 组件的属性值
region: cn-shanghai
service:
name: java-service
description: "Serverless Devs Website Service"
function:
name: server
description: "Serverless Devs Website Docusaurus Function"
runtime: custom
codeUri: ./
timeout: 30
memorySize: 512
caPort: 8080
customRuntimeConfig:
command:
- java
args:
- '-jar'
- 'target/blog-server-1.0.0.jar'
triggers:
- name: httpTrigger
type: http
config:
authType: anonymous
methods:
- GET
- POST
- PUT
- DELETE
customDomains:
- domainName: auto
protocol: HTTP
routeConfigs:
- path: /*