在 CircleCI 中,我尝试构建 Docker 映像并将其推送到 AWS ECR,然后使用 AWS ECS 进行部署。但是,对于 AWS ECS 部分,我在 CircleCI 中收到错误:
Error: config compilation contains errors: config compilation contains errors:
- Error calling workflow: 'build_deploy_prod'
- Error calling job: 'deploy-to-ecs'
- Cannot find a definition for command named aws-ecs/deploy_service_update
我发现 AWS ECR 部分没有任何问题并且工作正常,但是我仅在 AWS ECS 部署_服务_更新时收到此错误。
这是我的 CircleCI config.yml 的代码:
version: 2.1
orbs:
aws-cli: circleci/[email protected]
aws-ecr: circleci/[email protected]
aws-ecs: circleci/[email protected]
executors:
pod-php:
docker:
- image: circleci/php:7.4-node
- image: tkuchiki/delayed-mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: ''
MYSQL_DATABASE: pod_test
working_directory: [REDACTED]
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artfacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
DEBIAN_FRONTEND: noninteractive
jobs:
build-and-push-docker:
docker:
- image: cimg/php:7.4-node
steps:
- checkout
- run:
name: Install dependencies
command: |
composer install --no-interaction --prefer-dist
npm install
- run:
name: Build application
command: |
npm run production
- setup_remote_docker:
version: 20.10.14
# Environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_ECR_ACCOUNT_URL
- aws-ecr/build_and_push_image:
auth:
- aws-cli/setup:
role_arn: arn:aws:iam::[REDACTED]
repo: [REDACTED]
tag: "latest, v0.1.${CIRCLE_BUILD_NUM}"
dockerfile: Dockerfile
deploy-to-ecs:
docker:
- image: cimg/base:stable
steps:
- aws-ecs/deploy_service_update:
auth:
- aws-cli/setup:
role_arn: arn:aws:iam::[REDACTED]
cluster: ${ECS_CLUSTER_NAME}
container_image_name_updates: container=${ECS_SERVICE_NAME},tag=${CIRCLE_SHA1}
family: ${ECS_SERVICE_NAME}
workflows:
version: 2.1
build_deploy_prod:
jobs:
- test:
context: "prod"
filters:
branches:
only:
- master
- build-and-push-docker:
context: "prod"
requires:
- test
filters:
branches:
only:
- master
- deploy-to-ecs:
context: "prod"
requires:
- build-and-push-docker
filters:
branches:
only:
- master
我尝试过使用连字符和下划线的服务名称。我尝试使用 CircleCI 网站上的文档进行设置: