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:
@@ -506,6 +506,63 @@ copy_from_image() {
|
||||
fi
|
||||
}
|
||||
|
||||
copy_dir_from_image() {
|
||||
declare desc="copy a directory from named image to destination"
|
||||
declare IMAGE="$1" SRC_DIR="$2" DST_DIR="$3"
|
||||
local WORK_DIR=""
|
||||
|
||||
local DOCKER_CREATE_LABEL_ARGS="--label=com.dokku.app-name=$APP"
|
||||
|
||||
if verify_image "$IMAGE"; then
|
||||
if ! is_abs_path "$SRC_DIR"; then
|
||||
if is_image_cnb_based "$IMAGE"; then
|
||||
WORKDIR="/workspace"
|
||||
elif is_image_herokuish_based "$IMAGE" "$APP"; then
|
||||
WORKDIR="/app"
|
||||
else
|
||||
WORKDIR="$("$DOCKER_BIN" image inspect --format '{{.Config.WorkingDir}}' "$IMAGE")"
|
||||
fi
|
||||
|
||||
if [[ -n "$WORKDIR" ]]; then
|
||||
SRC_DIR="${WORKDIR}/${SRC_DIR}"
|
||||
fi
|
||||
fi
|
||||
|
||||
TMP_DIR_COMMAND_OUTPUT=$(mktemp -d "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
|
||||
trap "rm -rf '$TMP_DIR_COMMAND_OUTPUT' &>/dev/null || true" RETURN
|
||||
|
||||
local CID=$("$DOCKER_BIN" container create "${DOCKER_CREATE_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS "$IMAGE")
|
||||
"$DOCKER_BIN" container cp "$CID:$SRC_DIR" "$TMP_DIR_COMMAND_OUTPUT" 2>/dev/null || true
|
||||
"$DOCKER_BIN" container rm --force "$CID" &>/dev/null
|
||||
plugn trigger scheduler-register-retired "$APP" "$CID"
|
||||
|
||||
# docker cp exits with status 1 when run as non-root user when it tries to chown the file
|
||||
# after successfully copying the file. Thus, we suppress stderr.
|
||||
# ref: https://github.com/dotcloud/docker/issues/3986
|
||||
if [[ ! -d "$TMP_DIR_COMMAND_OUTPUT" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
pushd "$TMP_DIR_COMMAND_OUTPUT" >/dev/null
|
||||
for filename in *; do
|
||||
if [[ ! -f "$TMP_DIR_COMMAND_OUTPUT/$filename" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# workaround for CHECKS file when owner is root. seems to only happen when running inside docker
|
||||
dos2unix -l <"$TMP_DIR_COMMAND_OUTPUT/$filename" >"$DST_DIR/$filename"
|
||||
|
||||
# add trailing newline for certain places where file parsing depends on it
|
||||
if [[ "$(tail -c1 "$DST_DIR/$filename")" != "" ]]; then
|
||||
echo "" >>"$DST_DIR/$filename"
|
||||
fi
|
||||
done
|
||||
popd &>/dev/null || pushd "/tmp" >/dev/null
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_app_container_ids() {
|
||||
declare desc="returns list of docker container ids for given app and optional container_type"
|
||||
local APP="$1"
|
||||
|
||||
Reference in New Issue
Block a user