diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..c80200c1d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +root = true + +[*] +insert_final_newline = true +indent_style = space +indent_size = 2 diff --git a/HISTORY.md b/HISTORY.md index 085f7977f..bacb60464 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,8 +1,58 @@ # History -## 0.3.0 (in progress) +## 0.3.1 + +- 647b2157: @josegonzalez Update HISTORY.md for 0.3.0 +- #359: @plietar Remove plugins before copying them again +- #573: @eriknomitch Use command instead of which for apt-get existential check in bootstrap.sh +- #579: @motin Plugin nginx-vhosts includes files in folder nginx.conf.d +- #607: @fbochu Use PLUGIN_PATH in dokku default case +- #617: @markstos Document what bootstrap.sh is doing +- #758: @josegonzalez Make ENV file readable only from dokku user. Closes #621 +- #699: @tombell Actually suppress the output from `git_archive_all` +- #702: @jazzzz Allows config:set to set parameters values with spaces +- #754: @josegonzalez Remove all references to Ubuntu 12.04. Refs #238 +- #755: @josegonzalez Setup dokku-installer within Vagrant VM on first provision +- #759: @josegonzalez Create an `apps` core plugin +- #760: @josegonzalez Formatting +- #761: @josegonzalez Add dokku-registry to list. Closes #716 +- #762: @josegonzalez Update template for dokku docs + +## 0.3.0 + +- Added git submodules support +- 969aed87: @jfrazelle Fix double brackets issue in nginx-vhosts install +- 42fee25f: @rhy-jot Mention 14.04 & 12.10 sunset +- 4f5fc586: @rhy-jot Update cipher list +- #276: @joliv Add dependencies hook - wingrunr21- #476: Added man page entry +- #522: @wingrunr21 Improve SSL support and implement SPDY +- #544: @jfrazelle if dokku.conf has not been created, create it +- #555: @jakubholynet Readme fix, Env vars only set at run time +- #562: @assaf Zero down-time deploy and server checks +- #571: @joliv Added man page plugin command + #601: @jazzzz Restart app only if config changed +- #628: @voronianski Update Vagrant box to trusty because of raring server issues +- #632: @jazzzz Fixed port when docker is start with --ip with an IP other than 0.0.0.0 +- #654: @cameron-martin Fixed variable name for RESTART +- #664: @alexernst Don't overwrite $APP/URL modified by plugins in post-deploy hook +- #665: @protomouse Explicitly install man-db +- #698: @tombell Help output formatting +- #701: @jazzzz Fix issues with single-letter config:set usage +- #703: @jazzzz Display help when invoking dokku with no parameter +- #706: @josegonzalez Consolidate documentation on viewthedocs +- #709: @rinti Grammar and spelling fixes +- #708: @josegonzalez Simplify vagrant workflow +- #717: @kristofsajdak Add dokku-registry to plugin list +- #718: @Coaxial Use https for installation instructions +- #721: @wrboyce Fix issue in plugins-install-dependencies +- #723: @ghostbar Let users know they are starting buildstep during installation +- #735: @andrewsomething Redirect to the app deployment docs on success. +- #745: @rcarmo Typo +- #746: @vincentfretin replace gitreceive by sshcommand in example url +- #748: @vincentfretin Link to proper blog url +- #749: @vincentfretin Fix app certificate directory in backup-import/export +- #750: @th4t Remove unintended phrase repetition in installation.md -* Added git submodules support ## 0.2.0 (2013-11-24) diff --git a/Makefile b/Makefile index cfac50ca2..fc3eaf439 100644 --- a/Makefile +++ b/Makefile @@ -6,17 +6,30 @@ STACK_URL ?= https://github.com/progrium/buildstep.git PREBUILT_STACK_URL ?= https://github.com/progrium/buildstep/releases/download/2014-03-08/2014-03-08_429d4a9deb.tar.gz DOKKU_ROOT ?= /home/dokku -.PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count +# If the first argument is "vagrant-dokku"... +ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS))) + # use the rest as arguments for "vagrant-dokku" + RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + # ...and turn them into do-nothing targets + $(eval $(RUN_ARGS):;@:) +endif + +.PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku all: # Type "make install" to install. -install: dependencies stack copyfiles plugins version +install: dependencies stack copyfiles plugin-dependencies plugins version copyfiles: addman cp dokku /usr/local/bin/dokku mkdir -p /var/lib/dokku/plugins - cp -r plugins/* /var/lib/dokku/plugins + find /var/lib/dokku/plugins -mindepth 2 -maxdepth 2 -name '.core' -printf '%h\0' | xargs -0 rm -Rf + find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do \ + rm -Rf /var/lib/dokku/plugins/$$plugin && \ + cp -R plugins/$$plugin /var/lib/dokku/plugins && \ + touch /var/lib/dokku/plugins/$$plugin/.core; \ + done addman: mkdir -p /usr/local/share/man/man1 @@ -26,6 +39,9 @@ addman: version: git describe --tags > ${DOKKU_ROOT}/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ${DOKKU_ROOT}/VERSION +plugin-dependencies: pluginhook + dokku plugins-install-dependencies + plugins: pluginhook docker dokku plugins-install @@ -41,26 +57,28 @@ pluginhook: dpkg -i /tmp/pluginhook_0.1.0_amd64.deb docker: aufs + apt-get install -qq -y curl egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku - curl https://get.docker.io/gpg | apt-key add - + curl --silent https://get.docker.io/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 - apt-get install -y lxc-docker-${DOCKER_VERSION} + apt-get install -qq -y lxc-docker-${DOCKER_VERSION} else - apt-get install -y lxc-docker + apt-get install -qq -y lxc-docker endif sleep 2 # give docker a moment i guess aufs: - lsmod | grep aufs || modprobe aufs || apt-get install -y linux-image-extra-`uname -r` + lsmod | grep aufs || modprobe aufs || apt-get install -qq -y linux-image-extra-`uname -r` > /dev/null stack: + @echo "Start building buildstep" ifdef BUILD_STACK @docker images | grep progrium/buildstep || (git clone ${STACK_URL} /tmp/buildstep && docker build -t progrium/buildstep /tmp/buildstep && rm -rf /tmp/buildstep) else - @docker images | grep progrium/buildstep || curl -L ${PREBUILT_STACK_URL} | gunzip -cd | docker import - progrium/buildstep + @docker images | grep progrium/buildstep || curl --silent -L ${PREBUILT_STACK_URL} | gunzip -cd | docker import - progrium/buildstep endif count: @@ -70,3 +88,19 @@ count: @find plugins -type f | xargs cat | wc -l @echo "Test lines:" @find tests -type f | xargs cat | wc -l + +dokku-installer: + test -f /var/lib/dokku/.dokku-installer-created || gem install rack -v 1.5.2 --no-rdoc --no-ri + test -f /var/lib/dokku/.dokku-installer-created || gem install rack-protection -v 1.5.3 --no-rdoc --no-ri + test -f /var/lib/dokku/.dokku-installer-created || gem install sinatra -v 1.4.5 --no-rdoc --no-ri + test -f /var/lib/dokku/.dokku-installer-created || gem install tilt -v 1.4.1 --no-rdoc --no-ri + test -f /var/lib/dokku/.dokku-installer-created || ruby /root/dokku/contrib/dokku-installer.rb onboot + test -f /var/lib/dokku/.dokku-installer-created || service dokku-installer start + test -f /var/lib/dokku/.dokku-installer-created || service nginx reload + test -f /var/lib/dokku/.dokku-installer-created || touch /var/lib/dokku/.dokku-installer-created + +vagrant-acl-add: + vagrant ssh -- sudo sshcommand acl-add dokku $(USER) + +vagrant-dokku: + vagrant ssh -- "sudo -H -u root bash -c 'dokku $(RUN_ARGS)'" diff --git a/README.md b/README.md index 480ae1183..ce422d53d 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # Dokku [![Build Status](https://travis-ci.org/progrium/dokku.png?branch=master)](https://travis-ci.org/progrium/dokku) -Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. +Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. Sponsored by our friends at [Deis](http://deis.io/). ## Requirements -- A fresh VM running either Ubuntu `14.04 x64` or `12.04 x64` +- A fresh VM running Ubuntu `14.04 x64` ## Installing To install the latest stable version of dokku, you can run the following bootstrapper command: - $ wget -qO- https://raw.github.com/progrium/dokku/v0.2.3/bootstrap.sh | sudo DOKKU_TAG=v0.2.3 bash + $ wget -qO- https://raw.github.com/progrium/dokku/v0.3.1/bootstrap.sh | sudo DOKKU_TAG=v0.3.1 bash ## Documentation @@ -20,6 +20,10 @@ Full documentation - including advanced installation docs - are available online You can use [Github Issues](https://github.com/progrium/dokku/issues), check [Troubleshooting](https://github.com/progrium/dokku/wiki/Troubleshooting) on the wiki, or join us on [freenode in #dokku](https://webchat.freenode.net/?channels=%23dokku) +## Sponsors + +Dokku is currently sponsored by the enterprise grade, multi-host PaaS project [Deis](http://deis.io/). + ## License MIT diff --git a/SPONSORS b/SPONSORS new file mode 100644 index 000000000..b910636d2 --- /dev/null +++ b/SPONSORS @@ -0,0 +1 @@ +Deis http://deis.io \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index 005f6c3b5..b47fde806 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -29,5 +29,6 @@ Vagrant::configure("2") do |config| vb.customize ["modifyvm", :id, "--memory", BOX_MEMORY] end - config.vm.provision :shell, :inline => "apt-get -y install git && cd /root/dokku && #{make_cmd}" + config.vm.provision :shell, :inline => "apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}" + config.vm.provision :shell, :inline => "cd /root/dokku && make dokku-installer" end diff --git a/bootstrap.sh b/bootstrap.sh old mode 100644 new mode 100755 index 0acc430a7..3950ef3fc --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,18 +1,22 @@ #!/usr/bin/env bash +# A script to bootstrap dokku. +# It expects to be run on Ubuntu 14.04 via 'sudo' +# It checks out the dokku source code from Github into ~/dokku and then runs 'make install' from dokku source. + set -eo pipefail export DEBIAN_FRONTEND=noninteractive export DOKKU_REPO=${DOKKU_REPO:-"https://github.com/progrium/dokku.git"} -if ! which apt-get &>/dev/null +if ! command -v apt-get &>/dev/null then echo "This installation script requires apt-get. For manual installation instructions, consult https://github.com/progrium/dokku ." exit 1 fi apt-get update -apt-get install -y git make curl software-properties-common +apt-get install -qq -y git make curl software-properties-common man-db -[[ `lsb_release -sr` == "12.04" ]] && apt-get install -y python-software-properties +[[ `lsb_release -sr` == "12.04" ]] && apt-get install -qq -y python-software-properties cd ~ && test -d dokku || git clone $DOKKU_REPO cd dokku diff --git a/contrib/dokku-installer.rb b/contrib/dokku-installer.rb index c8ce50227..6506fc176 100755 --- a/contrib/dokku-installer.rb +++ b/contrib/dokku-installer.rb @@ -3,120 +3,120 @@ require "sinatra" require "open3" if ARGV[0] == "onboot" - File.open("/etc/init/dokku-installer.conf", "w") do |f| - f.puts "start on runlevel [2345]" - f.puts "exec #{File.absolute_path(__FILE__)} selfdestruct" - end - File.open("/etc/nginx/conf.d/dokku-installer.conf", "w") do |f| - f.puts "upstream dokku-installer { server 127.0.0.1:2000; }" - f.puts "server {" - f.puts " listen 80;" - f.puts " location / {" - f.puts " proxy_pass http://dokku-installer;" - f.puts " }" - f.puts "}" - end - `rm /etc/nginx/sites-enabled/*` - puts "Installed Upstart service and default Nginx virtualhost for installer to run on boot." - exit + File.open("/etc/init/dokku-installer.conf", "w") do |f| + f.puts "start on runlevel [2345]" + f.puts "exec #{File.absolute_path(__FILE__)} selfdestruct" + end + File.open("/etc/nginx/conf.d/dokku-installer.conf", "w") do |f| + f.puts "upstream dokku-installer { server 127.0.0.1:2000; }" + f.puts "server {" + f.puts " listen 80;" + f.puts " location / {" + f.puts " proxy_pass http://dokku-installer;" + f.puts " }" + f.puts "}" + end + `rm /etc/nginx/sites-enabled/*` + puts "Installed Upstart service and default Nginx virtualhost for installer to run on boot." + exit end -version = "v0.2.1" -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 -template = DATA.read +version = "v0.3.1" +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 +template = DATA.read set :port, 2000 set :environment, :production disable :protection get "/" do - ERB.new(template).result binding + ERB.new(template).result binding end post "/setup" do - if params[:vhost] == "true" - File.open("#{dokku_root}/VHOST", "w") {|f| f.write params[:hostname] } - else - `rm #{dokku_root}/VHOST` - end - File.open("#{dokku_root}/HOSTNAME", "w") {|f| f.write params[:hostname] } - Open3.capture2("sshcommand acl-add dokku admin", :stdin_data => params[:key]) - Thread.new { - `rm /etc/nginx/conf.d/dokku-installer.conf && /etc/init.d/nginx stop && /etc/init.d/nginx start` - `rm /etc/init/dokku-installer.conf && stop dokku-installer` - }.run if ARGV[0] == "selfdestruct" + if params[:vhost] == "true" + File.open("#{dokku_root}/VHOST", "w") {|f| f.write params[:hostname] } + else + `rm #{dokku_root}/VHOST` + end + File.open("#{dokku_root}/HOSTNAME", "w") {|f| f.write params[:hostname] } + Open3.capture2("sshcommand acl-add dokku admin", :stdin_data => params[:key]) + Thread.new { + `rm /etc/nginx/conf.d/dokku-installer.conf && /etc/init.d/nginx stop && /etc/init.d/nginx start` + `rm /etc/init/dokku-installer.conf && stop dokku-installer` + }.run if ARGV[0] == "selfdestruct" end __END__ - Dokku Setup - - + Dokku Setup + + -
-
-

Dokku Setup <%= version %>

-
-

Admin Access

-
- -
-
-

Hostname Configuration

-
- - -
-
- -
-

Your app URLs will look like:

-
http://hostname:port
-
- -
-
-
- +
+
+

Dokku Setup <%= version %>

+
+

Admin Access

+
+ +
+
+

Hostname Configuration

+
+ + +
+
+ +
+

Your app URLs will look like:

+
http://hostname:port
+
+ +
+
+
+ diff --git a/docs/configuration-management.md b/docs/configuration-management.md index 119c058d9..242325167 100644 --- a/docs/configuration-management.md +++ b/docs/configuration-management.md @@ -11,3 +11,4 @@ config:set KEY1=VALUE1 [KEY2=VALUE2 ...] - set one or more config vars config:unset KEY1 [KEY2 ...] - unset one or more config vars ``` +The variables are by default available only at run time, i.e. not when the application is being built/compiled. However there are [plugins](http://progrium.viewdocs.io/dokku/plugins) that can change that. diff --git a/docs/index.md b/docs/index.md index 5479727e4..73fe4e06e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,6 +17,10 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. ## Things this project won't do - * **Multi-host.** Not a huge leap, but this isn't the project for it. Have a look at [Flynn](https://flynn.io/). - * **Multitenancy.** It's ready for it, but again, have a look at [Flynn](https://flynn.io/). + * **Multi-host.** Not a huge leap, but this isn't the project for it. Have a look at [Deis](http://deis.io/). + * **Multitenancy.** It's ready for it, but again, have a look at [Deis](http://deis.io/). * **Client app.** Given the constraints, running commands remotely via SSH is fine. + +## Sponsors + +Though we love everybody doing open source, we especially love [Deis](http://deis.io/) for sponsoring Dokku. diff --git a/docs/installation.md b/docs/installation.md index 62c5f9771..92f20125e 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -2,18 +2,16 @@ ## Requirements -- A fresh VM running either Ubuntu `14.04 x64` or `12.04 x64` +- A fresh VM running Ubuntu `14.04 x64` -Ubuntu 14.04 x64 or 12.04 x64. Ideally have a domain ready to point to your host. It's designed for and is probably best to use a fresh VM. The bootstrapper will install everything it needs. - -**Note: Support for 12.04 will be sunsetting in the near future after dokku & 14.04 have been more thoroughly tested.** +Ubuntu 14.04 x64 x64. Ideally have a domain ready to point to your host. It's designed for and is probably best to use a fresh VM. The bootstrapper will install everything it needs. ## Installing the latest Stable version To install the latest stable version of dokku, you can run the following bootstrapper command: ```bash -wget -qO- https://raw.github.com/progrium/dokku/v0.2.3/bootstrap.sh | sudo DOKKU_TAG=v0.2.3 bash +wget -qO- https://raw.github.com/progrium/dokku/v0.3.1/bootstrap.sh | sudo DOKKU_TAG=v0.3.1 bash ``` ## Configuring @@ -55,7 +53,7 @@ environment variables may be set to override the defaults (see the `Makefile` fo apply). Example: ```bash -sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/gitreceive make install +sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/sshcommand make install ``` ### Bootstrap a server from your own repository @@ -71,7 +69,7 @@ sudo DOKKU_REPO=https://github.com/yourusername/dokku.git ./bootstrap.sh ### Custom buildstep build -Dokku ships with a pre-built version of version of the [buildstep](https://github.com/progrium/buildstep) component by +Dokku ships with a pre-built version of the [buildstep](https://github.com/progrium/buildstep) component by default. If you want to build your own version you can specify that with an env variable. @@ -85,10 +83,10 @@ sudo BUILD_STACK=true make install - Download and install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) - Download and install [Vagrant](http://www.vagrantup.com/downloads.html) -- Download Dokku (latest stable) +- Clone Dokku ``` - wget https://github.com/progrium/dokku/archive/master.zip + git clone https://github.com/progrium/dokku.git ``` - Setup SSH hosts in your `/etc/hosts` @@ -115,11 +113,7 @@ sudo BUILD_STACK=true make install vagrant up ``` -- Add SSH key to Dokku using `sshcommand acl-add `, e.g.: - - ``` - cat ~/.ssh/id_rsa.pub | ssh -i ~/.vagrant.d/insecure_private_key vagrant@dokku.me "sudo sshcommand acl-add dokku progrium" - ``` +- Copy your SSH key via `cat ~/.ssh/id_rsa.pub | pbcopy` and paste it into the dokku-installer at http://dokku.me . Change the `Hostname` field on the Dokku Setup screen to your domain and then check the box that says `Use virtualhost naming`. Then click *Finish Setup* to install your key. You'll be directed to application deployment instructions from here. You are now ready to deploy an app or install plugins. diff --git a/docs/plugins.md b/docs/plugins.md index 4938cb478..c9207f96b 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -26,7 +26,7 @@ If you create your own plugin: 1. take a look at the plugins shipped with dokku and hack away! 2. upload your plugin to github with a repository name in form of `dokku-` (e.g. `dokku-mariadb`) 3. edit this page and add a link to it below! -4. subscribe to the [dokku development blog](http://progrium.com/dokku/) to be notified about API changes and releases +4. subscribe to the [dokku development blog](http://progrium.com) to be notified about API changes and releases ## Community plugins @@ -71,6 +71,7 @@ Note: The following plugins have been supplied by our community and may not have [cameron-martin]: https://github.com/cameron-martin [matto1990]: https://github.com/matto1990 [ohardy]: https://github.com/ohardy +[agco-adm]: https://github.com/agco-adm ### Datastores @@ -128,6 +129,7 @@ Note: The following plugins have been supplied by our community and may not have | [Volume (persistent storage)](https://github.com/ohardy/dokku-volume) | [ohardy][] | Compatible with 0.2.0 | | [user-env-compile](https://github.com/musicglue/dokku-user-env-compile)1 | [musicglue][] | Compatible with dokku master branch | | [user-env-compile](https://github.com/motin/dokku-user-env-compile)1 | [motin][] | Compatible with 0.2.1 | +| [registry](https://github.com/agco-adm/dokku-registry)5 | [agco-adm](https://github.com/agco-adm) | | | [SSH Deployment Keys](https://github.com/cedricziel/dokku-deployment-keys)2 | [cedricziel][] | 2014-01-17: compatible with upstream/master | | [SSH Hostkeys](https://github.com/cedricziel/dokku-hostkeys-plugin)3 | [cedricziel][] | 2014-01-17: compatible with upstream/master | | [Link Containers](https://github.com/rlaneve/dokku-link) | [rlaneve][] | Requires dokku >= [c77cbf1][] | @@ -139,11 +141,12 @@ Note: The following plugins have been supplied by our community and may not have | [Debug](https://github.com/heichblatt/dokku-debug) | [heichblatt][] | | | [Pre-Deploy Tasks](https://github.com/michaelshobbs/dokku-app-predeploy-tasks) | [michaelshobbs][] | | | [Hostname](https://github.com/michaelshobbs/dokku-hostname) | [michaelshobbs][] | | -| [VHOSTS Custom Configuration](https://github.com/neam/dokku-nginx-vhosts-custom-configuration) | [motin][] | Requires https://github.com/progrium/dokku/pull/579 | +| [VHOSTS Custom Configuration](https://github.com/neam/dokku-nginx-vhosts-custom-configuration) | [motin][] | Compatible with 0.3.1+ | | [Multiple domains and per-app custom nginx.conf](https://github.com/mikexstudios/dokku-nginx-alt) | [mikexstudios][] | Works with v0.2.3 | | [Supply env vars to buildpacks](https://github.com/cameron-martin/dokku-build-env)| [cameron-martin][] | Works with v0.2.3 | | [HTTP Auth Secure Apps](https://github.com/matto1990/dokku-secure-apps) | [matto1990][] | Works with v0.2.3 | | [app-url](https://github.com/mikecsh/dokku-app-url) | [mikecsh](https://github.com/mikecsh) | Works with 0.2.0 | +| [dokku-registry](https://github.com/agco-adm/dokku-registry) | [agco-adm][] | | [8fca220]: https://github.com/progrium/dokku/commit/8fca2204edb0017796d6915ca9157c05b1238e28 [217d00a]: https://github.com/progrium/dokku/commit/217d00a1bc47a7e24d8847617bb08a1633025fc7 @@ -158,6 +161,8 @@ Note: The following plugins have been supplied by our community and may not have 4 Conflicts with [VHOSTS Custom Configuration](https://github.com/neam/dokku-nginx-vhosts-custom-configuration) +5 On Heroku similar functionality is offered by the [heroku-labs pipeline feature](https://devcenter.heroku.com/articles/labs-pipelines), which allows you to promote builds across multiple environments (staging -> production) + ### Other Add-ons | Plugin | Author | Compatibility | diff --git a/docs/template.html b/docs/template.html new file mode 100644 index 000000000..a66d9b40b --- /dev/null +++ b/docs/template.html @@ -0,0 +1,98 @@ + + + + {{NAME}} :: viewdocs.io + + + + + + +
+
+

{{NAME}} :: index

+
+
+ {{CONTENT}} +
+
+ + + + + + diff --git a/dokku b/dokku index 35e644218..2f0ec3b93 100755 --- a/dokku +++ b/dokku @@ -7,11 +7,17 @@ export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"} [[ $DOKKU_TRACE ]] && set -x -if [[ $(id -un) != "dokku" && $1 != "plugins-install" ]]; then +if [[ $(id -un) != "dokku" && $1 != plugins-install* ]]; then sudo -u dokku -H $0 "$@" exit fi +if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then + export -n SSH_ORIGINAL_COMMAND + $0 $SSH_ORIGINAL_COMMAND + exit $? +fi + case "$1" in receive) APP="$2"; IMAGE="dokku/$APP" @@ -64,7 +70,7 @@ case "$1" in # start the app DOCKER_ARGS=$(: | pluginhook docker-args $APP) id=$(docker run -d -p 5000 -e PORT=5000 $DOCKER_ARGS $IMAGE /bin/bash -c "/start web") - port=$(docker port $id 5000 | sed 's/0.0.0.0://') + port=$(docker port $id 5000 | sed 's/[0-9.]*://') # if we can't post-deploy successfully, kill new container function kill_new { @@ -77,15 +83,16 @@ case "$1" in trap kill_new INT TERM EXIT echo "-----> Running pre-flight checks" pluginhook check-deploy $id $APP $port - echo "-----> Running post-deploy" - pluginhook post-deploy $APP $port - trap - INT TERM EXIT # now using the new container echo $id > "$DOKKU_ROOT/$APP/CONTAINER" echo $port > "$DOKKU_ROOT/$APP/PORT" echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL" + echo "-----> Running post-deploy" + pluginhook post-deploy $APP $port + trap - INT TERM EXIT + # kill the old container if [[ -n "$oldid" ]]; then # Let the old container finish processing requests, before terminating it @@ -106,9 +113,9 @@ case "$1" in cleanup) # delete all non-running container - docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm &> /dev/null & + docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm &> /dev/null & # delete unused images - docker images | grep '' | awk '{print $3}' | xargs docker rmi &> /dev/null & + docker images | grep '' | awk '{print $3}' | xargs docker rmi &> /dev/null & ;; plugins) @@ -119,24 +126,28 @@ case "$1" in pluginhook install ;; + plugins-install-dependencies) + pluginhook dependencies + ;; + # temporary hack for https://github.com/progrium/dokku/issues/82 deploy:all) - for app in $(ls -d $DOKKU_ROOT/*/); do - APP=$(basename $app); + for app in $(ls -d $DOKKU_ROOT/*/CONTAINER); do + APP=$(basename $(dirname $app)); dokku deploy $APP done ;; help|'') cat< $TARGET_DIR/.ssh/authorized_keys - chmod 0700 $TARGET_DIR/.ssh - chmod 0600 $TARGET_DIR/.ssh/* + mkdir -p $TARGET_DIR/.ssh + cat $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys | uniq > $TARGET_DIR/.ssh/authorized_keys + chmod 0700 $TARGET_DIR/.ssh + chmod 0600 $TARGET_DIR/.ssh/* fi [[ -f $IMPORT_DIR/HOSTNAME ]] && mv $IMPORT_DIR/HOSTNAME $TARGET_DIR/HOSTNAME [[ -f $IMPORT_DIR/VHOST ]] && mv $IMPORT_DIR/VHOST $TARGET_DIR/VHOST diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 1d981fc2e..8e4c36cb9 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -1,28 +1,9 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + case "$1" in delete) - if [[ -z $2 ]]; then - echo "Please specify an app to delete" - exit 1 - fi - APP="$2"; IMAGE="dokku/$APP"; - if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then - echo "App does not exist" - exit 1 - fi - - pluginhook pre-delete $APP - if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then - ID=$(< "$DOKKU_ROOT/$APP/CONTAINER") - - docker stop $ID > /dev/null || true - docker rm $ID > /dev/null || true - fi - - docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null & - - pluginhook post-delete $APP + dokku apps:destroy $2 ;; logs) @@ -50,13 +31,13 @@ case "$1" in run) if [[ -z $2 ]]; then - echo "Please specify an app to run the command on" - exit 1 + echo "Please specify an app to run the command on" + exit 1 fi APP="$2"; IMAGE="dokku/$APP" if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then - echo "App $APP does not exist" - exit 1 + echo "App $APP does not exist" + exit 1 fi shift 2 @@ -67,8 +48,8 @@ case "$1" in url) APP="$2"; if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then - echo "App $APP does not exist" - exit 1 + echo "App $APP does not exist" + exit 1 fi if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then @@ -85,7 +66,6 @@ case "$1" in help) cat && cat< Delete an application logs [-t] Show the last logs for an application (-t follows) run Run a command in the environment of an application url Show the URL for an application @@ -94,4 +74,3 @@ EOF ;; esac - diff --git a/plugins/00_dokku-standard/install b/plugins/00_dokku-standard/install index bc804f546..9625e8fdc 100755 --- a/plugins/00_dokku-standard/install +++ b/plugins/00_dokku-standard/install @@ -2,7 +2,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then - echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME + echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME fi # temporary hack for https://github.com/progrium/dokku/issues/82 diff --git a/plugins/00_dokku-standard/pre-delete b/plugins/00_dokku-standard/pre-delete deleted file mode 100755 index 5a14726e3..000000000 --- a/plugins/00_dokku-standard/pre-delete +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - -APP="$1" -IMAGE=dokku/"$1" -CACHE_DIR="$DOKKU_ROOT/$APP/cache" - -docker run -v $CACHE_DIR:/cache $IMAGE find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; - - diff --git a/plugins/apps/commands b/plugins/apps/commands new file mode 100755 index 000000000..673238045 --- /dev/null +++ b/plugins/apps/commands @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +case "$1" in + apps) + echo "=== My Apps" + find $DOKKU_ROOT -maxdepth 1 -type d \( ! -iname ".*" \) -not -path $DOKKU_ROOT/tls | sed 's|^\./||g' | sed 's|'$DOKKU_ROOT'\/||' | tail -n +2 | sort + ;; + + apps:create) + if [[ -z $2 ]]; then + echo "Please specify an app to create" + exit 1 + fi + APP="$2" + if [[ -d "$DOKKU_ROOT/$APP" ]]; then + echo " ! Name is already taken" + exit 1 + fi + + mkdir -p "$DOKKU_ROOT/$APP" + echo "Creating $APP... done" + ;; + + apps:destroy) + if [[ -z $2 ]]; then + echo "Please specify an app to delete" + exit 1 + fi + APP="$2"; IMAGE="dokku/$APP"; + if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then + echo "App $APP does not exist" + exit 1 + fi + + if [[ "$APP" == "tls" ]]; then + echo "Unable to destroy tls directory" + exit 1 + fi + + echo " ! WARNING: Potentially Destructive Action" + echo " ! This command will destroy $APP (including all add-ons)." + echo " ! To proceed, type \"$APP\"" + echo "" + + read -p "> " app_name + if [[ "$app_name" != "$APP" ]]; then + echo " ! Confirmation did not match $APP. Aborted." + exit 1 + fi + + echo "Destroying $APP (including all add-ons)" + + pluginhook pre-delete $APP + if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then + ID=$(< "$DOKKU_ROOT/$APP/CONTAINER") + + docker stop $ID > /dev/null || true + docker rm $ID > /dev/null || true + fi + + docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null & + + pluginhook post-delete $APP + ;; + + help) + cat && cat< Create a new app + apps:destroy Permanently destroy an app +EOF + ;; + +esac diff --git a/plugins/00_dokku-standard/post-delete b/plugins/apps/post-delete similarity index 99% rename from plugins/00_dokku-standard/post-delete rename to plugins/apps/post-delete index 6b6829284..b164bb44b 100755 --- a/plugins/00_dokku-standard/post-delete +++ b/plugins/apps/post-delete @@ -1,3 +1,4 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + [[ -n $1 ]] && rm -r "$DOKKU_ROOT/$1" > /dev/null diff --git a/plugins/apps/pre-delete b/plugins/apps/pre-delete new file mode 100755 index 000000000..fa031488d --- /dev/null +++ b/plugins/apps/pre-delete @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +APP="$1"; IMAGE="dokku/$APP"; CACHE_DIR="$DOKKU_ROOT/$APP/cache" +if [[ -d $CACHE_DIR ]]; then + docker run -v "$CACHE_DIR:/cache" "$IMAGE" find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; +fi diff --git a/plugins/backup/commands b/plugins/backup/commands index 9aa6cdc65..4c41037fc 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + CURRENT_BACKUP_VERSION=1 -set -e; case "$1" in + +case "$1" in backup:export) OUTPUT_FILE="$2" BACKUP_DIR="$DOKKU_ROOT" @@ -24,9 +26,9 @@ set -e; case "$1" in # if no file specified, output to stdout if [[ -z $OUTPUT_FILE ]]; then - cat $BACKUP_TMP_FILE + cat $BACKUP_TMP_FILE else - mv $BACKUP_TMP_FILE $OUTPUT_FILE + mv $BACKUP_TMP_FILE $OUTPUT_FILE fi rm -rf $BACKUP_TMP_DIR @@ -48,14 +50,14 @@ set -e; case "$1" in tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then - echo "Unable to determine backup version" - exit 1 + echo "Unable to determine backup version" + exit 1 fi VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version) if [[ $VERSION -ne 1 ]]; then - echo "Unknown format version $VERSION" - exit 1 + echo "Unknown format version $VERSION" + exit 1 fi echo "Importing a version $VERSION backup..." @@ -91,4 +93,3 @@ EOF ;; esac - diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index 6db3f6444..00346af5b 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -14,6 +14,7 @@ # in seconds). set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + CONTAINERID="$1"; APP="$2"; PORT="$3" ; HOSTNAME="${4:-localhost}" # source in app env to get DOKKU_CHECKS_WAIT and any other necessary vars @@ -27,23 +28,23 @@ WAIT="${DOKKU_CHECKS_WAIT:-5}" # after successfully copying the file. Thus, we suppress stderr. # ref: https://github.com/dotcloud/docker/issues/3986 if [[ ! -f "$FILENAME" ]] ; then - echo " check-deploy: $FILENAME not found. attempting to retrieve it from container ..." - TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX) - docker cp $CONTAINERID:/app/CHECKS $TMPDIR 2> /dev/null || true - if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then - echo " CHECKS file not found in container. skipping checks." - rm -rf $TMPDIR - exit 0 - else - echo " CHECKS file found in container" - FILENAME=${TMPDIR}/CHECKS + echo " check-deploy: $FILENAME not found. attempting to retrieve it from container ..." + TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX) + docker cp $CONTAINERID:/app/CHECKS $TMPDIR 2> /dev/null || true + if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then + echo " CHECKS file not found in container. skipping checks." + rm -rf $TMPDIR + exit 0 + else + echo " CHECKS file found in container" + FILENAME=${TMPDIR}/CHECKS - function cleanup() { - echo " removing CHECKS file copied from container" - rm -rf $TMPDIR - } - trap cleanup EXIT - fi + function cleanup() { + echo " removing CHECKS file copied from container" + rm -rf $TMPDIR + } + trap cleanup EXIT + fi fi echo "Waiting $WAIT seconds ..." diff --git a/plugins/config/backup-export b/plugins/config/backup-export index 68b5c0393..bc709ce83 100755 --- a/plugins/config/backup-export +++ b/plugins/config/backup-export @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + shopt -s nullglob VERSION="$1" BASE_DIR="$2" diff --git a/plugins/config/backup-import b/plugins/config/backup-import index 9ed3b1eca..7652df515 100755 --- a/plugins/config/backup-import +++ b/plugins/config/backup-import @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + shopt -s nullglob VERSION="$1" IMPORT_DIR="$2" @@ -7,5 +8,5 @@ TARGET_DIR="$3" cd $IMPORT_DIR for file in */ENV; do - cp $file "$TARGET_DIR/$file" + cp $file "$TARGET_DIR/$file" done diff --git a/plugins/config/commands b/plugins/config/commands index f2f38f136..724fb58c9 100755 --- a/plugins/config/commands +++ b/plugins/config/commands @@ -9,6 +9,7 @@ if [[ $1 == config ]] || [[ $1 == config:* ]]; then else APP="$2" ENV_FILE="$DOKKU_ROOT/$APP/ENV" + ENV_FILE_TEMP="$DOKKU_ROOT/$APP/ENV.tmp" # Check if app exists with the same name if [ ! -d "$DOKKU_ROOT/$APP" ]; then @@ -24,19 +25,20 @@ if [[ $1 == config ]] || [[ $1 == config:* ]]; then fi config_styled_hash () { - vars=`echo -e "$1"` + vars="$1" + prefix="$2" longest="" - for word in $vars; do + while read -r word; do KEY=`echo $word | cut -d"=" -f1` if [ ${#KEY} -gt ${#longest} ]; then longest=$KEY fi - done + done <<< "$vars" - for word in $vars; do + while read -r word; do KEY=`echo $word | cut -d"=" -f1` - VALUE=`echo $word | cut -d"=" -f2-` + VALUE=`echo $word | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//"` num_zeros=$((${#longest} - ${#KEY})) zeros=" " @@ -44,23 +46,35 @@ config_styled_hash () { zeros="$zeros " num_zeros=$(($num_zeros - 1)) done - echo "$KEY:$zeros$VALUE" - done + echo "$prefix$KEY:$zeros$VALUE" + done <<< "$vars" } config_restart_app() { APP="$1"; - echo "-----> Releasing $APP ..." - dokku release $APP - echo "-----> Release complete!" - echo "-----> Deploying $APP ..." - dokku deploy $APP - echo "-----> Deploy complete!" + if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then + echo "-----> Releasing $APP ..." + dokku release $APP + echo "-----> Release complete!" + echo "-----> Deploying $APP ..." + dokku deploy $APP + echo "-----> Deploy complete!" + fi +} + +config_write() { + ENV_TEMP="$1" + echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP + if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then + cp -f $ENV_FILE_TEMP $ENV_FILE + chmod 600 $ENV_FILE + config_restart_app $APP + fi + rm -f $ENV_FILE_TEMP } case "$1" in - config) APP="$2" @@ -69,7 +83,7 @@ case "$1" in exit 1 fi - VARS=`cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | cut -d" " -f2` + VARS=`cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | cut -d" " -f2-` for var in "$@"; do if [[ "$var" == "--shell" ]]; then @@ -95,7 +109,7 @@ case "$1" in KEY="$3" - cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | cut -d" " -f2 | grep "^$KEY=" | cut -d"=" -f2- + cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | grep "^export $KEY=" | cut -d"=" -f2- | sed -e "s/^'//" -e "s/'$//" ;; config:set) @@ -108,10 +122,10 @@ case "$1" in APP="$2"; APP_DIR="$DOKKU_ROOT/$APP" ENV_ADD="" ENV_TEMP=`cat "${ENV_FILE}"` - RESTART=false - VARS="${*:3}" + RESTART_APP=false + shift 2 - for var in $VARS; do + for var; do if [[ $var != *"="* ]]; then echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]" echo "Must specify KEY and VALUE to set." @@ -119,25 +133,26 @@ case "$1" in fi done - for var in $VARS; do + for var; do KEY=`echo ${var} | cut -d"=" -f1` VALUE=`echo ${var} | cut -d"=" -f2-` if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then RESTART_APP=true ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $KEY=/ d") - ENV_TEMP="${ENV_TEMP}\nexport ${var}" + ENV_TEMP="${ENV_TEMP}\nexport $KEY='$VALUE'" ENV_ADD=$(echo -e "${ENV_ADD}" | sed "/^$KEY=/ d") - ENV_ADD="${ENV_ADD}\n${var}" + ENV_ADD="${ENV_ADD}$ +${var}" fi done + ENV_ADD=$(echo "$ENV_ADD" | tail -n +2) #remove first empty line if [ $RESTART_APP ]; then echo "-----> Setting config vars and restarting $APP" - config_styled_hash "$ENV_ADD" + config_styled_hash "$ENV_ADD" " " - echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE - config_restart_app $APP + config_write "$ENV_TEMP" fi ;; @@ -156,19 +171,17 @@ case "$1" in echo "-----> Unsetting $var and restarting $APP" ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $var=/ d") - echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE - config_restart_app $APP + config_write "$ENV_TEMP" done ;; help) cat && cat< display the config vars for an app - config:get KEY display a config value for an app - config:set KEY1=VALUE1 [KEY2=VALUE2 ...] set one or more config vars - config:unset KEY1 [KEY2 ...] unset one or more config vars + config Display the config vars for an app + config:get KEY Display a config value for an app + config:set KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars + config:unset KEY1 [KEY2 ...] Unset one or more config vars EOF ;; esac - diff --git a/plugins/git/backup-import b/plugins/git/backup-import index 6d4a30a10..8d40fd316 100755 --- a/plugins/git/backup-import +++ b/plugins/git/backup-import @@ -1,18 +1,20 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + VERSION="$1" IMPORT_DIR="$2" TARGET_DIR="$3" APPS="$4" -while read APP; do - APP_PATH="$TARGET_DIR/$APP"; - git init --bare $APP_PATH > /dev/null - PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" - cat > $PRERECEIVE_HOOK < /dev/null + PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" + cat > $PRERECEIVE_HOOK < /dev/null diff --git a/plugins/git/commands b/plugins/git/commands index 92daf1693..0b90005e5 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -2,19 +2,19 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x git_archive_all() { - APP=$1; REV=$2 - TMP_WORK_DIR=$(mktemp -d) - chmod 755 $TMP_WORK_DIR - unset GIT_DIR GIT_WORK_TREE - git clone $DOKKU_ROOT/$APP $TMP_WORK_DIR > /dev/null - pushd $TMP_WORK_DIR > /dev/null - git config advice.detachedHead false - git checkout $REV > /dev/null - git submodule update --init --recursive > /dev/null - find -name .git -prune -exec rm -rf {} \; > /dev/null - tar c . - popd > /dev/null - rm -rf $TMP_WORK_DIR > /dev/null + APP=$1; REV=$2 + TMP_WORK_DIR=$(mktemp -d) + chmod 755 $TMP_WORK_DIR + unset GIT_DIR GIT_WORK_TREE + git clone $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null + pushd $TMP_WORK_DIR > /dev/null + git config advice.detachedHead false + git checkout $REV &> /dev/null + git submodule update --init --recursive &> /dev/null + find -name .git -prune -exec rm -rf {} \; > /dev/null + tar c . + popd > /dev/null + rm -rf $TMP_WORK_DIR > /dev/null } case "$1" in @@ -31,7 +31,6 @@ case "$1" in echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master." echo $'\e[1G\e[K'"-----> for example, try 'git push ${refname/refs\/heads\/}:master'" fi - done ;; @@ -40,14 +39,15 @@ case "$1" in APP_PATH=$DOKKU_ROOT/$APP if [[ $1 == "git-receive-pack" && ! -d "$APP_PATH/refs" ]]; then - git init --bare $APP_PATH > /dev/null - PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" - cat > $PRERECEIVE_HOOK < /dev/null + PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" + cat > $PRERECEIVE_HOOK < /dev/null diff --git a/plugins/nginx-vhosts/post-deploy b/plugins/nginx-vhosts/post-deploy index 1e0b1e7fe..19d5f04fc 100755 --- a/plugins/nginx-vhosts/post-deploy +++ b/plugins/nginx-vhosts/post-deploy @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + APP="$1"; PORT="$2" WILDCARD_SSL="$DOKKU_ROOT/tls" SSL="$DOKKU_ROOT/$APP/tls" @@ -56,6 +57,7 @@ $SSL_DIRECTIVES proxy_set_header X-Forwarded-Port \$server_port; proxy_set_header X-Request-Start \$msec; } + include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf; } EOF @@ -79,6 +81,7 @@ server { proxy_set_header X-Forwarded-Port \$server_port; proxy_set_header X-Request-Start \$msec; } + include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf; } EOF diff --git a/tests/apps/config/check_deploy b/tests/apps/config/check_deploy index 4047ea6b8..57e2a697a 100755 --- a/tests/apps/config/check_deploy +++ b/tests/apps/config/check_deploy @@ -1,3 +1,15 @@ #!/bin/bash -set -e; output="$(curl -s $1)"; echo $output; test "$output" == "config-test" +set -e; +base_url="$1" +test_url / "config-test" +test_url /hello "Hello world" + +test_url () { + path="$1" + expected_output="$2" + url="$base_url$path" + output="$(curl -s $url)" + echo $output + test "$output" == "$expected_output" +} \ No newline at end of file diff --git a/tests/apps/config/post-deploy b/tests/apps/config/post-deploy index d0080c7a9..440051a2c 100755 --- a/tests/apps/config/post-deploy +++ b/tests/apps/config/post-deploy @@ -4,5 +4,5 @@ set -ex; REMOTE=$1 REPO=$2 -ssh $REMOTE config:set $REPO CONFTEST=config-test +ssh $REMOTE config:set $REPO CONFTEST=config-test HELLO=\"Hello world\" diff --git a/tests/apps/config/web.js b/tests/apps/config/web.js index 3b5050b1f..774ece28b 100644 --- a/tests/apps/config/web.js +++ b/tests/apps/config/web.js @@ -6,6 +6,10 @@ app.get('/', function(request, response) { response.send(process.env.CONFTEST); }); +app.get('/hello', function(request, response) { + response.send(process.env.HELLO); +}); + var port = process.env.PORT || 5000; app.listen(port, function() { console.log("Listening on " + port); diff --git a/tests/ci/receiver b/tests/ci/receiver index 710a01df0..2d3db4aac 100755 --- a/tests/ci/receiver +++ b/tests/ci/receiver @@ -11,7 +11,7 @@ if [[ $2 == *dokku* ]]; then cd /tmp/build tar -xf - echo "-----> Installing dependencies" - DEBIAN_FRONTEND=noninteractive apt-get install -y git make curl software-properties-common + DEBIAN_FRONTEND=noninteractive apt-get install -qq -y git make curl software-properties-common echo "-----> Set hostname to dokku.me" hostname dokku.me echo "-----> Enabling tracing" diff --git a/tests/ci/setup.sh b/tests/ci/setup.sh index d020280af..d22fafefa 100755 --- a/tests/ci/setup.sh +++ b/tests/ci/setup.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -eo pipefail -export DEBIAN_FRONTEND=noninteractive -apt-get install -y git make curl +export DEBIAN_FRONTEND=noninteractive +apt-get install -qq -y git make curl cd /tmp @@ -24,4 +24,4 @@ EOF cat< /etc/rc.local curl https://raw.github.com/progrium/dokku/master/tests/ci/receiver -s > /tmp/receiver chmod +x /tmp/receiver -EOF \ No newline at end of file +EOF