Sha256: 482042140db8434e80511d5d45012cd4a51b43cb96ac39470b8ba6fd0086688a

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

#! /usr/bin/env sh

NAMETAG="json-api-toolbox:dev"
COMMAND=${1:-help}
shift

command_help() {
    echo "
Usage:  docker COMMAND [code]

A simple script to control the project container

Commands:
  run                      Run [code] on a new container
  exec                     Run [code] on the current active container
  build                    Build the project image
  help                     Show this help message
"
}

command_build() {
    docker build -t $NAMETAG --ssh=default . 
}

config_ssh_agent() {
  if [ uname == "Darwin" ]; then
    AUTH_PATH="/run/host-services/ssh-auth.sock"
  else 
    AUTH_PATH=$(echo $SSH_AUTH_SOCK)
  fi

  echo "-v $(echo $HOME)/.ssh:/root/.ssh \
        -v $(echo $AUTH_PATH):/ssh-agent \
        -e SSH_AUTH_SOCK=/ssh-agent \
  "
}

command_run() {
    [[ $1 == "--build" ]] && { command_build; shift; }

    docker volume create bundler_cache > /dev/null
    docker run -it \
               -v bundler_cache:/usr/local/bundle \
               -v $(pwd):/gem \
               $(config_ssh_agent) \
               $NAMETAG
               $@
}

command_exec() {
    [[ $1 == "--build" ]] && { command_build; shift; }

    docker exec $NAMETAG $@
}

case $COMMAND in
  build) command_build "$@" ;;
  exec)  command_exec  "$@" ;;
  run)   command_run   "$@" ;;
  *)     command_help  "$@" ;;
esac

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_api_toolbox-3.0.0 bin/docker
json_api_toolbox-2.1.0 bin/docker
json_api_toolbox-2.0.1 bin/docker