actually merge dokku-app-user into core

This commit is contained in:
Michael Hobbs
2016-08-26 10:50:01 -07:00
parent 6e4ad6311b
commit 204031306f
6 changed files with 49 additions and 2 deletions

View File

@@ -256,7 +256,7 @@ The following plugins have been removed as their functionality is now in Dokku C
| Plugin | Author | In Dokku Since |
| ------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------- |
| [App User](https://github.com/michaelshobbs/dokku-app-user) | [michaelshobbs][] | v0.7.0 (herokuish 0.3.18) |
| [App User](https://github.com/michaelshobbs/dokku-app-user) | [michaelshobbs][] | v0.7.1 (herokuish 0.3.18) |
| [Custom Domains](https://github.com/neam/dokku-custom-domains) | [motin][] | v0.3.10 (domains plugin) |
| [Debug](https://github.com/heichblatt/dokku-debug) | [heichblatt][] | v0.3.9 (trace command) |
| [Docker Options](https://github.com/dyson/dokku-docker-options) | [dyson][] | v0.3.17 (docker-options plugin) |

2
dokku
View File

@@ -37,7 +37,7 @@ export DOKKU_LOGS_DIR=${DOKKU_LOGS_DIR:="/var/log/dokku"}
export DOKKU_EVENTS_LOGFILE=${DOKKU_EVENTS_LOGFILE:="$DOKKU_LOGS_DIR/events.log"}
export DOKKU_CONTAINER_LABEL=dokku
export DOKKU_GLOBAL_RUN_ARGS="--label=$DOKKU_CONTAINER_LABEL --env=USER=herokuishuser"
export DOKKU_GLOBAL_RUN_ARGS="--label=$DOKKU_CONTAINER_LABEL"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
app_user_docker_args() {
local APP="$1"
local STDIN
local DOKKU_APP_TYPE
local DOKKU_APP_USER
STDIN=$(cat)
DOKKU_APP_TYPE=$(config_get "$APP" DOKKU_APP_TYPE || true)
DOKKU_APP_USER=$(config_get "$APP" DOKKU_APP_USER || true)
DOKKU_APP_USER=${DOKKU_APP_USER:="herokuishuser"}
if [[ "$DOKKU_APP_TYPE" == "herokuish" ]]; then
local docker_args="$STDIN --env=USER=${DOKKU_APP_USER}"
else
local docker_args="$STDIN"
fi
echo -n "$docker_args"
}
app_user_docker_args "$@"

View File

@@ -0,0 +1 @@
docker-args-build

View File

@@ -0,0 +1 @@
docker-args-build

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/00_dokku-standard/exec-app-json-scripts"
exec_app_json_scripts() {
@@ -12,4 +13,23 @@ exec_app_json_scripts() {
execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY"
}
app_user_pre_deploy_trigger() {
local desc="app user pre-deploy trigger"
local APP="$1"; local IMAGE_TAG="$2"; local IMAGE; local DOCKER_ARGS
local DOKKU_APP_USER; local APP_PATHS; local CONTAINER_PATHS
IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG")
DOKKU_APP_USER=$(config_get "$APP" DOKKU_APP_USER || true)
APP_PATHS=$(dokku --quiet storage:list "$APP" || true)
if [[ -n "$APP_PATHS" ]]; then
CONTAINER_PATHS=$(echo "$APP_PATHS" | awk -F ':' '{ print $2 }' | xargs)
DOCKER_ARGS=$(: | plugn trigger docker-args-deploy "$APP" "$IMAGE_TAG" | xargs)
fi
if [[ -n "$DOKKU_APP_USER" ]] && [[ -n "$CONTAINER_PATHS" ]]; then
# shellcheck disable=SC2086
docker run $DOKKU_GLOBAL_RUN_ARGS $DOCKER_ARGS $IMAGE /bin/bash -c "find $CONTAINER_PATHS -not -user $DOKKU_APP_USER -print0 | xargs -0 -r chown -R $DOKKU_APP_USER" || true
fi
}
exec_app_json_scripts "$@"
app_user_pre_deploy_trigger "$@"