<file_sep>#!/bin/bash
source /opt/app-root/etc/generate_container_user

set -e

# User settable environment
DOTNET_CONFIGURATION="${DOTNET_CONFIGURATION:-Release}"
DOTNET_STARTUP_PROJECT="${DOTNET_STARTUP_PROJECT:-.}"

# Private environment
DOTNET_FRAMEWORK="netcoreapp1.0"
APP_DLL_NAME="$(basename "$(realpath "${DOTNET_STARTUP_PROJECT}")").dll"
APP_DLL_DIR="${DOTNET_STARTUP_PROJECT}/bin/${DOTNET_CONFIGURATION}/${DOTNET_FRAMEWORK}/publish"

ARG_FILE="arguments.txt"
if [[ -f "${ARG_FILE}" ]]; then
  echo "---> Running application with arguments from file '${ARG_FILE}' ..."
  PROG_ARGS="$(cat ${ARG_FILE})"
  cd "${APP_DLL_DIR}" && exec dotnet "${APP_DLL_NAME}" ${PROG_ARGS}
else
  echo "---> Running application ..."
  cd "${APP_DLL_DIR}" && exec dotnet "${APP_DLL_NAME}"
fi
