version: 2
jobs:
  test:
    docker:
      - image: python:2.7-alpine3.7
    steps:
      - run:
          name: Setup environment
          command: apk add --no-cache --no-progress build-base git libffi-dev openssh openssl-dev
      - checkout
      - run:
          name: Setup Python environment
          command: |
            pip install virtualenv
            virtualenv env

      - restore_cache:
          keys:
            - pip-v1-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/test.txt" }}
      - run:
          name: Install dependencies
          command: |
            source env/bin/activate
            pip install --requirement requirements.txt --requirement requirements/test.txt
      - save_cache:
          key: pip-v1-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/test.txt" }}
          paths:
            - "~/.cache/pip"

      - run:
          name: Run unit tests
          command: |
            source env/bin/activate
            python manage.py test
workflows:
  version: 2
  build_and_test:
    jobs:
      - test

version: 2
jobs:
  build:
    docker:
      - image: docker:18-git
    environment:
      CLA_DOCKER_REGISTRY: "cla-registry.dsd.io"
      APP_NAME: "cla_public"
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Build Docker image
          command: docker build --tag $CLA_DOCKER_REGISTRY/$APP_NAME:$CIRCLE_SHA1 .

  test:
    docker:
      - image: python:2.7-alpine3.7
    steps:
      - run:
          name: Setup environment
          command: apk add --no-cache --no-progress build-base git libffi-dev openssh openssl-dev
      - checkout
      - run:
          name: Setup Python environment
          command: |
            pip install virtualenv
            virtualenv env

      - restore_cache:
          keys:
            - pip-v1-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/test.txt" }}
      - run:
          name: Install dependencies
          command: |
            source env/bin/activate
            pip install --requirement requirements.txt --requirement requirements/test.txt
      - save_cache:
          key: pip-v1-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/test.txt" }}
          paths:
            - "~/.cache/pip"

      - run:
          name: Run unit tests
          command: |
            source env/bin/activate
            python manage.py test

workflows:
  version: 2
  build_and_test:
    jobs:
      - test
      - build

Add Docker build to CircleCI workflow
Add Docker build to CircleCI workflow
