Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

aws-samples/solution-for-deploying-dify-on-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

11/29Support for Valkey instead of Redis.Support Aurora Serverless v2, mini capacity default to 0 ACU.

/------------------------------------------------------------------------------------------------/

This solution demostrates how to deploy community version of dify on AWS using CDK.It also provide a solution for deploying langfuse as a plugin of dify for tracing and monitoring.

It utilized AWS managed services including ALB, EKS, Aurora PostgreSQL, Opensearch, and S3.All the services deployed using Graviton processors to take maximum advantage of AWS cost optimization.

The default configuration is only for test purpose, please update the corresponding values in cdk.json for production use.

Also, please consider to purchase dify enterprise version for production use in AWS marketplace.

Deployment Architecture

Install from CDK

0.Prepare the CDK enviroment

sudo dnf install nodejs git -ysudo npm install -g aws-cdk sudo npm install -g typescript ts-node

Configure AWS CLI

aws configure

Download cdk code

git clone https://github.com/aws-samples/solution-for-deploying-dify-on-aws.gitcd solution-for-deploying-dify-on-aws/dify-cdk/npm install

1.Deploy dify and langfuse

Configure cdk.json for dify, gnerate your own "difySecretKey" using "openssl rand -base64 42"

"dbPassword":"Your.dbPassword.0910","opensearchPassword":"Your.aosPassword.0910","S3AccessKey":"Your.S3.AccessKey","S3SecretKey":"Your.S3.SecretKey",

[Optional] Configure cdk.json for langfuse, gnerate your own "nextAuthSecret" and "salt" using "openssl rand -base64 32"

"nextAuthSecret":"openssl rand -base64 32","salt":"openssl rand -base64 32",

2.Configure cdk environment, only need to run once

cdk synthcdk bootstrap

3.Deploy CDK

cdk deploy --all --concurrency 5 --require-approval never

Please use concurrency deployment, the whole deployment process takes about 20 minutes, if not using concurrency, it will take extra time.

4.Configure helm environment variablesEdit dify-helm-stack.ts in lib directoryIf you don't have your own domain, please configure the two host variables in the file to be the DNS name of the ALB created by CDK, such as:

constdifyHelm=neweks.HelmChart(this,'DifyHelmChart',{cluster:props.cluster,chart:'dify',repository:'https://douban.github.io/charts/',release:'dify',namespace:'default',values:{global:{//Specify your host on ALB DNS namehost:'k8s-default-dify-324ef51b8a-687325639.us-east-1.elb.amazonaws.com',
ingress:{enabled:true,className:'alb',annotations:{'kubernetes.io/ingress.class':'alb','alb.ingress.kubernetes.io/scheme':'internet-facing','alb.ingress.kubernetes.io/target-type':'ip','alb.ingress.kubernetes.io/listen-ports':'[{"HTTP": 80}]',//'alb.ingress.kubernetes.io/listen-ports': '[{"HTTPS": 443}]',//'alb.ingress.kubernetes.io/certificate-arn': 'arn:aws:acm:ap-southeast-1:788668107894:certificate/6404aaf8-6051-4637-8d93-d948932b18b6',},hosts:[{host:'k8s-default-dify-324ef51b8a-687325639.us-east-1.elb.amazonaws.com',

If you have your own domain, please configure your domain, and open tls, and configure your certificate ARN to 'alb.ingress.kubernetes.io/certificate-arn'.

Other environment variables injection, please refer tohttps://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted/environments

Deploy CDK again to enable enviroment variables

cdk deploy --all --concurrency 5 --require-approval never

5.dify database initializationConfigure "access entry" in EKS console for your user/role with policy "AmazonEKSAdminPolicy" and "AmazonEKSClusterAdminPolicy".

Please find a terminal that can connect to EKS, and run below:

aws eks update-kubeconfig --region$region --name dify-eks

Initial dify database with database migration scripts

kubectlexec -it$(kubectl get pods -n dify -l app.kubernetes.io/component=api -o jsonpath='{.items[0].metadata.name}') -n dify -- flask db upgrade

After execution, you can access dify usinghttp://ALBDNSName, and register as an administrator.

About upgrade:dify community version is very active, please update the tag variable in dify-helm-stack.ts for upgrade.And then run cdk deploy and database initialization again.

global:{host:'',port:'',enableTLS:false,image:{tag:'0.12.1'},edition:'SELF_HOSTED',storageType:'s3',extraEnvs:[],extraBackendEnvs:[

After upgrade, please run step5 again for database initialization.

FinallyHappy dify with AWS

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp