version: 2
jobs:
  build:
    docker: # run the steps with Docker

      - image: circleci/golang:1.15
        auth:
          username: javamachr
          password: $DOCKERHUB_PASSWORD
    steps:
      - checkout # check out source code to working directory

      - setup_remote_docker:
          version: 19.03.13
          docker_layer_caching: false

      - restore_cache:
          keys:
            - go-mod-v4-{{ checksum "go.sum" }}

      - run:
          name: Install requirements
          command: make install-requirements

      - run:
          name: Generate sources
          command: make generate

      - run:
          name: Docker login
          command: make docker-login

      - run:
          name: Build docker images
          command: make docker-images

      - run:
          name: Build docker images
          command: make docker-images

      - run:
          name: Push docker images
          command: make docker-push