# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
  build:
    docker:
      # specify the version
      - image: circleci/golang:1.9

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    #### TEMPLATE_NOTE: go expects specific checkout path representing url
    #### expecting it in the form of
    ####   /go/src/github.com/circleci/go-tool
    ####   /go/src/bitbucket.org/circleci/go-tool
    working_directory: /go/src/github.com/halla/golang-docker-circleci-example
    steps:
      - checkout

      # specify any bash command here prefixed with `run: `
      - run: go get -v -t -d ./...
      - run: go test -v ./...
      - deploy:
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              docker login -u $DOCKER_USER -p $DOCKER_PASS
              docker push $DOCKER_REPO:$CIRCLE_SHA1
              docker push $DOCKER_REPO:latest                        
            fi

# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
  build:
    docker:
      # specify the version
      - image: circleci/golang:1.9

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    #### TEMPLATE_NOTE: go expects specific checkout path representing url
    #### expecting it in the form of
    ####   /go/src/github.com/circleci/go-tool
    ####   /go/src/bitbucket.org/circleci/go-tool
    working_directory: /go/src/github.com/halla/golang-docker-circleci-example
    steps:
      - checkout
      - setup_remote_docker:   # (2)
          docker_layer_caching: true # (3)

      # specify any bash command here prefixed with `run: `
      - run: go get -v -t -d ./...
      - run: go test -v ./...
      - deploy:
          name: Install Docker client
          command: |
            set -x
            VER="17.07.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin
      - deploy:
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
              docker push ${DOCKER_REPO}:${CIRCLE_SHA1}
            fi

Install docker inside deployment container
Install docker inside deployment container
