Gradle with Docker plugin on 2.0


#1

Hi everyone, I recently moved one of my projects from 1.0 to 2.0. My setup is JDK8, I use CircleCI-provided image as build environment. Below is my config:

version: 2
jobs:
  build:
    environment:
      IMAGE_NAME: <image>
      DOCKER_ADDRESS: <acctid>.dkr.ecr.us-east-1.amazonaws.com
      TERM: dumb
    docker:
      - image: circleci/openjdk:8-jdk
    steps:
      - checkout
      - run:
          name: Install AWS-CLI
          command: |
            sudo apt-get update && sudo apt-get install -y python-setuptools python python-pip
            sudo pip install awscli
      - setup_remote_docker
      - restore_cache:
          keys:
            - gradle-cache-{{ .Branch }}-{{ checksum "build.gradle" }}
      - run:
          name: Install gradle dependencies
          command: |
            ./gradlew dependencies
      - run:
          name: Run gradle build
          command: |
            eval $(aws ecr get-login --region us-east-1 --no-include-email)
            ./gradlew versionTxt
            ./gradlew dockerBuildImage
            docker push $DOCKER_ADDRESS/$IMAGE_NAME:`cat VERSION`
      - save_cache:
          key: gradle-cache-{{ .Branch }}-{{ checksum "build.gradle" }}
          paths:
            - ~/.gradle
  deploy-staging:
    machine:
      enabled: true
    environment:
      SERVICE_NAME: <image>
      IMAGE_NAME: <image>
      DEPLOYMENT_NAME: <image>
      CONTAINER_NAME: <image>
      DOCKER_ADDRESS: <acct>.dkr.ecr.us-east-1.amazonaws.com
      TERM: dumb
    steps:
      - checkout
      - run:
          name: Install AWS-CLI
          command: |
            apt-get update && apt-get install -y python-pip
            pip install awscli
      - run:
          name: Install kubernetes-cli
          command: |
            wget https://storage.googleapis.com/kubernetes-release/release/v1.6.1/bin/linux/amd64/kubectl && sudo mv kubectl /usr/bin && sudo chmod +x /usr/bin/kubectl
            wget https://github.com/kubernetes/kops/releases/download/1.6.1/kops-linux-amd64 && chmod +x kops-linux-amd64 && sudo mv kops-linux-amd64 /usr/bin/kops
      - run:
          command: |
            eval $(aws ecr get-login --region us-east-1 --no-include-email)
            ./gradlew versionTxt
            docker pull $DOCKER_ADDRESS/$IMAGE_NAME:$CIRCLE_SHA1
            docker tag $DOCKER_ADDRESS/$IMAGE_NAME:`cat VERSION` $DOCKER_ADDRESS/$IMAGE_NAME:staging
            docker push $DOCKER_ADDRESS/$IMAGE_NAME:staging
            kops export <clustername>
            HTTP_HOST=<hostname> VERSION=$CIRCLE_SHA1 NAMESPACE=staging ENV=staging envsubst < deployment/deployment.template.yml > deployment/deployment.yml
            kubectl -n staging apply -f deployment/deployment.yml
workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy-staging:
          requires:
            - build
          filters:
            branches:
              only: staging

While building I get the following:

[dockerjava-jaxrs-async-0] INFO org.apache.http.impl.execchain.RetryExec - I/O exception (java.net.SocketException) caught when processing request to {}->http://35.196.15.83:2376: Connection reset
[dockerjava-jaxrs-async-0] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
org.apache.http.client.ClientProtocolException

I guess 35.196.15.83:2376 is the address of the remote docker daemon so I’m not really sure what’s wrong about it and how to go on with that.

Please help, don’t want to fallback to 1.0 for this as my builds are much faster with 2.0

Thanks in advance!


#2

Ok I managed to fix these by adding these 2 lines to docker closure on my build.gradle:

url = System.env.DOCKER_HOST
certPath = new File(System.env.DOCKER_CERT_PATH)

#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.