feat: add openresty proxy implementation

This plugin is mostly compatible with the nginx plugin, but runs the proxy within a docker container. Users do not have direct access to add custom openresty configuration at this time, but instead receive the ability to setup automatic ssl on first request via letsencrypt integration.
This commit is contained in:
Jose Diaz-Gonzalez
2023-08-01 02:16:11 -04:00
parent 5846301a48
commit 625ea14c8f
37 changed files with 1371 additions and 86 deletions

View File

@@ -0,0 +1,55 @@
#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/openresty-vhosts/internal-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
fn-openresty-vhosts-copy-from-image() {
declare APP="$1" IMAGE_NAME="$2" CONF_PATH="$3"
mkdir -p "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP"
rm -f "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes."*
copy_dir_from_image "$IMAGE_NAME" "$CONF_PATH" "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID" || true
if [[ ! -f "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID" ]]; then
touch "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID.missing"
fi
}
fn-openresty-vhosts-copy-from-directory() {
declare APP="$1" SOURCECODE_WORK_DIR="$2" CONF_PATH="$3"
pushd "$SOURCECODE_WORK_DIR" >/dev/null
mkdir -p "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP"
if [[ -z "$CONF_PATH" ]]; then
touch "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID.missing"
return
fi
if [[ ! -d "$CONF_PATH" ]]; then
touch "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID.missing"
return
fi
rm -f "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes."*
mkdir p "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID/"
cp -f "$CONF_PATH"/* "${DOKKU_LIB_ROOT}/data/openresty-vhosts/app-$APP/openresty-http-includes.$DOKKU_PID/"
popd &>/dev/null || pushd "/tmp" >/dev/null
}
trigger-openresty-vhosts-core-post-extract() {
declare desc="openresty-vhosts post-extract plugin trigger"
declare trigger="post-extract"
declare APP="$1" SOURCECODE_WORK_DIR="$2"
local CONF_PATH="openresty-http-includes"
local app_source_image
app_source_image="$(plugn trigger git-get-property "$APP" "source-image")"
if [[ -n "$app_source_image" ]]; then
fn-openresty-vhosts-copy-from-image "$APP" "$app_source_image" "$CONF_PATH"
else
fn-openresty-vhosts-copy-from-directory "$APP" "$SOURCECODE_WORK_DIR" "$CONF_PATH"
fi
}
trigger-openresty-vhosts-core-post-extract "$@"