dify-self-hosted-on-aws: An error occurs when deploying the ECS Fargate API, and the deployment does not complete, resulting in a timeout error.

I tried deploying Dify to AWS, but when I deploy the Fargate API task, the task fails to start and ends with an error.

  • The deployment keeps failing with errors (eventually a timeout occurs), so the ECS circuit breaker is enabled to forcibly terminate the deployment.

The following is the content of the error, but how should I respond?

Source code

Only bin/cdk.ts has been modified as follows. The other files have not been modified.

export const props: EnvironmentProps = {
awsRegion: 'ap-northeast-1',
awsAccount: '123456789',
difyImageTag: 'latest',
difySandboxImageTag: 'latest',
domainName: 'example.com',
subDomain: 'dify',
isRedisMultiAz: false,
enableAuroraScalesToZero: true,
useNatInstance: true,
useCloudFront: true
};

Commands

# success
npx cdk bootstrap --profile=my-profile
# received error
npx cdk deploy --all --profile=my-profile

Error on ECS deploy

The same error as in this link (https://github.com/aws-samples/dify-self-hosted-on-aws/issues/3) is displayed.

cannotPullContainerError: ref pull has been retried 1 time(s): failed to unpack image on snapshotter overlayfs: mismatched image rootfs and manifest layers

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

🎉 I’ll take a look at it tomorrow. Thanks!

@tatsuyoshi-mashiko Have you seen a similar error as below when running cdk deploy?

DifyOnAwsStack: fail: docker push 123456789012.dkr.ecr.ap-southeast-1.amazonaws.com/cdk-hnb659fds-container-assets-123456789012-ap-southeast-1:390daaab2c4f628bdc73937a612367625074094c3a0c37c0765c4a3b0af66535 exited with error code 1: failed commit on ref “manifest-sha256:988ce6b453eff7b26252ad0f84ae6543410ad726c50b1c5a36adf0c54316c18b”: unexpected status from PUT request to https://123456789012.dkr.ecr.ap-southeast-1.amazonaws.com/v2/cdk-hnb659fds-container-assets-123456789012-ap-southeast-1/manifests/390daaab2c4f628bdc73937a612367625074094c3a0c37c0765c4a3b0af66535: 400 Bad Request

Also, does your CDK ECR repositroy (it looks like cdk-hnb659fds-container-assets-<accout>-<region>) contain 0MB images?

Image

If so, the below steps should resolve the problem:

  1. Remove images with 0MB size from ECR
  2. Open Docker Desktop dashboard
  3. Disable General -> Use containerd for pulling and storing images
  4. Restart Docker Desktop
  5. run cdk deploy again

Setting BUILDX_NO_DEFAULT_ATTESTATIONS=1 also seems to fix the problem, but you have to correctly invalidate build caches (e.g. inserting lines like ENV FOO 1 right after FROM line in two Dockerfiles (sandbox and external-knowledge-api.)

Another workaround is to deploy it from CloudShell as described here, which should just work without any workaround.

References:

Hi @tatsuyoshi-mashiko thank you for the trial and error. As my colleague reproduced a similar issue, I’ll dive deep into it tomorrow in his environment.