From 077b7cee6e017d1d4e2893638745f6a724cd0fc2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 19 Mar 2015 20:04:48 -0400 Subject: [PATCH 01/22] Set dokku version during post installation --- debian/postinst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/postinst b/debian/postinst index 25965e1dd..231c1a20d 100755 --- a/debian/postinst +++ b/debian/postinst @@ -13,6 +13,8 @@ case "$1" in egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku dokku plugins-install + rm -f /home/dokku/VERSION + cp /var/lib/dokku/STABLE_VERSION /home/dokku/VERSION if [ -f /etc/init/dokku-installer.conf ] && service dokku-installer status 2> /dev/null | grep waiting; then sudo service dokku-installer start From 6f52853049799dd30cd214f96ec9a22afd4fbd2a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 19 Mar 2015 20:05:25 -0400 Subject: [PATCH 02/22] Ensure we always have apt-transport-https available On certain distributions, this package is not automatically installed --- deb.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deb.mk b/deb.mk index 6e3f5917d..068969520 100644 --- a/deb.mk +++ b/deb.mk @@ -29,6 +29,10 @@ GOPATH = /home/vagrant/gocode .PHONY: install-from-deb deb-all deb-buildstep deb-dokku deb-gems deb-pluginhook deb-setup deb-sshcommand install-from-deb: + echo "--> Initial apt-get update" + sudo apt-get update > /dev/null + sudo apt-get install -y apt-transport-https + echo "--> Installing docker gpg key" curl --silent https://get.docker.io/gpg 2> /dev/null | apt-key add - 2>&1 >/dev/null @@ -43,7 +47,7 @@ install-from-deb: sudo apt-get update > /dev/null echo "--> Installing pre-requisites" - sudo apt-get install -y linux-image-extra-`uname -r` apt-transport-https + sudo apt-get install -y linux-image-extra-`uname -r` echo "--> Installing dokku" sudo apt-get install -y dokku From aee8ada6d086d093fe49ccb05cfbcdfc3caf8954 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 19 Mar 2015 20:07:32 -0400 Subject: [PATCH 03/22] Copy the public key into place instead of moving it This gets around reprovisioning issues --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index a2a4e7d9c..ba7b7352a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -53,6 +53,6 @@ Vagrant::configure("2") do |config| if Pathname.new(PUBLIC_KEY_PATH).exist? config.vm.provision :file, source: PUBLIC_KEY_PATH, destination: '/tmp/id_rsa.pub' - config.vm.provision :shell, :inline => "rm /root/.ssh/authorized_keys && mv /tmp/id_rsa.pub /root/.ssh/authorized_keys" + config.vm.provision :shell, :inline => "rm -f /root/.ssh/authorized_keys && cp /tmp/id_rsa.pub /root/.ssh/authorized_keys" end end From 95ae41b2fd2986b26c34aa257b75398af359159f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 19 Mar 2015 21:08:31 -0400 Subject: [PATCH 04/22] Switch all gpg key retrieval to use docker.com --- Makefile | 2 +- contrib/stackscript.sh | 2 +- deb.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0083ae5d3..5497eb032 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ docker: aufs apt-get install -qq -y curl egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku - curl --silent https://get.docker.io/gpg | apt-key add - + curl --silent https://get.docker.com/gpg | apt-key add - echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list apt-get update ifdef DOCKER_VERSION diff --git a/contrib/stackscript.sh b/contrib/stackscript.sh index 7650176b2..4d9ace16b 100644 --- a/contrib/stackscript.sh +++ b/contrib/stackscript.sh @@ -137,7 +137,7 @@ function install_prerequisites { sudo apt-get install -qq -y curl > /dev/null 2>&1 logit "Installing docker gpg key" - curl --silent https://get.docker.io/gpg 2> /dev/null | apt-key add - > /dev/null 2>&1 + curl --silent https://get.docker.com/gpg 2> /dev/null | apt-key add - > /dev/null 2>&1 logit "Installing dokku gpg key" curl --silent https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - > /dev/null 2>&1 diff --git a/deb.mk b/deb.mk index 068969520..c10fdb89f 100644 --- a/deb.mk +++ b/deb.mk @@ -34,7 +34,7 @@ install-from-deb: sudo apt-get install -y apt-transport-https echo "--> Installing docker gpg key" - curl --silent https://get.docker.io/gpg 2> /dev/null | apt-key add - 2>&1 >/dev/null + curl --silent https://get.docker.com/gpg 2> /dev/null | apt-key add - 2>&1 >/dev/null echo "--> Installing dokku gpg key" curl --silent https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - 2>&1 >/dev/null From af626069dd5db32c9306549085571677eea3da6c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 25 Mar 2015 01:03:51 -0400 Subject: [PATCH 05/22] Release 0.3.16 --- HISTORY.md | 48 ++++++++++++++++++++++++++++++++++++++ README.md | 2 +- contrib/dokku-installer.rb | 2 +- docs/installation.md | 2 +- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 5353e30bc..6be8b8bbe 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,53 @@ # History +## 0.3.16 + +- #974: @michaelhobbs Don't use set to guard against pipefail +- #975: @michaelhobbs Simplify SSL hostname handling and avoid overwriting variables. refs #971 +- #978: @michaelhobbs Add apparmor and cgroup-lite as pre-dependencies for dokku debian package +- #980: @josegonzalez [docs] Add documentation for pluginhooks +- #981: @josegonzalez Remove old files +- #982: @josegonzalez [docs] Add documentation for existing clients. Closes #977 +- #983: @josegonzalez [docs] Update installation documentation +- #984: @josegonzalez [docs] Clarify installation instructions +- #988: @josegonzalez [docs] Add deprecated plugins section and where to get help +- #989: @josegonzalez [docs] Add more clients +- #986: @josegonzalez Switch to yabawock's static nginx buildpack for tests +- #987: @techniq Improve Dockerfile example/test +- #967: @alessio Really clean-up containers and images a-la-Docker +- #992: @josegonzalez [docs] Fix digital ocean docs. Closes #991 +- #994: @alessio Fix quoting in container termination. Closes #249 +- #996: @pmvieira [docs] Minor typo fix in the pluginhooks documentation +- #1003: @michaelhobbs Remove quoting around cleanup and disable lint for those lines +- #1001: @sekjun9878 [docs] Add sekjun9878/dokku-redis-plugin to plugins.md +- #1004: @michaelhobbs Remove quoting from dockerfile env. closes #1002 +- #1018: @michaelhobbs Confine arg shifting to between dokku and command. closes #1017 +- #1022: @Flink [docs] Add dokku-maintenance to plugins +- #1008: @lmars Support multiple domains using a wildcard TLS certificate +- #1013: @lmars Fix URL schemes in `dokku urls` output +- #1027: @nickstenning [docs] Add webhooks plugin to documentation +- #1026: @michaelhobbs Ensure we have newlines around our config. closes #1025 +- #1010: @michaelhobbs Don't run create/destroy twice in tests +- #1028: @Flink [docs] Add rails-logs to plugins +- #1031: @michaelhobbs Upgrade docker in CI to 1.5.0 +- #1029: @assaf Added several enhancements for CHECKS file: + - Specify how long to wait before running first check + - Specify timeout for each check + - Check specific hosts, e.g. http://signin.example.com + - Check both HTTP and HTTPS resources +- #1032: @cameron-martin Updated dokku-installer to use relative path +- #1035: @Flink [docs] Add dokku-http-auth to plugins +- #1040: @ebeigarts [docs] Add dokku-slack plugin information +- #1038: @michaelhobbs Default container check. closes #1020 +- #1036: @michaelhobbs Create config set/unset without restart. closes #908 +- #1009: @michaelhobbs Extract first port from Dockerfile and set config variable for use in deploy phase. closes #993 +- #1042: @michaelhobbs Update to Support xip.io wildcard DNS as a VHOST +- #1043: @michaelhobbs Use upstart config from docker docs. closes #1015 +- #1047: @michaelhobbs Show logs on deploy success and failure +- #1049: @ebeigarts [docs] Change Slack Notifications link +- #1051: @Flink [docs] Add dokku-airbrake-deploy to plugins +- #1057: @josegonzalez Updated deb packaging + ## 0.3.15 - #950: @michaelhobbs Do not count blank lines in `make count` diff --git a/README.md b/README.md index f736b5358..419d8c46c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. S To install the latest stable release, you can run the following command as a user that has access to `sudo`: - wget -qO- https://raw.github.com/progrium/dokku/v0.3.15/bootstrap.sh | sudo DOKKU_TAG=v0.3.15 bash + wget -qO- https://raw.github.com/progrium/dokku/v0.3.16/bootstrap.sh | sudo DOKKU_TAG=v0.3.16 bash ### Upgrading diff --git a/contrib/dokku-installer.rb b/contrib/dokku-installer.rb index 4b14c3f2c..2497ad95e 100755 --- a/contrib/dokku-installer.rb +++ b/contrib/dokku-installer.rb @@ -21,7 +21,7 @@ if ARGV[0] == "onboot" exit end -version = "v0.3.15" +version = "v0.3.16" dokku_root = ENV["DOKKU_ROOT"] || "/home/dokku" admin_key = `cat /root/.ssh/authorized_keys`.split("\n").first hostname = `bash -c '[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME || curl icanhazip.com'`.strip diff --git a/docs/installation.md b/docs/installation.md index ca0eca8db..270fbe657 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -12,7 +12,7 @@ To install the latest stable version of dokku, you can run the following bootstr ```shell # This may need to be run twice -wget -qO- https://raw.github.com/progrium/dokku/v0.3.15/bootstrap.sh | sudo DOKKU_TAG=v0.3.15 bash +wget -qO- https://raw.github.com/progrium/dokku/v0.3.16/bootstrap.sh | sudo DOKKU_TAG=v0.3.16 bash # Install the web installer. See `Configuring` under # `Advanced Install Customization` if you wish to perform the From 50f7b4236b8433d8d5003cd4641f6f25c533bdfe Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 26 Mar 2015 14:33:10 -0400 Subject: [PATCH 06/22] Add .template suffix to nginx configuration templates. Refs #1054 --- plugins/nginx-vhosts/commands | 4 ++-- .../templates/{nginx.conf => nginx.conf.template} | 0 .../templates/{nginx.ssl.conf => nginx.ssl.conf.template} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename plugins/nginx-vhosts/templates/{nginx.conf => nginx.conf.template} (100%) rename plugins/nginx-vhosts/templates/{nginx.ssl.conf => nginx.ssl.conf.template} (100%) diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index ab8d6e245..13e601cdf 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -66,7 +66,7 @@ EOF SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0) NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0) - NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf" + NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf.template" while read line; do dokku_log_info1 "Configuring SSL for $line..." SSL_SERVER_NAME=$line @@ -82,7 +82,7 @@ EOF eval "cat <<< \"$(< $APP_NGINX_TEMPLATE)\" > $NGINX_CONF" elif [[ -n "$NONSSL_VHOSTS" ]]; then xargs -i echo "-----> Configuring {}..." <<< "$NONSSL_VHOSTS" - NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.conf" + NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.conf.template" eval "cat <<< \"$(< $NGINX_TEMPLATE)\" >> $NGINX_CONF" fi diff --git a/plugins/nginx-vhosts/templates/nginx.conf b/plugins/nginx-vhosts/templates/nginx.conf.template similarity index 100% rename from plugins/nginx-vhosts/templates/nginx.conf rename to plugins/nginx-vhosts/templates/nginx.conf.template diff --git a/plugins/nginx-vhosts/templates/nginx.ssl.conf b/plugins/nginx-vhosts/templates/nginx.ssl.conf.template similarity index 100% rename from plugins/nginx-vhosts/templates/nginx.ssl.conf rename to plugins/nginx-vhosts/templates/nginx.ssl.conf.template From b6ce856acb3cc303fed0ad94a568df736b9bb7e5 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 27 Mar 2015 14:25:52 -0700 Subject: [PATCH 07/22] set DEBIAN_FRONTEND appropriately to avoid warnings --- Vagrantfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index ba7b7352a..305d212e8 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,7 +9,7 @@ DOKKU_IP = ENV["DOKKU_IP"] || "10.0.0.2" PREBUILT_STACK_URL = File.exist?("#{File.dirname(__FILE__)}/stack.tgz") ? 'file:///root/dokku/stack.tgz' : nil PUBLIC_KEY_PATH = "#{Dir.home}/.ssh/id_rsa.pub" -make_cmd = "make install" +make_cmd = "DEBIAN_FRONTEND=noninteractive make -e install" if PREBUILT_STACK_URL make_cmd = "PREBUILT_STACK_URL='#{PREBUILT_STACK_URL}' #{make_cmd}" end @@ -35,7 +35,7 @@ Vagrant::configure("2") do |config| vm.vm.network :forwarded_port, guest: 80, host: 8080 vm.vm.hostname = "#{DOKKU_DOMAIN}" vm.vm.network :private_network, ip: DOKKU_IP - vm.vm.provision :shell, :inline => "apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" + vm.vm.provision :shell, :inline => "DEBIAN_FRONTEND=noninteractive apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" vm.vm.provision :shell, :inline => "cd /root/dokku && make dokku-installer" end @@ -47,7 +47,7 @@ Vagrant::configure("2") do |config| end config.vm.define "build", autostart: false do |vm| - vm.vm.provision :shell, :inline => "apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" + vm.vm.provision :shell, :inline => "DEBIAN_FRONTEND=noninteractive apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" vm.vm.provision :shell, :inline => "cd /root/dokku && make deb-all" end From e1672b2764549ddcd89a0828a16442df13fa37c0 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 27 Mar 2015 14:26:21 -0700 Subject: [PATCH 08/22] call make stack in subprocess --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5497eb032..74d2748cd 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ include deb.mk all: # Type "make install" to install. -install: dependencies stack copyfiles plugin-dependencies plugins version +install: dependencies copyfiles plugin-dependencies plugins version release: deb-all package_cloud packer @@ -61,7 +61,8 @@ plugin-dependencies: pluginhook plugins: pluginhook docker dokku plugins-install -dependencies: sshcommand pluginhook docker stack help2man +dependencies: sshcommand pluginhook docker help2man + $(MAKE) -e stack help2man: apt-get install -qq -y help2man From 2b59c4b8eb4825ad81639c22d58e4de6b8c38e3a Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 27 Mar 2015 14:24:04 -0700 Subject: [PATCH 09/22] [ci skip] document test suite --- docs/development/testing.md | 36 ++++++++++++++++++++++++++++++++++++ docs/index.md | 1 + 2 files changed, 37 insertions(+) create mode 100644 docs/development/testing.md diff --git a/docs/development/testing.md b/docs/development/testing.md new file mode 100644 index 000000000..b5dd94fac --- /dev/null +++ b/docs/development/testing.md @@ -0,0 +1,36 @@ +# Dokku test suite + +Dokku now has a full test suite to assist in quick iterating development. These tests include a linter using [shellcheck](https://github.com/koalaman/shellcheck), functional unit tests using the [bats testing framework](https://github.com/sstephenson/bats), and a deployment suite of example apps that use the most popular languages and frameworks. + +Bats tests can be found here: + ``` + tests/unit/*.bats + ``` + +Example apps can be found here: + ``` + tests/apps/ + ``` + +### Executing tests locally + +- Setup dokku in a [vagrant vm](http://progrium.viewdocs.io/dokku/getting-started/install/vagrant) +- Test setup and execution + + ```shell + $ vagrant ssh + $ sudo su - + $ cd ~/dokku + $ make ci-dependencies setup-deploy-tests + $ make test # run the entire test suite (linter, bats tests, and app deployment tests) + $ + $ make lint # linter + $ make unit-tests # bats tests + $ make deploy-tests # app deployment tests + ``` +- Additionally you may run a specific app deployment tests with a target similar to: + + ```shell + make deploy-test-nodejs-express + ``` +- For a full list of test make targets check out `tests.mk` in the root of the dokku repository. diff --git a/docs/index.md b/docs/index.md index 52f86918a..3a0a2f750 100644 --- a/docs/index.md +++ b/docs/index.md @@ -27,6 +27,7 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. - [Plugin Creation](http://progrium.viewdocs.io/dokku/development/plugin-creation) - [Pluginhooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) +- [Test Suite](http://progrium.viewdocs.io/dokku/development/testing) ## Things this project won't do From c4d0d371131010b40210a64b180c69681efc538c Mon Sep 17 00:00:00 2001 From: Martin Ansty Date: Fri, 27 Mar 2015 22:38:13 +0000 Subject: [PATCH 10/22] Fix nginx docs wording around config template eg --- docs/nginx.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nginx.md b/docs/nginx.md index a6f6472d2..7f176a54f 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -75,7 +75,7 @@ server { } ``` -The above is a sample, http configuration that adds an `X-Served-By` header to requests. The template is manually uploaded this template file and **must** it owned by `dokku:dokku`. +The above is a sample http configuration that adds an `X-Served-By` header to requests. The template file **must** be owned by the user `dokku:dokku`. ## Customizing hostnames From bb54f845aa28efeeb0034adb362571f7e30653d0 Mon Sep 17 00:00:00 2001 From: Matias Korhonen Date: Sun, 29 Mar 2015 18:40:23 +0300 Subject: [PATCH 11/22] Fixes escaping in the rc.local script `uname -r` was getting executed before the kernel change --- contrib/stackscript.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/stackscript.sh b/contrib/stackscript.sh index 4d9ace16b..6fe9da858 100644 --- a/contrib/stackscript.sh +++ b/contrib/stackscript.sh @@ -115,7 +115,7 @@ function setup_linode { update-grub cp /etc/rc.local /etc/rc.local-bak - cat << EOF > /etc/rc.local + cat << "EOF" > /etc/rc.local #!/bin/sh -e sudo apt-get update >> /root/setup_linode.txt 2>&1 sudo apt-get install -y linux-image-extra-"$(uname -r)" >> /root/setup_linode.txt 2>&1 From 61136e2591b983bd406bdbf6978d2dff91bcc0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Mon, 30 Mar 2015 11:25:33 +0200 Subject: [PATCH 12/22] Better detection of dokku remote Previously this script was matching for a remote named 'dokku' even when DOKKU_HOST is provided and completely custom. I have a case where I have 2 remotes with dokku, one on a staging server and another on a production server. So by matching for 'dokku@$DOKKU_HOST' instead, the script can determine correctly which remote to use. --- contrib/dokku_client.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index 148ffa61a..27f75148b 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -46,7 +46,7 @@ if [[ ! -z $DOKKU_HOST ]]; then appname="" if [[ -d .git ]] || git rev-parse --git-dir > /dev/null 2>&1; then set +e - appname=$(git remote -v 2>/dev/null | grep -Ei "^dokku" | head -n 1 | cut -f1 -d' ' | cut -f2 -d':' 2>/dev/null) + appname=$(git remote -v 2>/dev/null | grep -Ei "dokku@$DOKKU_HOST" | head -n 1 | cut -f1 -d' ' | cut -f2 -d':' 2>/dev/null) set -e else echo "This is not a git repository" From af924efe17a33db625e7faef1544ef73879e963a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Mon, 30 Mar 2015 23:24:34 +0200 Subject: [PATCH 13/22] Add dokku-psql-single-container to plugins --- docs/plugins.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/plugins.md b/docs/plugins.md index 995edd060..8ff3b05eb 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -93,6 +93,7 @@ Note: The following plugins have been supplied by our community and may not have | [PostgreSQL](https://github.com/jlachowski/dokku-pg-plugin) | [jlachowski][] | IP & PORT available directly in linked app container env variables (requires link plugin)| | [PostgreSQL (single container)](https://github.com/jeffutter/dokku-postgresql-plugin) | [jeffutter][] | This plugin creates a single postgresql container that all your apps can use. Thus only one instance of postgresql running (good for servers without a ton of memory). | | [PostgreSQL (single container)](https://github.com/ohardy/dokku-psql) | [ohardy][] | Compatible with 0.2.0 | +| [PostgreSQL (single container)](https://github.com/Flink/dokku-psql-single-container) | [Flink][] | Single Postgresql container with official Postgresql docker image. Compatible with 0.3.16 | | [PostGIS](https://github.com/fermuch/dokku-pg-plugin) | [fermuch][] | | #### Caching From 0f4ee909d5b56797e872d7ec7647f4ab659d567c Mon Sep 17 00:00:00 2001 From: Rory Date: Wed, 1 Apr 2015 13:44:49 +0200 Subject: [PATCH 14/22] corrected configuration link in bootstrap.sh --- bootstrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 6a4d0f4bc..942f63da2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -33,4 +33,5 @@ make install echo echo "Almost done! For next steps on configuration:" -echo " http://progrium.viewdocs.io/dokku/installation#user-content-configuring" +echo " http://progrium.viewdocs.io/dokku/advanced-installation#user-content-configuring" + From df8f4fb8824550518b07c87ac56aba568bd81295 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 1 Apr 2015 12:21:45 -0700 Subject: [PATCH 15/22] initial pass at including docker-options plugin. closes #1062 --- docs/docker-options.md | 60 +++++++++ docs/index.md | 1 + plugins/docker-options/commands | 149 +++++++++++++++++++++ plugins/docker-options/docker-args-build | 1 + plugins/docker-options/docker-args-deploy | 43 ++++++ plugins/docker-options/docker-args-run | 1 + tests/unit/docker-options.bats | 151 ++++++++++++++++++++++ 7 files changed, 406 insertions(+) create mode 100644 docs/docker-options.md create mode 100755 plugins/docker-options/commands create mode 120000 plugins/docker-options/docker-args-build create mode 100755 plugins/docker-options/docker-args-deploy create mode 120000 plugins/docker-options/docker-args-run create mode 100644 tests/unit/docker-options.bats diff --git a/docs/docker-options.md b/docs/docker-options.md new file mode 100644 index 000000000..0e21d508b --- /dev/null +++ b/docs/docker-options.md @@ -0,0 +1,60 @@ +docker-options +======================== + +Usage +----- + +```bash +$ dokku help +... + docker-options Display apps docker options for all phases + docker-options Display apps docker options for phase (comma seperated phase list) + docker-options:add OPTION Add docker option to app for phase (comma seperated phase list) + docker-options:remove OPTION Remove docker option from app for phase (comma seperated phase list) +... +```` + +Add some options + +```bash +$ dokku docker-options:add myapp deploy "-v /host/path:/container/path" +$ dokku docker-options:add myapp run "-v /another/container/path" +$ dokku docker-options:add myapp "-link container_name:alias" +``` + +Check what we added + +```bash +$ dokku docker-options myapp +-link container_name:alias +-v /host/path:/container/path +-v /another/container/path +``` + +Remove an option +```bash +$ dokku docker-options:remove myapp "-link container_name:alias" +``` + +Manual Usage +------------ + +In your applications folder (/home/dokku/app_name) create a file called DOCKER_OPTIONS. + +Inside this file list one docker option per line. For example: + +```bash +-link container_name:alias +-v /host/path:/container/path +-v /another/container/path +``` + +The above example will result in the following options being passed to docker during deploy and docker run: + +```bash +-link container_name:alias -v /host/path:/container/path -v /another/container/path +``` + +You may also include comments (lines beginning with a #) and blank lines in the DOCKER_OPTIONS file. + +Move information on docker options can be found here: http://docs.docker.io/en/latest/reference/run/ . diff --git a/docs/index.md b/docs/index.md index 3a0a2f750..0b2dd82d3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,6 +17,7 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. - [DNS Configuration](http://progrium.viewdocs.io/dokku/dns) - [Nginx Configuration](http://progrium.viewdocs.io/dokku/nginx) - [Running Remote commands](http://progrium.viewdocs.io/dokku/remote-commands) +- [Container Options](http://progrium.viewdocs.io/dokku/docker-options) ### Community Contributions diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands new file mode 100755 index 000000000..d2cc8b496 --- /dev/null +++ b/plugins/docker-options/commands @@ -0,0 +1,149 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$(dirname $0)/../common/functions" + +PHASES=(build deploy run) + +FILE_PREFIX="DOCKER_OPTIONS_" + +get_app() { + [[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$1" + APP="$1" +} + +get_phases() { + local passed_phases_list=$1 + local phase + if [[ -n $passed_phases_list ]]; then + IFS=',' read -ra passed_phases <<< "$passed_phases_list" + for phase in "${passed_phases[@]}"; do + verify_phase $phase + done + fi +} + +verify_phase() { + local phase + for phase in "${PHASES[@]}"; do + if [[ "$phase" = "$1" ]]; then + return 0 + fi + done + dokku_log_fail "Phase(s) must be one of [${PHASES[@]}]" +} + +get_phase_file_path() { + local phase=$1 + phase_file_path="${DOKKU_ROOT}/${APP}/${FILE_PREFIX}${phase^^}" +} + +create_phase_file_if_required() { + local phase_file_path=$1 + [[ -f $phase_file_path ]] || { + touch $phase_file_path + } +} + +display_phase_options() { + local phase=$1 + local phase_file_path=$2 + echo "${phase^} options:" + sed -e 's/^/ /' $phase_file_path +} + +display_all_phases_options() { + for phase in "${PHASES[@]}"; do + get_phase_file_path $phase + if [[ -s $phase_file_path ]] ; then + display_phase_options $phase $phase_file_path + fi + done +} + +display_passed_phases_options() { + local passed_phases=("${!1}") + local phase + for phase in "${passed_phases[@]}"; do + get_phase_file_path $phase + if [ ! -s $phase_file_path ] ; then + echo "${phase^} options: none" + else + display_phase_options $phase $phase_file_path + fi + done +} + +get_passed_docker_option() { + [[ -z "$@" ]] && dokku_log_fail "Please specify docker options to add to the phase" + passed_docker_option=("$@") +} + +add_passed_docker_option() { + local passed_phases=("${!1}") + local passed_option_string=$2 + local phase + for phase in "${passed_phases[@]}"; do + get_phase_file_path $phase + create_phase_file_if_required $phase_file_path + echo "${passed_option_string}" >> $phase_file_path + all_phase_options=$(< $phase_file_path) + echo -e "${all_phase_options}" | sed '/^$/d' | sort -u > $phase_file_path + done +} + +remove_passed_docker_option() { + local passed_phases=("${!1}") + local passed_option_string=$2 + local phase + for phase in "${passed_phases[@]}"; do + get_phase_file_path $phase + [[ ! -s $phase_file_path ]] || { + all_phase_options=$(< $phase_file_path) + all_phase_options=$(echo -e "${all_phase_options}" | sed "s#^${passed_option_string}\$##") + echo -e "${all_phase_options}" | sed '/^$/d' | sort -u > $phase_file_path + } + done +} + +case "$1" in + # Display applications docker options + docker-options) + get_app $2 + get_phases $3 + if [[ ! "${passed_phases[@]}" ]]; then + display_all_phases_options + else + display_passed_phases_options passed_phases[@] + fi + ;; + + # Add a docker option to application + docker-options:add) + get_app $2 + get_phases $3 + shift 3 # everything else passed is the docker option + get_passed_docker_option "$@" + add_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" + ;; + + # Remove a docker option from application + docker-options:remove) + get_app $2 + get_phases $3 + shift 3 # everything else passed is the docker option + get_passed_docker_option "$@" + remove_passed_docker_option passed_phases[@] "${passed_docker_option[@]}" + ;; + + # Display usage help + help) + cat && cat< Display apps docker options for all phases + docker-options Display apps docker options for phase (comma seperated phase list) + docker-options:add OPTION Add docker option to app for phase (comma seperated phase list) + docker-options:remove OPTION Remove docker option from app for phase (comma seperated phase list) +EOF + ;; + +esac diff --git a/plugins/docker-options/docker-args-build b/plugins/docker-options/docker-args-build new file mode 120000 index 000000000..68dea362a --- /dev/null +++ b/plugins/docker-options/docker-args-build @@ -0,0 +1 @@ +docker-args-deploy \ No newline at end of file diff --git a/plugins/docker-options/docker-args-deploy b/plugins/docker-options/docker-args-deploy new file mode 100755 index 000000000..019f66f81 --- /dev/null +++ b/plugins/docker-options/docker-args-deploy @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +STDIN=$(cat) +APP="$1" + +case "$0" in + *docker-args-build) + PHASE=BUILD + ;; + *docker-args-deploy) + PHASE=DEPLOY + ;; + *docker-args-run) + PHASE=RUN + ;; +esac + +FILE_PREFIX="DOCKER_OPTIONS_" +PHASE_FILE_PATH="${DOKKU_ROOT}/${APP}/${FILE_PREFIX}${PHASE}" + +output="" + +if [[ -f "$PHASE_FILE_PATH" ]]; then + DONE=false + until $DONE; do + read line || DONE=true + + [[ ! -n "$line" ]] && continue + + # shellcheck disable=SC1001 + case "$line" in + \#*) + continue + ;; + *) + output="$output $line" + ;; + esac + done < $PHASE_FILE_PATH +fi + +echo "$STDIN$output" diff --git a/plugins/docker-options/docker-args-run b/plugins/docker-options/docker-args-run new file mode 120000 index 000000000..68dea362a --- /dev/null +++ b/plugins/docker-options/docker-args-run @@ -0,0 +1 @@ +docker-args-deploy \ No newline at end of file diff --git a/tests/unit/docker-options.bats b/tests/unit/docker-options.bats new file mode 100644 index 000000000..c2b097eb2 --- /dev/null +++ b/tests/unit/docker-options.bats @@ -0,0 +1,151 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + create_app +} + +teardown() { + destroy_app +} + +@test "docker-options:add (all phases)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 3" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "docker-options:add (build phase)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP build \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP build | egrep '\-v /tmp' | wc -l | grep -q 1" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "docker-options:add (deploy phase)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP deploy \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP deploy | egrep '\-v /tmp' | wc -l | grep -q 1" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "docker-options:add (run phase)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP run | egrep '\-v /tmp' | wc -l | grep -q 1" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "docker-options:remove (all phases)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 3" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options:remove $TEST_APP build,deploy,run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP | wc -l | grep -q 0" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "docker-options:remove (build phase)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 3" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options:remove $TEST_APP build \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP build" + echo "output: "$output + echo "status: "$status + assert_output "Build options: none" +} + +@test "docker-options:remove (deploy phase)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP deploy | egrep '\-v /tmp' | wc -l | grep -q 1" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options:remove $TEST_APP deploy \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP deploy" + echo "output: "$output + echo "status: "$status + assert_output "Deploy options: none" +} + +@test "docker-options:remove (run phase)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP run | egrep '\-v /tmp' | wc -l | grep -q 1" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options:remove $TEST_APP run \"-v /tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP run" + echo "output: "$output + echo "status: "$status + assert_output "Run options: none" +} + +@test "docker-options (deploy with options)" { + run /bin/bash -c "dokku docker-options:add $TEST_APP deploy \"-v /var/tmp\"" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "echo '-v /tmp' >> $DOKKU_ROOT/$TEST_APP/DOCKER_OPTIONS_DEPLOY" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "echo '# comment' >> $DOKKU_ROOT/$TEST_APP/DOCKER_OPTIONS_DEPLOY" + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku docker-options $TEST_APP deploy | egrep '\-v /tmp' | wc -l | grep -q 1" + echo "output: "$output + echo "status: "$status + assert_success + deploy_app +} From 1bad26426ec537ed4898c57ec2a7b3ab52dd2451 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 1 Apr 2015 13:49:55 -0700 Subject: [PATCH 16/22] force testing .env with no newline and actually fix #1025 and #1026. closes #1063 --- plugins/build-env/pre-build | 1 + tests/apps/ruby/.env | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/apps/ruby/.env diff --git a/plugins/build-env/pre-build b/plugins/build-env/pre-build index fa14ac60b..033973c40 100755 --- a/plugins/build-env/pre-build +++ b/plugins/build-env/pre-build @@ -10,6 +10,7 @@ APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV="" ! (grep -q CURL_TIMEOUT "$DOKKU_ROOT/ENV" > /dev/null 2>&1) && echo "export CURL_TIMEOUT=30" >> "$DOKKU_ROOT/ENV" if [[ -f "$DOKKU_ROOT/ENV" ]]; then + BUILD_ENV+=$'\n' BUILD_ENV+=$(< "$DOKKU_ROOT/ENV") BUILD_ENV+=$'\n' fi diff --git a/tests/apps/ruby/.env b/tests/apps/ruby/.env new file mode 100644 index 000000000..4b145e474 --- /dev/null +++ b/tests/apps/ruby/.env @@ -0,0 +1 @@ +export BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby#v129 \ No newline at end of file From 6d0b4ef4ec19df3189575a16282e0938ce7741cd Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 1 Apr 2015 17:30:09 -0700 Subject: [PATCH 17/22] test cleanup with slight performance boost --- tests/apps/config/package.json | 6 +-- tests/apps/gitsubmodules/package.json | 4 +- .../nodejs-express-noprocfile/package.json | 4 +- tests/apps/nodejs-express/package.json | 6 +-- tests/unit/00_dokku-standard.bats | 23 ++++++--- tests/unit/apps.bats | 0 tests/unit/build-env.bats | 2 +- tests/unit/cleanup.bats | 2 +- tests/unit/ps-buildstep.bats | 30 ++++------- tests/unit/ps-dockerfile.bats | 50 ++++++++----------- 10 files changed, 59 insertions(+), 68 deletions(-) mode change 100755 => 100644 tests/unit/apps.bats diff --git a/tests/apps/config/package.json b/tests/apps/config/package.json index 7bdf8db0c..eb17caf0c 100644 --- a/tests/apps/config/package.json +++ b/tests/apps/config/package.json @@ -5,7 +5,7 @@ "express": "2.5.x" }, "engines": { - "node": "0.8.x", - "npm": "1.1.x" + "node": "0.10.x", + "npm": "2.7.x" } -} \ No newline at end of file +} diff --git a/tests/apps/gitsubmodules/package.json b/tests/apps/gitsubmodules/package.json index 742e06105..ca800a5df 100644 --- a/tests/apps/gitsubmodules/package.json +++ b/tests/apps/gitsubmodules/package.json @@ -6,6 +6,6 @@ }, "engines": { "node": "0.10.x", - "npm": "1.3.x" + "npm": "2.7.x" } -} \ No newline at end of file +} diff --git a/tests/apps/nodejs-express-noprocfile/package.json b/tests/apps/nodejs-express-noprocfile/package.json index 7f0462b58..6f8ca43e1 100644 --- a/tests/apps/nodejs-express-noprocfile/package.json +++ b/tests/apps/nodejs-express-noprocfile/package.json @@ -5,8 +5,8 @@ "express": "2.5.x" }, "engines": { - "node": "0.8.x", - "npm": "1.1.x" + "node": "0.10.x", + "npm": "2.7.x" }, "scripts": { "start": "node web.js" diff --git a/tests/apps/nodejs-express/package.json b/tests/apps/nodejs-express/package.json index 7bdf8db0c..eb17caf0c 100644 --- a/tests/apps/nodejs-express/package.json +++ b/tests/apps/nodejs-express/package.json @@ -5,7 +5,7 @@ "express": "2.5.x" }, "engines": { - "node": "0.8.x", - "npm": "1.1.x" + "node": "0.10.x", + "npm": "2.7.x" } -} \ No newline at end of file +} diff --git a/tests/unit/00_dokku-standard.bats b/tests/unit/00_dokku-standard.bats index d7a5cde95..a77286159 100644 --- a/tests/unit/00_dokku-standard.bats +++ b/tests/unit/00_dokku-standard.bats @@ -26,7 +26,18 @@ build_nginx_config() { dokku nginx:build-config $TEST_APP } -@test "run (with tty)" { +@test "core: unknown command" { + run /bin/bash -c "dokku fakecommand" + echo "output: "$output + echo "status: "$status + assert_failure + run /bin/bash -c "dokku fakecommand | grep -q 'is not a dokku command'" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "core: run (with tty)" { deploy_app run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" echo "output: "$output @@ -34,7 +45,7 @@ build_nginx_config() { assert_success } -@test "run (without tty)" { +@test "core: run (without tty)" { deploy_app run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" echo "output: "$output @@ -42,7 +53,7 @@ build_nginx_config() { assert_success } -@test "run (with --options)" { +@test "core: run (with --options)" { deploy_app run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version" echo "output: "$output @@ -50,7 +61,7 @@ build_nginx_config() { assert_success } -@test "urls (non-ssl)" { +@test "core: urls (non-ssl)" { assert_urls "http://dokku.me" build_nginx_config assert_urls "http://${TEST_APP}.dokku.me" @@ -58,7 +69,7 @@ build_nginx_config() { assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me" } -@test "urls (app ssl)" { +@test "core: urls (app ssl)" { setup_test_tls assert_urls "https://dokku.me" build_nginx_config @@ -67,7 +78,7 @@ build_nginx_config() { assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me" "http://test.dokku.me" } -@test "urls (wildcard ssl)" { +@test "core: urls (wildcard ssl)" { setup_test_tls_wildcard assert_urls "https://dokku.me" build_nginx_config diff --git a/tests/unit/apps.bats b/tests/unit/apps.bats old mode 100755 new mode 100644 diff --git a/tests/unit/build-env.bats b/tests/unit/build-env.bats index cd062742a..f18b58bfd 100644 --- a/tests/unit/build-env.bats +++ b/tests/unit/build-env.bats @@ -10,7 +10,7 @@ teardown() { destroy_app } -@test "build-env with special chars" { +@test "build-env: with special chars" { run dokku config:set $TEST_APP NEWRELIC_APP_NAME="$TEST_APP (Staging)" echo "output: "$output echo "status: "$status diff --git a/tests/unit/cleanup.bats b/tests/unit/cleanup.bats index 22e0c4f5b..31c3c82db 100644 --- a/tests/unit/cleanup.bats +++ b/tests/unit/cleanup.bats @@ -10,7 +10,7 @@ teardown() { destroy_app } -@test "remove exited containers" { +@test "core: remove exited containers" { # make sure we have many exited containers of the same 'type' run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done" echo "output: "$output diff --git a/tests/unit/ps-buildstep.bats b/tests/unit/ps-buildstep.bats index 9973731ef..4cbbdd0ed 100644 --- a/tests/unit/ps-buildstep.bats +++ b/tests/unit/ps-buildstep.bats @@ -21,22 +21,7 @@ teardown() { # assert_success # } -@test "ps:start (buildstep)" { - run bash -c "dokku ps:stop $TEST_APP" - echo "output: "$output - echo "status: "$status - assert_success - run bash -c "dokku ps:start $TEST_APP" - echo "output: "$output - echo "status: "$status - assert_success - run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)" - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "ps:stop (buildstep)" { +@test "ps (buildstep)" { run bash -c "dokku ps:stop $TEST_APP" echo "output: "$output echo "status: "$status @@ -45,9 +30,16 @@ teardown() { echo "output: "$output echo "status: "$status assert_failure -} -@test "ps:restart (buildstep)" { + run bash -c "dokku ps:start $TEST_APP" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "dokku ps:restart $TEST_APP" echo "output: "$output echo "status: "$status @@ -56,9 +48,7 @@ teardown() { echo "output: "$output echo "status: "$status assert_success -} -@test "ps:rebuild (buildstep)" { run bash -c "dokku ps:rebuild $TEST_APP" echo "output: "$output echo "status: "$status diff --git a/tests/unit/ps-dockerfile.bats b/tests/unit/ps-dockerfile.bats index ddc1d3706..1cce3a704 100644 --- a/tests/unit/ps-dockerfile.bats +++ b/tests/unit/ps-dockerfile.bats @@ -10,33 +10,18 @@ teardown() { destroy_app } +# @test "ps (dockerfile)" { +# # CI support: 'Ah. I just spoke with our Docker expert -- +# # looks like docker exec is built to work with docker-under-libcontainer, +# # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry +# skip "circleci does not support docker exec at the moment." +# run bash -c "dokku ps $TEST_APP | grep -q \"node web.js\"" +# echo "output: "$output +# echo "status: "$status +# assert_success +# } + @test "ps (dockerfile)" { - # CI support: 'Ah. I just spoke with our Docker expert -- - # looks like docker exec is built to work with docker-under-libcontainer, - # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry - skip "circleci does not support docker exec at the moment." - run bash -c "dokku ps $TEST_APP | grep -q \"node web.js\"" - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "ps:start (dockerfile)" { - run bash -c "dokku ps:stop $TEST_APP" - echo "output: "$output - echo "status: "$status - assert_success - run bash -c "dokku ps:start $TEST_APP" - echo "output: "$output - echo "status: "$status - assert_success - run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)" - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "ps:stop (dockerfile)" { run bash -c "dokku ps:stop $TEST_APP" echo "output: "$output echo "status: "$status @@ -45,9 +30,16 @@ teardown() { echo "output: "$output echo "status: "$status assert_failure -} -@test "ps:restart (dockerfile)" { + run bash -c "dokku ps:start $TEST_APP" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "dokku ps:restart $TEST_APP" echo "output: "$output echo "status: "$status @@ -56,9 +48,7 @@ teardown() { echo "output: "$output echo "status: "$status assert_success -} -@test "ps:rebuild (dockerfile)" { run bash -c "dokku ps:rebuild $TEST_APP" echo "output: "$output echo "status: "$status From 4e472c39e3d666e7f7b4c92ab6db81ee30c2101e Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 1 Apr 2015 17:44:34 -0700 Subject: [PATCH 18/22] uniform unit test labels --- tests/unit/apps.bats | 36 ++++---- tests/unit/backup.bats | 2 +- tests/unit/build-env.bats | 2 +- tests/unit/cleanup.bats | 36 -------- tests/unit/client.bats | 26 +++--- tests/unit/config.bats | 10 +-- .../{00_dokku-standard.bats => core.bats} | 83 ++++++++++++------- tests/unit/{ports.bats => core_ports.bats} | 18 ++-- tests/unit/domains.bats | 8 +- tests/unit/nginx-vhosts.bats | 10 +-- tests/unit/ps-buildstep.bats | 4 +- tests/unit/ps-dockerfile.bats | 4 +- 12 files changed, 116 insertions(+), 123 deletions(-) delete mode 100644 tests/unit/cleanup.bats rename tests/unit/{00_dokku-standard.bats => core.bats} (64%) rename tests/unit/{ports.bats => core_ports.bats} (86%) diff --git a/tests/unit/apps.bats b/tests/unit/apps.bats index 361ad9fba..099be0895 100644 --- a/tests/unit/apps.bats +++ b/tests/unit/apps.bats @@ -2,24 +2,26 @@ load test_helper -APP=lifecycle-app +@test "(apps) apps" { + create_app + run bash -c "dokku apps | grep $TEST_APP" + echo "output: "$output + echo "status: "$status + assert_output $TEST_APP + destroy_app +} -@test "apps:create" { - run dokku apps:create $APP - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "apps" { - run bash -c "dokku apps | grep $APP" - echo "output: "$output - echo "status: "$status - assert_output $APP -} - -@test "apps:destroy" { - run bash -c "dokku --force apps:destroy $APP" +@test "(apps) apps:create" { + run dokku apps:create $TEST_APP + echo "output: "$output + echo "status: "$status + assert_success + destroy_app +} + +@test "(apps) apps:destroy" { + create_app + run bash -c "dokku --force apps:destroy $TEST_APP" echo "output: "$output echo "status: "$status assert_success diff --git a/tests/unit/backup.bats b/tests/unit/backup.bats index 0f733e4fa..1a3bb19a5 100644 --- a/tests/unit/backup.bats +++ b/tests/unit/backup.bats @@ -12,7 +12,7 @@ # destroy_app # } -# @test "backup:export" { +# @test "(backup) backup:export" { # run dokku backup:export $backup_file # echo "output: "$output # echo "status: "$status diff --git a/tests/unit/build-env.bats b/tests/unit/build-env.bats index f18b58bfd..1bbd8a708 100644 --- a/tests/unit/build-env.bats +++ b/tests/unit/build-env.bats @@ -10,7 +10,7 @@ teardown() { destroy_app } -@test "build-env: with special chars" { +@test "(build-env) special characters" { run dokku config:set $TEST_APP NEWRELIC_APP_NAME="$TEST_APP (Staging)" echo "output: "$output echo "status: "$status diff --git a/tests/unit/cleanup.bats b/tests/unit/cleanup.bats deleted file mode 100644 index 31c3c82db..000000000 --- a/tests/unit/cleanup.bats +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -setup() { - deploy_app -} - -teardown() { - destroy_app -} - -@test "core: remove exited containers" { - # make sure we have many exited containers of the same 'type' - run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done" - echo "output: "$output - echo "status: "$status - assert_success - run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'" - echo "output: "$output - echo "status: "$status - assert_success - run dokku cleanup - echo "output: "$output - echo "status: "$status - assert_success - sleep 5 # wait for dokku cleanup to happen in the background - run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'" - echo "output: "$output - echo "status: "$status - assert_failure - run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false" - echo "output: "$output - echo "status: "$status - assert_output "" -} diff --git a/tests/unit/client.bats b/tests/unit/client.bats index 88a6b0a6e..2d5e5e677 100644 --- a/tests/unit/client.bats +++ b/tests/unit/client.bats @@ -12,7 +12,7 @@ teardown() { unset DOKKU_HOST } -@test "dokku client (unconfigured DOKKU_HOST)" { +@test "(client) unconfigured DOKKU_HOST" { unset DOKKU_HOST run ./contrib/dokku_client.sh apps echo "output: "$output @@ -20,14 +20,14 @@ teardown() { assert_exit_status 20 } -@test "dokku client (no args should print help)" { +@test "(client) no args should print help" { run /bin/bash -c "./contrib/dokku_client.sh | head -1 | egrep -q '^Usage: dokku \[.+\] COMMAND .*'" echo "output: "$output echo "status: "$status assert_success } -@test "dokku client (apps:create AND apps:destroy)" { +@test "(client) apps:create AND apps:destroy" { setup_client_repo run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh apps:create" echo "output: "$output @@ -39,7 +39,7 @@ teardown() { assert_success } -@test "dokku client (config:set)" { +@test "(client) config:set" { run ./contrib/dokku_client.sh config:set $TEST_APP test_var=true test_var2=\"hello world\" echo "output: "$output echo "status: "$status @@ -50,7 +50,7 @@ teardown() { assert_success } -@test "dokku client (config:unset)" { +@test "(client) config:unset" { run ./contrib/dokku_client.sh config:set $TEST_APP test_var=true test_var2=\"hello world\" echo "output: "$output echo "status: "$status @@ -69,14 +69,14 @@ teardown() { assert_failure } -@test "dokku client (domains)" { +@test "(client) domains" { run bash -c "./contrib/dokku_client.sh domains $TEST_APP | grep -q ${TEST_APP}.dokku.me" echo "output: "$output echo "status: "$status assert_success } -@test "dokku client (domains:add)" { +@test "(client) domains:add" { run ./contrib/dokku_client.sh domains:add $TEST_APP www.test.app.dokku.me echo "output: "$output echo "status: "$status @@ -87,7 +87,7 @@ teardown() { assert_success } -@test "dokku client (domains:remove)" { +@test "(client) domains:remove" { run ./contrib/dokku_client.sh domains:add $TEST_APP test.app.dokku.me echo "output: "$output echo "status: "$status @@ -98,7 +98,7 @@ teardown() { refute_line "test.app.dokku.me" } -@test "dokku client (domains:clear)" { +@test "(client) domains:clear" { run ./contrib/dokku_client.sh domains:add $TEST_APP test.app.dokku.me echo "output: "$output echo "status: "$status @@ -109,7 +109,7 @@ teardown() { assert_success } -# @test "dokku client (ps)" { +# @test "(client) ps" { # # CI support: 'Ah. I just spoke with our Docker expert -- # # looks like docker exec is built to work with docker-under-libcontainer, # # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry @@ -121,7 +121,7 @@ teardown() { # assert_success # } -@test "dokku client (ps:start)" { +@test "(client) ps:start" { deploy_app run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:stop $TEST_APP" echo "output: "$output @@ -137,7 +137,7 @@ teardown() { assert_success } -@test "dokku client (ps:stop)" { +@test "(client) ps:stop" { deploy_app run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:stop $TEST_APP" echo "output: "$output @@ -149,7 +149,7 @@ teardown() { assert_failure } -@test "dokku client (ps:restart)" { +@test "(client) ps:restart" { deploy_app run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:restart $TEST_APP" echo "output: "$output diff --git a/tests/unit/config.bats b/tests/unit/config.bats index dd9d1cdf6..e68860e9b 100644 --- a/tests/unit/config.bats +++ b/tests/unit/config.bats @@ -12,14 +12,14 @@ teardown() { rm -f "$DOKKU_ROOT/ENV" } -@test "config:set" { +@test "(config) config:set" { run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" echo "output: "$output echo "status: "$status assert_success } -@test "config:get" { +@test "(config) config:get" { run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" echo "output: "$output echo "status: "$status @@ -30,7 +30,7 @@ teardown() { assert_output 'hello world' } -@test "config:unset" { +@test "(config) config:unset" { run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" echo "output: "$output echo "status: "$status @@ -49,7 +49,7 @@ teardown() { assert_output "" } -@test "global config (buildstep)" { +@test "(config) global config (buildstep)" { deploy_app run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'" echo "output: "$output @@ -57,7 +57,7 @@ teardown() { assert_success } -@test "global config (dockerfile)" { +@test "(config) global config (dockerfile)" { deploy_app dockerfile run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'" echo "output: "$output diff --git a/tests/unit/00_dokku-standard.bats b/tests/unit/core.bats similarity index 64% rename from tests/unit/00_dokku-standard.bats rename to tests/unit/core.bats index a77286159..76d5702e2 100644 --- a/tests/unit/00_dokku-standard.bats +++ b/tests/unit/core.bats @@ -26,7 +26,57 @@ build_nginx_config() { dokku nginx:build-config $TEST_APP } -@test "core: unknown command" { +@test "(core) remove exited containers" { + deploy_app + # make sure we have many exited containers of the same 'type' + run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'" + echo "output: "$output + echo "status: "$status + assert_success + run dokku cleanup + echo "output: "$output + echo "status: "$status + assert_success + sleep 5 # wait for dokku cleanup to happen in the background + run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'" + echo "output: "$output + echo "status: "$status + assert_failure + run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false" + echo "output: "$output + echo "status: "$status + assert_output "" +} + +@test "(core) run (with tty)" { + deploy_app + run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "(core) run (without tty)" { + deploy_app + run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "(core) run (with --options)" { + deploy_app + run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "(core) unknown command" { run /bin/bash -c "dokku fakecommand" echo "output: "$output echo "status: "$status @@ -37,31 +87,7 @@ build_nginx_config() { assert_success } -@test "core: run (with tty)" { - deploy_app - run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "core: run (without tty)" { - deploy_app - run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "core: run (with --options)" { - deploy_app - run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version" - echo "output: "$output - echo "status: "$status - assert_success -} - -@test "core: urls (non-ssl)" { +@test "(core) urls (non-ssl)" { assert_urls "http://dokku.me" build_nginx_config assert_urls "http://${TEST_APP}.dokku.me" @@ -69,7 +95,7 @@ build_nginx_config() { assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me" } -@test "core: urls (app ssl)" { +@test "(core) urls (app ssl)" { setup_test_tls assert_urls "https://dokku.me" build_nginx_config @@ -78,7 +104,7 @@ build_nginx_config() { assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me" "http://test.dokku.me" } -@test "core: urls (wildcard ssl)" { +@test "(core) urls (wildcard ssl)" { setup_test_tls_wildcard assert_urls "https://dokku.me" build_nginx_config @@ -88,3 +114,4 @@ build_nginx_config() { add_domain "dokku.example.com" assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://dokku.example.com" } + diff --git a/tests/unit/ports.bats b/tests/unit/core_ports.bats similarity index 86% rename from tests/unit/ports.bats rename to tests/unit/core_ports.bats index b0d3c728c..f0076b381 100644 --- a/tests/unit/ports.bats +++ b/tests/unit/core_ports.bats @@ -13,7 +13,7 @@ teardown() { [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" } -@test "port exposure (with global VHOST)" { +@test "(core) port exposure (with global VHOST)" { echo "dokku.me" > "$DOKKU_ROOT/VHOST" deploy_app CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') @@ -23,7 +23,7 @@ teardown() { assert_failure } -@test "port exposure (without global VHOST and real HOSTNAME)" { +@test "(core) port exposure (without global VHOST and real HOSTNAME)" { rm "$DOKKU_ROOT/VHOST" echo "dokku.me" > "$DOKKU_ROOT/HOSTNAME" deploy_app @@ -34,7 +34,7 @@ teardown() { assert_success } -@test "port exposure (with NO_VHOST set)" { +@test "(core) port exposure (with NO_VHOST set)" { deploy_app dokku config:set $TEST_APP NO_VHOST=1 CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') @@ -44,7 +44,7 @@ teardown() { assert_success } -@test "port exposure (without global VHOST and IPv4 address as HOSTNAME)" { +@test "(core) port exposure (without global VHOST and IPv4 address as HOSTNAME)" { rm "$DOKKU_ROOT/VHOST" echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME" deploy_app @@ -55,7 +55,7 @@ teardown() { assert_success } -@test "port exposure (without global VHOST and IPv6 address as HOSTNAME)" { +@test "(core) port exposure (without global VHOST and IPv6 address as HOSTNAME)" { rm "$DOKKU_ROOT/VHOST" echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME" deploy_app @@ -66,7 +66,7 @@ teardown() { assert_success } -@test "port exposure (pre-deploy domains:add)" { +@test "(core) port exposure (pre-deploy domains:add)" { create_app run dokku domains:add $TEST_APP www.test.app.dokku.me echo "output: "$output @@ -88,7 +88,7 @@ teardown() { assert_success } -@test "port exposure (no global VHOST and domains:add post deploy)" { +@test "(core) port exposure (no global VHOST and domains:add post deploy)" { rm "$DOKKU_ROOT/VHOST" deploy_app @@ -109,7 +109,7 @@ teardown() { assert_success } -@test "dockerfile port exposure" { +@test "(core) dockerfile port exposure" { deploy_app dockerfile run bash -c "grep upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep 3000" echo "output: "$output @@ -117,7 +117,7 @@ teardown() { assert_success } -@test "port exposure (xip.io style hostnames)" { +@test "(core) port exposure (xip.io style hostnames)" { echo "127.0.0.1.xip.io" > "$DOKKU_ROOT/VHOST" deploy_app diff --git a/tests/unit/domains.bats b/tests/unit/domains.bats index 55e33eb57..bdc52994e 100644 --- a/tests/unit/domains.bats +++ b/tests/unit/domains.bats @@ -10,14 +10,14 @@ teardown() { destroy_app } -@test "domains" { +@test "(domains) domains" { run bash -c "dokku domains $TEST_APP | grep ${TEST_APP}.dokku.me" echo "output: "$output echo "status: "$status assert_output "${TEST_APP}.dokku.me" } -@test "domains:add" { +@test "(domains) domains:add" { run dokku domains:add $TEST_APP www.test.app.dokku.me echo "output: "$output echo "status: "$status @@ -28,7 +28,7 @@ teardown() { assert_success } -@test "domains:remove" { +@test "(domains) domains:remove" { run dokku domains:add $TEST_APP test.app.dokku.me echo "output: "$output echo "status: "$status @@ -39,7 +39,7 @@ teardown() { refute_line "test.app.dokku.me" } -@test "domains:clear" { +@test "(domains) domains:clear" { run dokku domains:add $TEST_APP test.app.dokku.me echo "output: "$output echo "status: "$status diff --git a/tests/unit/nginx-vhosts.bats b/tests/unit/nginx-vhosts.bats index f3440cc9f..4fc07af94 100644 --- a/tests/unit/nginx-vhosts.bats +++ b/tests/unit/nginx-vhosts.bats @@ -53,7 +53,7 @@ assert_http_success() { assert_output "200" } -@test "nginx (no server tokens)" { +@test "(nginx-vhosts) nginx (no server tokens)" { deploy_app run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | egrep '^Server' | egrep '[0-9]+'" echo "output: "$output @@ -61,7 +61,7 @@ assert_http_success() { assert_failure } -@test "nginx:build-config (wildcard SSL)" { +@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" { setup_test_tls_wildcard add_domain "wildcard1.dokku.me" add_domain "wildcard2.dokku.me" @@ -72,13 +72,13 @@ assert_http_success() { assert_nonssl_domain "www.test.dokku.me" } -@test "nginx:build-config (with SSL CN mismatch)" { +@test "(nginx-vhosts) nginx:build-config (with SSL CN mismatch)" { setup_test_tls deploy_app assert_ssl_domain "node-js-app.dokku.me" } -@test "nginx:build-config (with SSL and Multiple SANs)" { +@test "(nginx-vhosts) nginx:build-config (with SSL and Multiple SANs)" { setup_test_tls_with_sans deploy_app assert_ssl_domain "test.dokku.me" @@ -86,7 +86,7 @@ assert_http_success() { assert_ssl_domain "www.test.app.dokku.me" } -@test "nginx:build-config (no global VHOST and domains:add)" { +@test "(nginx-vhosts) nginx:build-config (no global VHOST and domains:add)" { destroy_app rm "$DOKKU_ROOT/VHOST" create_app diff --git a/tests/unit/ps-buildstep.bats b/tests/unit/ps-buildstep.bats index 4cbbdd0ed..934a57b65 100644 --- a/tests/unit/ps-buildstep.bats +++ b/tests/unit/ps-buildstep.bats @@ -10,7 +10,7 @@ teardown() { destroy_app } -# @test "ps (buildstep)" { +# @test "(ps) buildstep" { # # CI support: 'Ah. I just spoke with our Docker expert -- # # looks like docker exec is built to work with docker-under-libcontainer, # # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry @@ -21,7 +21,7 @@ teardown() { # assert_success # } -@test "ps (buildstep)" { +@test "(ps) buildstep" { run bash -c "dokku ps:stop $TEST_APP" echo "output: "$output echo "status: "$status diff --git a/tests/unit/ps-dockerfile.bats b/tests/unit/ps-dockerfile.bats index 1cce3a704..de4fea29e 100644 --- a/tests/unit/ps-dockerfile.bats +++ b/tests/unit/ps-dockerfile.bats @@ -10,7 +10,7 @@ teardown() { destroy_app } -# @test "ps (dockerfile)" { +# @test "(ps) dockerfile" { # # CI support: 'Ah. I just spoke with our Docker expert -- # # looks like docker exec is built to work with docker-under-libcontainer, # # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry @@ -21,7 +21,7 @@ teardown() { # assert_success # } -@test "ps (dockerfile)" { +@test "(ps) dockerfile" { run bash -c "dokku ps:stop $TEST_APP" echo "output: "$output echo "status: "$status From 7e7eb1dc87ef2f6900dc4d07ba96e980f099fa8b Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 1 Apr 2015 12:58:46 -0700 Subject: [PATCH 19/22] docs update --- docs/docker-options.md | 2 +- docs/plugins.md | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/docker-options.md b/docs/docker-options.md index 0e21d508b..730d64914 100644 --- a/docs/docker-options.md +++ b/docs/docker-options.md @@ -36,7 +36,7 @@ Remove an option $ dokku docker-options:remove myapp "-link container_name:alias" ``` -Manual Usage +Advanced Usage (avoid if possible) ------------ In your applications folder (/home/dokku/app_name) create a file called DOCKER_OPTIONS. diff --git a/docs/plugins.md b/docs/plugins.md index 8ff3b05eb..4a9e6b14b 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -149,7 +149,6 @@ Note: The following plugins have been supplied by our community and may not have | ------------------------------------------------------------------------------------------------- | --------------------- | --------------------- | | [app-url](https://github.com/mikecsh/dokku-app-url) | [mikecsh][] | Works with 0.2.0 | | [Docker Direct](https://github.com/heichblatt/dokku-docker-direct) | [heichblatt][] | | -| [Docker Options](https://github.com/dyson/dokku-docker-options) | [dyson][] | dokku >= [c77cbf1][] | | [Dokku Name](https://github.com/alex-sherwin/dokku-name) | [alex-sherwin][] | dokku >= [c77cbf1][] | | [Dokku Registry](https://github.com/agco-adm/dokku-registry)1 | [agco-adm][] | | | [git rev-parse HEAD in env](https://github.com/nornagon/dokku-git-rev) | [nornagon][] | Compatible with 0.2.0 | @@ -207,15 +206,16 @@ Note: The following plugins have been supplied by our community and may not have The following plugins have been removed as their functionality is now in Dokku Core. -| Plugin | Author | In Dokku Since | -| ------------------------------------------------------------------------------------------------- | --------------------- | ------------------------- | -| [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) | -| [Multiple Domains](https://github.com/wmluke/dokku-domains-plugin)1 | [wmluke][] | v0.3.10 (domains plugin) | -| [Rebuild application](https://github.com/scottatron/dokku-rebuild) | [scottatron][] | v0.3.14 (ps plugin) | -| [Supply env vars to buildpacks](https://github.com/cameron-martin/dokku-build-env)2 | [cameron-martin][] | v0.3.9 (build-env plugin) | -| [user-env-compile](https://github.com/musicglue/dokku-user-env-compile)2 | [musicglue][] | v0.3.9 (build-env plugin) | -| [user-env-compile](https://github.com/motin/dokku-user-env-compile)2 | [motin][] | v0.3.9 (build-env plugin) | +| Plugin | Author | In Dokku Since | +| ------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------- | +| [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) | +| [Multiple Domains](https://github.com/wmluke/dokku-domains-plugin)1 | [wmluke][] | v0.3.10 (domains plugin) | +| [Rebuild application](https://github.com/scottatron/dokku-rebuild) | [scottatron][] | v0.3.14 (ps plugin) | +| [Supply env vars to buildpacks](https://github.com/cameron-martin/dokku-build-env)2 | [cameron-martin][] | v0.3.9 (build-env plugin) | +| [user-env-compile](https://github.com/musicglue/dokku-user-env-compile)2 | [musicglue][] | v0.3.9 (build-env plugin) | +| [user-env-compile](https://github.com/motin/dokku-user-env-compile)2 | [motin][] | v0.3.9 (build-env plugin) | 1 Conflicts with [VHOSTS Custom Configuration](https://github.com/neam/dokku-nginx-vhosts-custom-configuration) 2 Similar to the heroku-labs feature (see https://devcenter.heroku.com/articles/labs-user-env-compile) From 295c897b7eee3eedf8c95afd324efcf20df36eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wendt?= Date: Thu, 2 Apr 2015 09:27:10 +0200 Subject: [PATCH 20/22] Make port forwarding configurable --- Vagrantfile | 5 +++-- docs/getting-started/install/vagrant.md | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index ba7b7352a..d0cd2fad5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -6,6 +6,7 @@ BOX_URI = ENV["BOX_URI"] || "https://cloud-images.ubuntu.com/vagrant/trusty/curr BOX_MEMORY = ENV["BOX_MEMORY"] || "1024" DOKKU_DOMAIN = ENV["DOKKU_DOMAIN"] || "dokku.me" DOKKU_IP = ENV["DOKKU_IP"] || "10.0.0.2" +FORWARDED_PORT = (ENV["FORWARDED_PORT"] || '8080').to_i PREBUILT_STACK_URL = File.exist?("#{File.dirname(__FILE__)}/stack.tgz") ? 'file:///root/dokku/stack.tgz' : nil PUBLIC_KEY_PATH = "#{Dir.home}/.ssh/id_rsa.pub" @@ -32,7 +33,7 @@ Vagrant::configure("2") do |config| config.vm.define "empty", autostart: false config.vm.define "dokku", primary: true do |vm| - vm.vm.network :forwarded_port, guest: 80, host: 8080 + vm.vm.network :forwarded_port, guest: 80, host: FORWARDED_PORT vm.vm.hostname = "#{DOKKU_DOMAIN}" vm.vm.network :private_network, ip: DOKKU_IP vm.vm.provision :shell, :inline => "apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" @@ -40,7 +41,7 @@ Vagrant::configure("2") do |config| end config.vm.define "dokku-deb", autostart: false do |vm| - vm.vm.network :forwarded_port, guest: 80, host: 8080 + vm.vm.network :forwarded_port, guest: 80, host: ENV['FORWARDED_PORT'] vm.vm.hostname = "#{DOKKU_DOMAIN}" vm.vm.network :private_network, ip: DOKKU_IP vm.vm.provision :shell, :inline => "cd /root/dokku && make install-from-deb" diff --git a/docs/getting-started/install/vagrant.md b/docs/getting-started/install/vagrant.md index adcf395ee..6dd618caf 100644 --- a/docs/getting-started/install/vagrant.md +++ b/docs/getting-started/install/vagrant.md @@ -21,7 +21,8 @@ # - `BOX_URI` # - `BOX_MEMORY` # - `DOKKU_DOMAIN` - # - `DOKKU_IP`. + # - `DOKKU_IP` + # - `FORWARDED_PORT`. cd path/to/dokku vagrant up ``` From ba33c161f5cb360487488ef947636ee96afab6ef Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 3 Apr 2015 10:51:23 -0700 Subject: [PATCH 21/22] make docker-options adhere to DOKKU_NOT_IMPLEMENTED_EXIT pattern --- dokku | 6 +++--- plugins/docker-options/commands | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dokku b/dokku index 3b4a7c26a..39d6d9781 100755 --- a/dokku +++ b/dokku @@ -177,17 +177,17 @@ EOF implemented=0 for script in $PLUGIN_PATH/*/commands; do set +e; $script "$@" ; exit_code=$? ; set -e - if [ "$exit_code" -eq "$DOKKU_NOT_IMPLEMENTED_EXIT" ]; then + if [[ "$exit_code" -eq "$DOKKU_NOT_IMPLEMENTED_EXIT" ]]; then continue fi implemented=1 - if [ "$exit_code" -ne "$DOKKU_VALID_EXIT" ]; then + if [[ "$exit_code" -ne "$DOKKU_VALID_EXIT" ]]; then exit $exit_code fi done - if [ "$implemented" -eq 0 ]; then + if [[ "$implemented" -eq 0 ]]; then dokku_log_warn "\`$*\` is not a dokku command." dokku_log_warn "See \`dokku help\` for a list of available commands." exit 1 diff --git a/plugins/docker-options/commands b/plugins/docker-options/commands index d2cc8b496..46bc8a8c0 100755 --- a/plugins/docker-options/commands +++ b/plugins/docker-options/commands @@ -146,4 +146,8 @@ case "$1" in EOF ;; + *) + exit $DOKKU_NOT_IMPLEMENTED_EXIT + ;; + esac From c2053d532277eb00b1db074bebd203af12e0136e Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 3 Apr 2015 12:13:39 -0700 Subject: [PATCH 22/22] support dockerfiles without expose command. closes #1083 --- plugins/00_dokku-standard/commands | 2 +- tests.mk | 5 ++++ tests/apps/dockerfile-noexpose/CHECKS | 1 + tests/apps/dockerfile-noexpose/Dockerfile | 13 +++++++++ tests/apps/dockerfile-noexpose/check_deploy | 2 ++ tests/apps/dockerfile-noexpose/index.js | 13 +++++++++ tests/apps/dockerfile-noexpose/package.json | 29 +++++++++++++++++++++ 7 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/apps/dockerfile-noexpose/CHECKS create mode 100644 tests/apps/dockerfile-noexpose/Dockerfile create mode 100755 tests/apps/dockerfile-noexpose/check_deploy create mode 100644 tests/apps/dockerfile-noexpose/index.js create mode 100644 tests/apps/dockerfile-noexpose/package.json diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 6f8ca6642..6fec1ff02 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -35,7 +35,7 @@ case "$1" in dockerfile) # extract first port from Dockerfile - DOCKERFILE_PORT=$(grep EXPOSE Dockerfile | head -1 | awk '{ print $2 }') + DOCKERFILE_PORT=$(grep EXPOSE Dockerfile | head -1 | awk '{ print $2 }' || true) [[ -n "$DOCKERFILE_PORT" ]] && dokku config:set-norestart $APP DOKKU_DOCKERFILE_PORT=$DOCKERFILE_PORT # sticking with same pattern of building app image before pre-build for now. diff --git a/tests.mk b/tests.mk index a1d7e62b3..5c1931e54 100644 --- a/tests.mk +++ b/tests.mk @@ -75,6 +75,10 @@ deploy-test-dockerfile: @echo deploying dockerfile app... cd tests && ./test_deploy ./apps/dockerfile dokku.me +deploy-test-dockerfile-noexpose: + @echo deploying dockerfile-noexpose app... + cd tests && ./test_deploy ./apps/dockerfile-noexpose dokku.me + deploy-test-gitsubmodules: @echo deploying gitsubmodules app... cd tests && ./test_deploy ./apps/gitsubmodules dokku.me @@ -125,6 +129,7 @@ deploy-tests: @$(QUIET) $(MAKE) deploy-test-config @$(QUIET) $(MAKE) deploy-test-clojure @$(QUIET) $(MAKE) deploy-test-dockerfile + @$(QUIET) $(MAKE) deploy-test-dockerfile-noexpose @$(QUIET) $(MAKE) deploy-test-gitsubmodules @$(QUIET) $(MAKE) deploy-test-go @$(QUIET) $(MAKE) deploy-test-java diff --git a/tests/apps/dockerfile-noexpose/CHECKS b/tests/apps/dockerfile-noexpose/CHECKS new file mode 100644 index 000000000..6439da05f --- /dev/null +++ b/tests/apps/dockerfile-noexpose/CHECKS @@ -0,0 +1 @@ +/ Hello World! diff --git a/tests/apps/dockerfile-noexpose/Dockerfile b/tests/apps/dockerfile-noexpose/Dockerfile new file mode 100644 index 000000000..2580af6d3 --- /dev/null +++ b/tests/apps/dockerfile-noexpose/Dockerfile @@ -0,0 +1,13 @@ +FROM ubuntu:trusty +ENV LC_ALL C +ENV DEBIAN_FRONTEND noninteractive +ENV DEBCONF_NONINTERACTIVE_SEEN true + +RUN apt-get install -y software-properties-common && add-apt-repository ppa:chris-lea/node.js && apt-get update +RUN apt-get install -y build-essential curl postgresql-client-9.3 nodejs git + +COPY . /app +WORKDIR /app +RUN npm install + +CMD npm start diff --git a/tests/apps/dockerfile-noexpose/check_deploy b/tests/apps/dockerfile-noexpose/check_deploy new file mode 100755 index 000000000..63a809e1f --- /dev/null +++ b/tests/apps/dockerfile-noexpose/check_deploy @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!" diff --git a/tests/apps/dockerfile-noexpose/index.js b/tests/apps/dockerfile-noexpose/index.js new file mode 100644 index 000000000..90221112f --- /dev/null +++ b/tests/apps/dockerfile-noexpose/index.js @@ -0,0 +1,13 @@ +var express = require('express') +var app = express(); + +app.set('port', (process.env.PORT || 5000)) +app.use(express.static(__dirname + '/public')) + +app.get('/', function(request, response) { + response.send('Hello World!') +}) + +app.listen(app.get('port'), function() { + console.log("Node app is running at localhost:" + app.get('port')) +}) diff --git a/tests/apps/dockerfile-noexpose/package.json b/tests/apps/dockerfile-noexpose/package.json new file mode 100644 index 000000000..29e7c9f3e --- /dev/null +++ b/tests/apps/dockerfile-noexpose/package.json @@ -0,0 +1,29 @@ +{ + "name": "node-js-sample", + "version": "0.1.0", + "description": "A sample Node.js app using Express 4", + "main": "index.js", + "scripts": { + "start": "node index.js" + }, + "dependencies": { + "express": "^4.0.0" + }, + "engines": { + "node": "0.10.x" + }, + "repository": { + "type": "git", + "url": "https://github.com/heroku/node-js-sample" + }, + "keywords": [ + "node", + "heroku", + "express" + ], + "author": "Mark Pundsack", + "contributors": [ + "Zeke Sikelianos (http://zeke.sikelianos.com)" + ], + "license": "MIT" +}