How to run self-hosted dify

Git からコードをコピー

git clone https://github.com/aws-samples/dify-self-hosted-on-aws.git
Python

自分用のコードをGITにremore

git remote set-url origin https://github.com/<username>/<new-repository>.git
Python

public codeをupstramとして追加

git remote add upstream https://github.com/aws-samples/dify-self-hosted-on-aws.git
Python

check

git remote -v
Python

switch to your branch

git branch master
git checkout master
git push -u origin master
Python

merge from public code

git checkout main
git fetch upstream
git merge upstream/main
git checkout master
git merge main
Python

download package for ubuntu

sudo snap install docker
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 18
nvm use 18
Python

git clone https://
npx ci
npx cdk bootstrap


sudo ln -s $(which node) /usr/local/bin/node
sudo ln -s $(which npx) /usr/local/bin/npx
sudo npx cdk deploy --all --require-approval never
Python

parameterを変更して再Deploy

・api.tsとweb.tsの設定を変更して、上記のDeployコードをもう1回実行すれば再Deployできる。既存のDBは削除されない。

auto scaling

・api.tsを変更

    postgres.connections.allowDefaultPortFrom(service);
    redis.connections.allowDefaultPortFrom(service);

    // add auto scaling setting
    const scaling = service.autoScaleTaskCount({
      minCapacity: 1,  // 闲暇时保持 1 个任务
      maxCapacity: 5,  // 最多扩展到 5 个任务
    });

    // add suto scaling policy
    scaling.scaleOnCpuUtilization('CpuScaling', {
      targetUtilizationPercent: 75,  //CPU 使用率达到 75% 时触发扩缩
      scaleInCooldown: Duration.seconds(60),   // 缩减冷却时间
      scaleOutCooldown: Duration.seconds(60),  // 扩展冷却时间
    });
Python

・web.tsを変更

    // add auto scaling setting
    const scaling = service.autoScaleTaskCount({
      minCapacity: 1,  // 闲暇时保持 1 个任务
      maxCapacity: 5,  // 最多扩展到 5 个任务
    });

    // add suto scaling policy
    scaling.scaleOnCpuUtilization('CpuScaling', {
      targetUtilizationPercent: 75,  //CPU 使用率达到 75% 时触发扩缩
      scaleInCooldown: Duration.seconds(60),   // 缩减冷却时间
      scaleOutCooldown: Duration.seconds(60),  // 扩展冷却时间
    });

    alb.addEcsService('Web', service, port, '/', ['/*']);
Python

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注