#!/usr/bin/env bash

MASTER3_REGISTRY=registry.gitlab.takima.io
M3PRESS_IMAGE=${MASTER3_REGISTRY}/oabdelnour/es06-epf/m3-press:latest
function main() {

  case "$1" in
    build)
      build ${@:2}
      ;;
    dev)
      dev ${@:2}
      ;;
    *)
      help
      ;;
  esac
  }

function help() {
  echo "Usage: precise the mode (dev or build) and the /docs folder path, ex :  'sh $0 build|dev <docsDir>'"
}

function build() {
  docker pull ${M3PRESS_IMAGE} || (docker login ${MASTER3_REGISTRY} && docker pull ${M3PRESS_IMAGE})
  docker run -it --rm \
    -v $(pwd):/app \
    -p8085:8085 \
    ${M3PRESS_IMAGE} build $@
}


function dev() {
  docker pull ${M3PRESS_IMAGE} || (docker login ${MASTER3_REGISTRY} && docker pull ${M3PRESS_IMAGE})
  docker run -it --rm \
    -v $(pwd):/app \
    -p8085:8085 \
    ${M3PRESS_IMAGE} dev $@
}


main $@
