#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"

nginx_build_config() {
  declare desc="build nginx config to proxy app containers from command line"
  declare APP="$1"
  [[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"

  if [[ "$(get_app_proxy_type "$1")" = "nginx" ]]; then
    plugn trigger network-build-config "$APP"
    nginx_build_config "$APP"
  fi
}

nginx_build_config_cmd "$@"
