Skip to content

Commit

Permalink
Add Dify template: Build the large language model (LLM) application d…
Browse files Browse the repository at this point in the history
…evelopment platform Dify on the ECS instance (CentOS 7).
  • Loading branch information
Prodesire committed May 31, 2024
1 parent d37df26 commit ab7cae2
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
1 change: 1 addition & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ ROS 模板的示例和最佳实践。模板分类如下:

| 模板 | 说明 |
| ---- | ---- |
| [ai/ecs-instance-dify.yml](./examples/ai/ecs-instance-dify.yml) | 在ECS实例(CentOS 7)上搭建大语言模型(LLM) 应用开发平台Dify。 |
| [application/ecs-clone-join-sls.yml](./examples/application/ecs-clone-join-sls.yml) | 克隆ECS实例,将IP指向日志服务中新建的机器组,应用指定的规则。 |
| [application/ecs-group-join-cms.yml](./examples/application/ecs-group-join-cms.yml) | 手动部署LNMP环境(CentOS 7)及配置CMS报警项和报警联系人。 |
| [application/ecs-group-join-sls.yml](./examples/application/ecs-group-join-sls.yml) | 创建一组ECS实例,将其作为日志服务中相关项目logtail的机器组。 |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Examples and best practices of ROS templates. The templates are categorized as f

| Template | Description |
| -- | ---- |
| [ai/ecs-instance-dify.yml](./examples/ai/ecs-instance-dify.yml) | Build the large language model (LLM) application development platform Dify on the ECS instance (CentOS 7). |
| [application/ecs-clone-join-sls.yml](./examples/application/ecs-clone-join-sls.yml) | Clone the ECS instance, direct the IP to the new machine group created in the Log Service, and apply the specified rules. |
| [application/ecs-group-join-cms.yml](./examples/application/ecs-group-join-cms.yml) | Manually deploy the LNMP environment (CentOS 7) and configure CMS alarm items and alarm contacts. |
| [application/ecs-group-join-sls.yml](./examples/application/ecs-group-join-sls.yml) | Create a set of ECS instance, and consider it as the machine group of the related project logtail in Log Service. |
Expand Down
154 changes: 154 additions & 0 deletions examples/ai/ecs-instance-dify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: Build the large language model (LLM) application development platform Dify on
the ECS instance (CentOS 7).
zh-cn: 在ECS实例(CentOS 7)上搭建大语言模型(LLM) 应用开发平台Dify。
Parameters:
ZoneId:
Type: String
Label:
en: Availability Zone
zh-cn: 可用区ID
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
DefaultValueStrategy: recent
SystemDiskCategory:
Type: String
Label:
en: System Disk Type
zh-cn: 系统盘类型
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
LocaleKey: DiskCategory
ZoneId: ${ZoneId}
InstanceType: ${InstanceType}
AutoSelectFirst: true
AutoChangeType: false
Default: cloud_essd
InstancePassword:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol
in).
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
ConstraintDescription:
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers,
()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${SelectInstance}
- false
Default:
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
MinLength: 8
MaxLength: 30
NoEcho: true
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
CidrBlock: 192.168.0.0/24
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SecurityGroupIngress_80:
Type: ALIYUN::ECS::SecurityGroupIngress
Properties:
SecurityGroupId:
Ref: SecurityGroup
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
NicType: intranet
PortRange: 80/80
InstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId: centos_7_9
InstanceName: dify
InstanceType:
Ref: InstanceType
SystemDiskCategory:
Ref: SystemDiskCategory
Password:
Ref: InstancePassword
IoOptimized: optimized
MaxAmount: 1
DS_Instances:
Type: DATASOURCE::ECS::Instances
Properties:
InstanceIds:
Fn::GetAtt:
- InstanceGroup
- InstanceIds
InstallDify:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
Fn::GetAtt:
- InstanceGroup
- InstanceIds
Type: RunShellScript
Sync: true
Timeout: 1800
CommandContent: |
#!/bin/bash
echo "#########################"
echo "# Install Docker"
echo "#########################"
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
systemctl start docker
systemctl enable docker
echo "#########################"
echo "# Install Dify"
echo "#########################"
yum -y install git
git clone --depth 1 https://github.com/langgenius/dify.git /opt/dify
cd /opt/dify/docker
docker compose up -d
docker compose ps
Outputs:
DifyUrl:
Description: Dify default address.
Value:
Fn::Sub:
- http://${IP}
- IP:
Fn::Jq:
- First
- if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0] else .[0].EipAddress.IpAddress
end
- Fn::GetAtt:
- DS_Instances
- Instances

0 comments on commit ab7cae2

Please sign in to comment.