Ошибка сборки CodeSipeline AWS ECS REPOSITORY_URI - PullRequest
0 голосов
/ 08 ноября 2019

мы хотим попробовать CodePipeline с изображением, которое у нас уже есть на ECR.

Итак, мы следуем инструкциям в документации.

У нас есть buildspec.yml, подобный этому:

phases:
  install:
    runtime-versions:
      nodejs: 10
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - $(aws ecr get-login --no-include-email --region us-east-1)
      - REPOSITORY_URI=OUR_URL_FROM_ECR
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_TAG=${COMMIT_HASH:=latest}
      - echo $REPOSITORY_URI
      - echo $COMMIT_HASH
      - echo $IMAGE_TAG
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...          
      - docker build -t $REPOSITORY_URI:latest .
      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:latest
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - echo Writing image definitions file...
      - printf '[{"name":"Petr","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
    files: imagedefinitions.json

Мы создали новый конвейерный поток, но когда мы вносим некоторые изменения, мы получаем этот журнал:

[Container] 2019/11/07 23:30:49 Waiting for agent ping 
[Container] 2019/11/07 23:30:51 Waiting for DOWNLOAD_SOURCE 
[Container] 2019/11/07 23:30:52 Phase is DOWNLOAD_SOURCE 
[Container] 2019/11/07 23:30:52 CODEBUILD_SRC_DIR=/codebuild/output/src386464501/src 
[Container] 2019/11/07 23:30:52 YAML location is /codebuild/output/src386464501/src/buildspec.yml 
[Container] 2019/11/07 23:30:52 No commands found for phase name: INSTALL 
[Container] 2019/11/07 23:30:52 Processing environment variables 
[Container] 2019/11/07 23:30:52 Moving to directory /codebuild/output/src386464501/src 
[Container] 2019/11/07 23:30:52 Registering with agent 
[Container] 2019/11/07 23:30:52 Phases found in YAML: 4 
[Container] 2019/11/07 23:30:52  POST_BUILD: 6 commands 
[Container] 2019/11/07 23:30:52  INSTALL: 0 commands 
[Container] 2019/11/07 23:30:52  PRE_BUILD: 9 commands 
[Container] 2019/11/07 23:30:52  BUILD: 4 commands 
[Container] 2019/11/07 23:30:52 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED 
[Container] 2019/11/07 23:30:52 Phase context status code:  Message:  
[Container] 2019/11/07 23:30:52 Entering phase INSTALL 
[Container] 2019/11/07 23:30:52 Running command echo "Installing Node.js version 10 ..." 
Installing Node.js version 10 ... 

[Container] 2019/11/07 23:30:52 Running command n 10.16.3 
   installed : v10.16.3 (with npm 6.9.0) 

[Container] 2019/11/07 23:31:02 Phase complete: INSTALL State: SUCCEEDED 
[Container] 2019/11/07 23:31:02 Phase context status code:  Message:  
[Container] 2019/11/07 23:31:02 Entering phase PRE_BUILD 
[Container] 2019/11/07 23:31:02 Running command echo Logging in to Amazon ECR... 
Logging in to Amazon ECR... 

[Container] 2019/11/07 23:31:02 Running command aws --version 
aws-cli/1.16.242 Python/3.6.8 Linux/4.14.143-91.122.amzn1.x86_64 exec-env/AWS_ECS_EC2 botocore/1.12.232 

[Container] 2019/11/07 23:31:07 Running command $(aws ecr get-login --no-include-email --region us-east-1) 
WARNING! Using --password via the CLI is insecure. Use --password-stdin. 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json. 
Configure a credential helper to remove this warning. See 
https://docs.docker.com/engine/reference/commandline/login/#credentials-store 

Login Succeeded 

[Container] 2019/11/07 23:31:10 Running command REPOSITORY_URI=*********** 

[Container] 2019/11/07 23:31:10 Running command COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) 

[Container] 2019/11/07 23:31:10 Running command IMAGE_TAG=${COMMIT_HASH:=latest} 

[Container] 2019/11/07 23:31:10 Running command echo $REPOSITORY_URI 
*********** 

[Container] 2019/11/07 23:31:10 Running command echo $COMMIT_HASH 
88f8cfc 

[Container] 2019/11/07 23:31:10 Running command echo $IMAGE_TAG 
88f8cfc 

[Container] 2019/11/07 23:31:10 Phase complete: PRE_BUILD State: SUCCEEDED 
[Container] 2019/11/07 23:31:10 Phase context status code:  Message:  
[Container] 2019/11/07 23:31:10 Entering phase BUILD 
[Container] 2019/11/07 23:31:10 Running command echo Build started on `date` 
Build started on Thu Nov 7 23:31:10 UTC 2019 

[Container] 2019/11/07 23:31:10 Running command echo Building the Docker image... 
Building the Docker image... 

[Container] 2019/11/07 23:31:10 Running command docker build -t $REPOSITORY_URI:latest . 
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 

[Container] 2019/11/07 23:31:10 Command did not exit successfully docker build -t $REPOSITORY_URI:latest . exit status 1 
[Container] 2019/11/07 23:31:10 Phase complete: BUILD State: FAILED 
[Container] 2019/11/07 23:31:10 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker build -t $REPOSITORY_URI:latest .. Reason: exit status 1 
[Container] 2019/11/07 23:31:10 Entering phase POST_BUILD 
[Container] 2019/11/07 23:31:10 Running command echo Build completed on `date` 
Build completed on Thu Nov 7 23:31:10 UTC 2019 

[Container] 2019/11/07 23:31:10 Running command echo Pushing the Docker images... 
Pushing the Docker images... 

[Container] 2019/11/07 23:31:10 Running command docker push $REPOSITORY_URI:latest 
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 

[Container] 2019/11/07 23:31:10 Command did not exit successfully docker push $REPOSITORY_URI:latest exit status 1 
[Container] 2019/11/07 23:31:10 Phase complete: POST_BUILD State: FAILED 
[Container] 2019/11/07 23:31:10 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker push $REPOSITORY_URI:latest. Reason: exit status 1 
[Container] 2019/11/07 23:31:10 Expanding base directory path: . 
[Container] 2019/11/07 23:31:10 Assembling file list 
[Container] 2019/11/07 23:31:10 Expanding . 
[Container] 2019/11/07 23:31:10 Expanding file paths for base directory . 
[Container] 2019/11/07 23:31:10 Assembling file list 
[Container] 2019/11/07 23:31:10 Expanding imagedefinitions.json 
[Container] 2019/11/07 23:31:10 Skipping invalid file path imagedefinitions.json 
[Container] 2019/11/07 23:31:10 Phase complete: UPLOAD_ARTIFACTS State: FAILED 
[Container] 2019/11/07 23:31:10 Phase context status code: CLIENT_ERROR Message: no matching artifact paths found 

Мы хотим знать, если мы что-то упустили, мы следуем некоторым шагам отсюда:

https://aws.amazon.com/es/blogs/devops/build-a-continuous-delivery-pipeline-for-your-container-images-with-amazon-ecr-as-source/

Любой совет?

1 Ответ

0 голосов
/ 15 ноября 2019

Будет две возможности: -

Во-первых, вы не добавили ecr и ecs в свои роли, которые вы создали для экземпляра ec2, или если вы используете эластичный beanstalk. Сначала убедитесь, что

, иначе посмотрите на эту вторую возможность: - Используйте следующие команды в ваших фазах: -

фазы: установить: команды: - nohup / usr / local / bin / dockerd --host= unix: ///var/run/docker.sock --host = tcp: //127.0.0.1: 2375 --storage-driver = overlay2 & - timeout 15 sh -c "до информации о докере; сделать эхо.; sleep 1; done "

для более подробной информации используйте эту ссылку https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html#sample-docker-custom-image-files

https://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html#troubleshooting-cannot-connect-to-docker-daemon

...