Sha256: 469cdda17735e57e9a2adddb227b7a50aabd1c8b798bcda5b8d0ece5dfbefd38

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

#!/bin/bash
MINKE_VERSION="1.13.19"

DOCKER_SOCK="/var/run/docker.sock:/var/run/docker.sock"
NEW_UUID=$(base64 /dev/urandom | tr -d '/+' | head -c 32 | tr '[:upper:]' '[:lower:]')
DOCKER_IMAGE="nicholasjackson/minke:${MINKE_VERSION}"
COMMAND=$*
GEM_VOLUMES=""
SSH_AUTH=""

# Forward keys to docker host
if [[ $1 == "-A" || $2 == "-A" ]]; then
  if [[ "${DOCKER_MACHINE}" != "" ]]; then
    # for docker machine
    SSH_SOCK=boot2docker.$$.ssh.socket
    docker-machine ssh ${DOCKER_MACHINE} -A -S $SSH_SOCK -M -f -n tail -f /dev/null
    AGENT_SOCK=$(docker-machine ssh ${DOCKER_MACHINE} -S $SSH_SOCK echo \$SSH_AUTH_SOCK)
    SSH_AUTH="-e AGENT_SOCK=${AGENT_SOCK}"
  fi

  if [[ "${DOCKER_MACHINE}" == "" ]]; then
    SSH_AUTH="-e AGENT_SOCK=${SSH_AUTH_SOCK}"
  fi
  
  echo "Forwarding SSH Keys: ${SSH_AUTH}"
fi

# Test if interactive terminal and set the flag
[[ -t 1 ]] && IT="-it" || IT=""

if [[ $1 != \generate* ]]; then
  # Test if we need to mount any special volumes for paths specified in the Gemfile
  while read -r line; do
		if [[ $line != \#* ]]; then
			l=$(echo $line | sed "s/.*:path *=> *//" | sed "s/['|\"]\(.*\)['|\"]/\1/")
 			GEM_VOLUMES="${GEM_VOLUMES} -v $l:$l"
		fi
  done < <(grep :path Gemfile)

  DIR=$(dirname `pwd`)
  DOCKER_RUN="docker run ${IT} --rm --net=minke_${NEW_UUID} ${SSH_AUTH} ${GEM_VOLUMES} -v ${DOCKER_SOCK} -v ${DIR}:${DIR} -e BUNDLE_PATH=${PWD}/vendor -e BUNDLE_JOBS=2 -e DOCKER_NETWORK=minke_${NEW_UUID} -w ${DIR}/_minke ${DOCKER_IMAGE} ${COMMAND}"

  echo "Running command: minke ${COMMAND}"
  id=$(docker network create minke_${NEW_UUID})
  eval "${DOCKER_RUN}"
  id=$(docker network rm minke_${NEW_UUID})
  
  if [[ "${DOCKER_MACHINE}" != "" ]]; then
    # Clean up socket
    docker-machine ssh default -S $SSH_SOCK -O exit
  fi
fi

if [[ $1 = \generate* ]]; then
  DIR=$(pwd)
  DOCKER_RUN="docker run --rm -v ${DOCKER_SOCK} -v ${DIR}:${DIR} -w ${DIR}:${DIR} ${DOCKER_IMAGE} ${COMMAND}"
  eval "$DOCKER_RUN"
fi

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minke-1.13.19 lib/minke/scripts/minke