我们在工作流程中使用CircleCi,以便将PHP部署为ElasticBeanstalk服务器上的码头映像。build作业在CircleCi中的定义如下:
deploy:
docker:
- image: docker:17.05.0-ce-git
steps:
- checkout
- setup_remote_docker
- run:
name: Install dependencies
command: |
apk add --no-cache \
py-pip=9.0.0-r1
pip install \
awscli \
awsebcli --upgrade
- run:
name: Login to AWS
command: |
login="$(aws ecr get-login --no-include-email --region us-west-2)"
${login}
- run:
name: Deploy to Elastic Beanstalk
command: |
echo "Commit sha: ${CIRCLE_SHA1}"
if [ "${CIRCLE_BRANCH}" == "docker" ]; then
sed -i'' -e "s/%BUILD_NUM%/${CIRCLE_SHA1}/g" Dockerrun.aws.json
eb deploy sales-web -l $CIRCLE_SHA1
fi在Dockerrun.aws.json中,containerDefinitions下有(####是应用程序id和存储库名称在ECS中的正确值)
{
"essential": true,
"image": "####.dkr.ecr.us-west-2.amazonaws.com/####:%BUILD_NUM%",
"memory": 2048,
"name": "web-container",
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
]
}登录到AWS步骤成功,图像被上传,环境sales-web开始更新,但失败
2018-03-02 16:10:41 UTC+0200 ERROR Failed to deploy application.
2018-03-02 16:10:41 UTC+0200 ERROR Service:AmazonECS, Code:ClientException, Message:Container.image contains invalid characters., Class:com.amazonaws.services.ecs.model.ClientException
2018-03-02 16:09:52 UTC+0200 INFO Environment update is starting.我们确保映像构建正确(我们可以上传它为ti CircleCi服务器,启动容器并运行phpunit测试)。项目根目录中有.elasticbeanstalk文件夹,具有有效的config.yml文件。
已经尝试和谷歌了2天,但没有运气。将感谢任何帮助或指导,以理解这一错误信息的含义。如果需要任何额外的细节,我会提供他们,只要问。
发布于 2018-08-22 00:23:50
当我在一个变量的末尾有一个额外的}时,我使用了terraform。
您可以尝试的是在docker中构造映像名,并回显它以进行审核。
更新您的Dockerrun.aws.json如下:
...
"image": "%IMAGE_NAME",
...然后更新您的圆圈构建如下:
- run:
name: Deploy to Elastic Beanstalk
command: |
echo "Commit sha: ${CIRCLE_SHA1}"
if [ "${CIRCLE_BRANCH}" == "docker" ]; then
IMAGE_NAME=####.dkr.ecr.us-west-2.amazonaws.com/####:${CIRCLE_SHA1}
echo "IMAGE_NAME is $IMAGE_NAME"
sed -i'' -e "s/%IMAGE_NAME%/${IMAGE_NAME}/g" Dockerrun.aws.json
eb deploy sales-web -l $CIRCLE_SHA1
fi如果它失败,则在构建过程中复制IMAGE_NAME输出,并尝试使用
$(aws ecr get-login --no-include-email --region us-west-2)
docker pull <IMAGE_NAME>我打赌它会有一个错误,您可以排除。
发布于 2022-02-08 07:05:11
在尝试使用Dockerrun.aws.json进行部署时,返回了一个类似的错误。对于我的例子,我在image属性中有一个空格,如下所示。确保正确定义Dockerrun.aws.json文件
{
"AWSEBDockerrunVersion": 2,
"volumes": [
{
"name": "demo-app",
"host": {
"sourcePath": "/var/app/current/demo-app"
}
}
],
"containerDefinitions": [
{
"name": "demo-app",
"image": " foo.dkr.ecr.me-south-1.amazonaws.com/foo:latest",
"essential": true,
"memory": 378,
"links": ["redis"],
"command": ["./entrypoint.sh"],
"portMappings": [
{
"hostPort": 80,
"containerPort": 5000
}
],
"mountPoints": [
{
"sourceVolume": "demo-app",
"containerPath": "/src",
"readOnly": true
}
]
},
{
"name": "redis",
"image": "redis:latest",
"essential": false,
"memory": 128
}
]
}发布于 2022-11-02 20:06:20
在尝试使用GitHub操作时,我也遇到了类似的问题。
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
<---- $ECR_REPOSITORY missing here since it is used below
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUTECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}它来自于上面的步骤
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1https://stackoverflow.com/questions/49094182
复制相似问题