Skip to content

Commit

Permalink
Merge pull request #7 from michaelshobbs/mh-use-opsworks-info
Browse files Browse the repository at this point in the history
extract opsworks stack name and prepend it to hostname
  • Loading branch information
michaelshobbs committed Apr 12, 2016
2 parents cdf360b + 4d82d17 commit a196693
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ dokku plugin:install https://github.com/michaelshobbs/dokku-hostname.git dokku-h

## hooks

This plugin provides hooks:
This plugin provides the following triggers:

* `docker-args-build`: adds the `--hostname` env var to the host's `hostname`
* `docker-args-deploy`: adds the `--hostname` env var to the host's `hostname`
* `docker-args-run`: adds the `--hostname` env var to the host's `hostname`
* `docker-args-build`: adds the `--hostname` env var to the host's `hostname` or (if available) the AWS OpsWorks stack name + - + `hostname`
* `docker-args-deploy`: adds the `--hostname` env var to the host's `hostname` or (if available) the AWS OpsWorks stack name + - + `hostname`
* `docker-args-run`: adds the `--hostname` env var to the host's `hostname` or (if available) the AWS OpsWorks stack name + - + `hostname`
7 changes: 6 additions & 1 deletion docker-args
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ if [[ "$IMAGE_SOURCE_TYPE" == "dockerfile" ]] && [[ "$0" == *build ]]; then
echo -n "$STDIN"
else
STDIN=$(cat)
HOSTNAME=$(hostname)
OPSWORKS_STACK_NAME=$(grep "OpsWorks Stack:" /etc/motd 2>/dev/null || true)
if [[ -n "$OPSWORKS_STACK_NAME" ]]; then
HOSTNAME=$(echo "$OPSWORKS_STACK_NAME" "$(hostname)" | awk -F: '{ print $2 }' | xargs | tr '[:upper:]' '[:lower:]' | sed -e 's: :-:g')
else
HOSTNAME=$(hostname)
fi
echo -n "$STDIN --hostname=${HOSTNAME}"
fi
2 changes: 1 addition & 1 deletion plugin.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[plugin]
name = "dokku-hostname"
description = "Sets the docker hostname option for dokku"
version = "0.1.0"
version = "0.2.0"
website_url = "https://github.com/michaelshobbs/dokku-hostname"
[plugin.config]

0 comments on commit a196693

Please sign in to comment.