github.com/m3db/m3@v1.5.0/scripts/docker-integration-tests/setup.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -xe
     4  
     5  # expected to be run from root of repository
     6  cd $GOPATH/src/github.com/m3db/m3
     7  
     8  SERVICES=(m3dbnode m3coordinator m3aggregator)
     9  REVISION=$(git rev-parse HEAD)
    10  CLEAN=${CLEAN:-true}
    11  if [[ "$CLEAN" == "true" ]]; then
    12    make clean
    13  fi
    14  mkdir -p ./bin
    15  
    16  # by keeping all the required files in ./bin, it makes the build context
    17  # for docker much smaller
    18  cp ./src/query/config/m3coordinator-local-etcd.yml ./bin
    19  cp ./src/dbnode/config/m3dbnode-local-etcd.yml ./bin
    20  cp ./src/aggregator/config/m3aggregator.yml ./bin
    21  
    22  # build images
    23  echo "building docker images"
    24  
    25  function build_image {
    26    local svc=$1
    27    echo "creating image for $svc"
    28    make ${svc}-linux-amd64
    29    docker build -t "${svc}_integration:${REVISION}" -f ./scripts/docker-integration-tests/${svc}.Dockerfile ./bin
    30  }
    31  
    32  if [[ "$SERVICE" != "" ]]; then
    33    # optionally build just for a single service
    34    build_image $SERVICE
    35  else 
    36    # otherwise build all images
    37    for SVC in ${SERVICES[@]}; do
    38      # only build if image doesn't exist
    39      if [[ "$(docker images -q ${SVC}_integration:${REVISION} 2> /dev/null)" == "" ]]; then
    40        build_image $SVC
    41      fi
    42    done
    43  fi