Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add-flask-build #198

Open
wants to merge 9 commits into
base: V3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions web-framework/python/flask/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Edition: 3.0.0
Type: Project
Name: start-flask-v3
Name: start-dipper-flask
Provider:
- 阿里云
Version: 0.0.16
Version: 0.0.3
Description: 本案例将Flask框架,这一非常受欢迎的Python Web框架,快捷创建并部署到阿里云函数计算 FC。
HomePage: https://github.com/devsapp/start-web-framework
Organization: 阿里云函数计算(FC)
Expand All @@ -22,6 +22,8 @@ Parameters:
required: # 必填项
- region
- functionName
- chat_api_url
- chat_api_token
properties:
region:
title: 地域
Expand Down Expand Up @@ -55,3 +57,23 @@ Parameters:
default: flask-${default-suffix}
pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$"
description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间

domainName:
title: 域名配置
type: string
default: auto
description: 函数计算自定义域名, 如果为 auto,则会下发一个一定有效期的仅支持 http 临时测试域名(切莫用于生产)
required: false
x-domain: true

chat_api_url:
title: chat_api_url
type: string
default: 'https://api.openai.com/v1'
description: chat api 服务的 url

chat_api_token:
title: chat_api_token
type: string
sensitive: true
description: chat api 服务的 token
9 changes: 9 additions & 0 deletions web-framework/python/flask/src/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fc-flask:
defaultBuilder:
languages:
- python3.10
steps:
- run: mkdir python
path: ./code
- run: pip install -r requirements.txt -t ./python
path: ./code
36 changes: 18 additions & 18 deletions web-framework/python/flask/src/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ name: flask-app
access: "{{ access }}"
vars:
region: "{{ region }}"
functionName: "{{ functionName }}"

resources:
framework:
fc-flask:
component: fc3
actions:
pre-deploy:
- run: mkdir python
path: ./code
- run: pip install -r requirements.txt -t ./python
path: ./code
complete-deploy:
- plugin: flow_api_registry@dev
complete-remove:
- plugin: flow_api_registry@dev
props:
timeout: 60
cpu: 1
Expand All @@ -35,7 +36,11 @@ resources:
PATH: /var/fc/lang/python3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin:/opt/bin:/code:/code/bin
PYTHONPATH: /opt/python:/code/python:/code
TZ: Asia/Shanghai
functionName: "{{ functionName }}"
CHAT_API_URL: '{{ chat_api_url }}'
CHAT_API_TOKEN: '{{ chat_api_token }}'
PROJECT_NAME: ${env('ALIYUN_DEVS_REMOTE_PROJECT_NAME')}
XX_NAME: ${env('ALIYUN_DEVS_REMOTE_PROJECT_NAME')}_XX
functionName: ${vars.functionName}
code: ./code
layers:
- acs:fc:${this.props.region}:official:layers/Python3-Flask2x/versions/2
Expand All @@ -49,14 +54,9 @@ resources:
- PUT
- DELETE
authType: anonymous

fc3_domain_0:
component: fc3-domain
props:
region: ${vars.region}
domainName: auto
protocol: HTTP
routeConfig:
routes:
- path: /*
functionName: ${resources.framework.props.functionName}
customDomain:
domainName: "{{ domainName }}"
protocol: HTTP
route:
path: /*
qualifier: LATEST
12 changes: 12 additions & 0 deletions web-framework/python/flask/src/variable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services: #服务变量
fc-flask:
chat_api_url:
title: chat_api_url
type: string
default: 'https://api.openai.com/v1'
description: chat api 服务的 url
chat_api_token:
title: chat_api_token
type: string
sensitive: true
description: chat api 服务的 token