Sha256: 893fdc4d223c829ea4c6bdc451ba91cdcbb14a366570c8dcc95a835ca536074a

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

#!/bin/bash
MINKE_VERSION="1.13.3"
ERROR="Please specify a command e.g. ./minke --help"

DOCKER_SOCK="/var/run/docker.sock:/var/run/docker.sock"
NEW_UUID=$(base64 /dev/urandom | tr -d '/+' | head -c 32 | tr '[:upper:]' '[:lower:]')

GEMSET=$(<.ruby-gemset)
LEN=$(echo ${#GEMSET})

if [ $LEN -lt 1 ]; then
  GEMSET='minkegems'
fi

GEMSETFOLDER="/usr/local/rvm/gems/ruby-2.3.1@${GEMSET}"
RVM_COMMAND="source /usr/local/rvm/scripts/rvm && rvm gemset use ${GEMSET} --create"
DOCKER_IMAGE="nicholasjackson/minke:${MINKE_VERSION}"
COMMAND=""


if [ "$1" == '' ]; then
  echo $ERROR;
  exit 1;
fi

COMMAND=$*

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

if [[ $1 == "generate" ]] || [[ $2 == "generate" ]]; then
  echo "Generating new template"
  DIR=${PWD}
  DOCKER_RUN="docker run --rm -v ${DOCKER_SOCK} -v ${DIR}:${DIR} -v ${DIR}/_build/vendor/gems:${GEMSETFOLDER} -e DOCKER_NETWORK=minke_${NEW_UUID} -w ${DIR} ${DOCKER_IMAGE} /bin/bash -c '${RVM_COMMAND} && bundle install && minke ${COMMAND}'"
  eval "${DOCKER_RUN}"
fi

if [[ $1 != "generate" ]] || [[ $2 != "generate" ]]; then
  DIR=$(dirname `pwd`)
  DOCKER_RUN="docker run --rm ${IT} --net=minke_${NEW_UUID} -v ${DOCKER_SOCK} -v ${DIR}:${DIR} -v ${DIR}/_build/vendor/gems:${GEMSETFOLDER} -e DOCKER_NETWORK=minke_${NEW_UUID} -w ${DIR}/_build ${DOCKER_IMAGE} /bin/bash -c '${RVM_COMMAND} && minke ${COMMAND}'"

  echo "Running command: minke ${COMMAND}"

  eval "docker network create minke_${NEW_UUID}"
  echo "${DOCKER_RUN}"
  eval "docker network rm minke_${NEW_UUID}"
fi

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minke-1.13.3 lib/minke/scripts/minke