1

我正在 CircleCI 上构建我的项目,并且我的构建工作如下所示:

  build:
    <<: *defaults
  steps:
    - checkout
    - setup_remote_docker
    - run:
        name: Install pip
        command: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && sudo python get-pip.py
    - run:
        name: Install AWS CLI
        command: curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" && unzip awscli-bundle.zip && sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
    - run:
        name: Login to Docker Registry
        command: aws ecr get-login --no-include-email --region us-east-1 | sh
    - run:
        name: Install Dep
        command: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
    - run:
        name: Save Version Number
        command: echo "export VERSION_NUM=${CIRCLE_TAG}.${CIRCLE_BUILD_NUM}" > deployment/dev/.env
    - run:
        name: Build App
        command: source deployment/dev/.env && docker-compose -f deployment/dev/docker-compose.yml build
    - run:
        name: Test App
        command: |
          git config --global url."https://${GITHUB_PERSONAL_ACCESS_TOKEN} :x-oauth-basic@github.com/".insteadOf "https://github.com/"
          dep ensure
          go test -v ./...
    - run:
        name: Push Image
        command: |
          if [[ "${CIRCLE_TAG}" =~ ^v[0.9]+(\.[0-9]+)*-[a-z]*$ ]]; then
            source deployment/dev/.env
            docker-compose -f deployment/dev/docker-compose.yml push
          else
            echo 'No tag, not deploying'
          fi
    - persist_to_workspace:
        root: .
        paths:
          - deployment/*
          - tools/*

当我将更改推送到分支时,每次构建都会失败,Couldn't connect to Docker daemon at ... - is it running?因为它到达构建作业的构建应用程序步骤。

请帮我弄清楚为什么分支构建失败但标签构建没有。

4

2 回答 2

2

我怀疑你遇到了这个 docker-compose 错误:https ://github.com/docker/compose/issues/6050

当 docker-compose 文件中的图像名称无效时,该错误会报告一个误导性错误(您得到的错误)。

如果您使用环境变量作为图像名称或图像标签,并且该变量是从分支名称设置的,那么它会在某些分支上失败,但在其他分支上不会。

于 2018-08-22T02:16:27.440 回答
0

问题发生在Save Version Number台阶上。有时该版本会是.${CIRCLE_BUILD_NUM}因为没有通过任何标签。Docker 不喜欢这些.以.CIRCLE_TAGv0.1.0-build

于 2018-08-22T19:48:55.223 回答