#!/bin/bash
set -e

# Where there is no arguments supplied that means its trying to invoke the base
# image, so we are not going to do anything on startup
if [ $# -eq 0 ]; then
    echo "Finalizing Base"
  else
    echo "Starting .."

    if [ ! -d "/app/node_modules" ]; then
      # This is a proxy entrypoint to copy the node packages to the app directory
      echo "Node modules not found, copying source node modules"

      cp -r /usr/src/app/node_modules/. /app/node_modules/
    else
      echo "Node modules found, starting... if you want to install the node modules
      fresh from build you can delete the ./node_modules directory and run again"
    fi
fi

docker-entrypoint.sh $@
