Compare commits

...

41 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
00a8370b7d Release 0.3.1 2014-11-16 12:36:31 -05:00
Jose Diaz-Gonzalez
647b215738 Update HISTORY.md for 0.3.0 2014-11-16 12:19:29 -05:00
Jose Diaz-Gonzalez
3e224cc723 Merge pull request #579 from neam/include-nginx-conf.d
Plugin nginx-vhosts includes files in folder nginx.conf.d
2014-11-16 07:19:24 -05:00
Fredrik Wollsén
26a9e2fbf2 Update plugins list - VHOSTS Custom Configuration required core PR was made available in dokku core 0.3.1 2014-11-16 13:18:26 +02:00
Fredrik Wollsén
580f89e63b Plugin nginx-vhosts includes files in folder nginx.conf.d 2014-11-16 13:14:24 +02:00
Jose Diaz-Gonzalez
614a310bbf Merge pull request #762 from progrium/custom
Update template for dokku docs
2014-11-16 04:20:00 -05:00
Jose Diaz-Gonzalez
99304ac3d9 Update template for dokku docs 2014-11-16 04:18:34 -05:00
Jose Diaz-Gonzalez
403843832f Merge pull request #761 from progrium/add-registry-plugin
Add dokku-registry to list. Closes #716
2014-11-16 03:04:52 -05:00
Jose Diaz-Gonzalez
7d9aa7c492 Add dokku-registry to list. Closes #716 2014-11-16 03:04:26 -05:00
Jose Diaz-Gonzalez
33eca3bf39 Merge pull request #760 from progrium/formatting
Formatting
2014-11-16 03:01:04 -05:00
Jose Diaz-Gonzalez
aefa11db8b Add editorconfig to dokku
This should help dokku contributors force proper formatting on their contributions
2014-11-16 03:00:32 -05:00
Jose Diaz-Gonzalez
52774536ca Standardize installer on 2 spaces 2014-11-16 02:59:42 -05:00
Jose Diaz-Gonzalez
0f6ca81afd Update dokku-installer version to v0.3.0 2014-11-16 02:59:28 -05:00
Jose Diaz-Gonzalez
44201a66d9 Add set -eo statement to nginx-vhosts/dependencies 2014-11-16 02:59:07 -05:00
Jose Diaz-Gonzalez
7b361e564f Use 2 spaces for formatting bash
Also remove extra trailing newlines
2014-11-16 02:58:52 -05:00
Jose Diaz-Gonzalez
f13c1031c7 Ensure there is a newline after calling set -e 2014-11-16 02:54:54 -05:00
Jose Diaz-Gonzalez
bca8aa3923 Merge pull request #759 from progrium/apps-plugin
Create an `apps` core plugin.
2014-11-16 02:36:01 -05:00
Jose Diaz-Gonzalez
4b9433052f Create an apps core plugin.
This creates the following commands:

- apps
- apps:create <app>
- apps:destroy <app>

It also:

- makes `delete` an alias for `apps:destroy`
- adds confirmation to `apps:destroy`
- allows a developer to remove apps that have been created via apps:create but have not been deployed

Refs #87
Refs #543
Refs #586
Closes #599
Refs #655
Refs #656
Refs #685
Closes #757
2014-11-16 02:30:39 -05:00
Jose Diaz-Gonzalez
d0ceee5b3b Merge pull request #758 from progrium/621-permissions
Make ENV file readable only from dokku user. Closes #621
2014-11-16 00:27:07 -05:00
Jose Diaz-Gonzalez
913af9b641 Make ENV file readable only from dokku user. Closes #621 2014-11-16 00:26:12 -05:00
Jose Diaz-Gonzalez
f03c0c5440 Merge pull-request #617 from markstos/document-bootstrap 2014-11-16 00:16:51 -05:00
Mark Stosberg
96b348e880 Document what bootstrap.sh is doing. 2014-11-16 00:16:33 -05:00
Jose Diaz-Gonzalez
8a5b954bda Merge pull request #607 from fbochu/master
Use PLUGIN_PATH in dokku default case.
2014-11-16 00:13:48 -05:00
Jose Diaz-Gonzalez
b766654b4f Merge pull request #359 from plietar/rm-plugins
Remove plugins before copying them again.
2014-11-15 23:34:42 -05:00
Jose Diaz-Gonzalez
af0005196a Standardize the way in which we set variables 2014-11-15 23:32:30 -05:00
Jose Diaz-Gonzalez
c3df79f369 Merge pull-request #702 from jazzzz/config-spaces 2014-11-15 22:12:10 -05:00
Jose Diaz-Gonzalez
0f31ff1f24 Add a set of spaces to prefix config variables when setting them 2014-11-15 22:11:55 -05:00
Ludovic Perrine
043a1a01c5 Fixed setting config values with spaces over SSH 2014-11-15 22:03:54 -05:00
Ludovic Perrine
361011ec69 Added test for config with spaces 2014-11-15 22:03:54 -05:00
Ludovic Perrine
5dbc864060 Handle config values with spaces 2014-11-15 22:03:54 -05:00
Jose Diaz-Gonzalez
ac5f9a707c Merge pull request #755 from progrium/vagrant-dokku-installer
Setup dokku-installer within Vagrant VM on first provision
2014-11-15 20:25:13 -05:00
Jose Diaz-Gonzalez
d4235304ee Merge pull request #699 from tombell/suppress-git-archive-all-output
Actually suppress the output from `git_archive_all`
2014-11-15 20:23:57 -05:00
Jose Diaz-Gonzalez
a2d1d8c065 Setup dokku-installer within Vagrant VM on first provision 2014-11-15 20:14:01 -05:00
Jose Diaz-Gonzalez
190c50b694 Merge pull request #754 from progrium/remove-12-04 2014-11-15 16:59:01 -05:00
Jose Diaz-Gonzalez
ad516d6bf5 Remove all references to Ubuntu 12.04. Refs #238
We no longer test against 12.04 VMs
2014-11-15 16:57:59 -05:00
Jose Diaz-Gonzalez
a9ef99fe3d Merge pull request #573 from Prelang/command-instead-of-which 2014-11-15 16:40:42 -05:00
Erik Nomitch
592c95eaeb Use command instead of which for apt-get existential check in bootstrap.sh 2014-11-15 16:38:40 -05:00
Tom Bell
42c9d7aaa6 Actually suppress the output from the git commands 2014-09-30 21:08:23 +01:00
Fabien Bochu
22cdc11d57 Use PLUGIN_PATH in dokku default case. 2014-08-13 21:27:47 +02:00
Paul Lietar
4da4995a18 Only delete core plugins. 2013-11-29 20:57:53 +00:00
Paul Lietar
78591a618b Remove plugins before copying them again.
This way plugins can rename/delete files w/o having old files lying around.
2013-11-29 20:57:53 +00:00
37 changed files with 497 additions and 248 deletions

6
.editorconfig Normal file
View File

@@ -0,0 +1,6 @@
root = true
[*]
insert_final_newline = true
indent_style = space
indent_size = 2

View File

@@ -1,8 +1,58 @@
# History # 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) ## 0.2.0 (2013-11-24)

View File

@@ -14,7 +14,7 @@ ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS)))
$(eval $(RUN_ARGS):;@:) $(eval $(RUN_ARGS):;@:)
endif endif
.PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count vagrant-acl-add vagrant-dokku .PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku
all: all:
# Type "make install" to install. # Type "make install" to install.
@@ -24,7 +24,12 @@ install: dependencies stack copyfiles plugin-dependencies plugins version
copyfiles: addman copyfiles: addman
cp dokku /usr/local/bin/dokku cp dokku /usr/local/bin/dokku
mkdir -p /var/lib/dokku/plugins 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: addman:
mkdir -p /usr/local/share/man/man1 mkdir -p /usr/local/share/man/man1
@@ -84,6 +89,16 @@ count:
@echo "Test lines:" @echo "Test lines:"
@find tests -type f | xargs cat | wc -l @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-acl-add:
vagrant ssh -- sudo sshcommand acl-add dokku $(USER) vagrant ssh -- sudo sshcommand acl-add dokku $(USER)

View File

@@ -4,13 +4,13 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. S
## Requirements ## Requirements
- A fresh VM running either Ubuntu `14.04 x64` or `12.04 x64` - A fresh VM running Ubuntu `14.04 x64`
## Installing ## Installing
To install the latest stable version of dokku, you can run the following bootstrapper command: To install the latest stable version of dokku, you can run the following bootstrapper command:
$ wget -qO- https://raw.github.com/progrium/dokku/v0.3.0/bootstrap.sh | sudo DOKKU_TAG=v0.3.0 bash $ wget -qO- https://raw.github.com/progrium/dokku/v0.3.1/bootstrap.sh | sudo DOKKU_TAG=v0.3.1 bash
## Documentation ## Documentation

1
Vagrantfile vendored
View File

@@ -30,4 +30,5 @@ Vagrant::configure("2") do |config|
end end
config.vm.provision :shell, :inline => "apt-get -qq -y install git > /dev/null && 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 end

View File

@@ -1,9 +1,13 @@
#!/usr/bin/env bash #!/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 set -eo pipefail
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
export DOKKU_REPO=${DOKKU_REPO:-"https://github.com/progrium/dokku.git"} 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 then
echo "This installation script requires apt-get. For manual installation instructions, consult https://github.com/progrium/dokku ." echo "This installation script requires apt-get. For manual installation instructions, consult https://github.com/progrium/dokku ."
exit 1 exit 1

View File

@@ -3,120 +3,120 @@ require "sinatra"
require "open3" require "open3"
if ARGV[0] == "onboot" if ARGV[0] == "onboot"
File.open("/etc/init/dokku-installer.conf", "w") do |f| File.open("/etc/init/dokku-installer.conf", "w") do |f|
f.puts "start on runlevel [2345]" f.puts "start on runlevel [2345]"
f.puts "exec #{File.absolute_path(__FILE__)} selfdestruct" f.puts "exec #{File.absolute_path(__FILE__)} selfdestruct"
end end
File.open("/etc/nginx/conf.d/dokku-installer.conf", "w") do |f| 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 "upstream dokku-installer { server 127.0.0.1:2000; }"
f.puts "server {" f.puts "server {"
f.puts " listen 80;" f.puts " listen 80;"
f.puts " location / {" f.puts " location / {"
f.puts " proxy_pass http://dokku-installer;" f.puts " proxy_pass http://dokku-installer;"
f.puts " }" f.puts " }"
f.puts "}" f.puts "}"
end end
`rm /etc/nginx/sites-enabled/*` `rm /etc/nginx/sites-enabled/*`
puts "Installed Upstart service and default Nginx virtualhost for installer to run on boot." puts "Installed Upstart service and default Nginx virtualhost for installer to run on boot."
exit exit
end end
version = "v0.2.1" version = "v0.3.1"
dokku_root = ENV["DOKKU_ROOT"] || "/home/dokku" dokku_root = ENV["DOKKU_ROOT"] || "/home/dokku"
admin_key = `cat /root/.ssh/authorized_keys`.split("\n").first admin_key = `cat /root/.ssh/authorized_keys`.split("\n").first
hostname = `bash -c '[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME || curl icanhazip.com'`.strip hostname = `bash -c '[[ $(dig +short $HOSTNAME) ]] && echo $HOSTNAME || curl icanhazip.com'`.strip
template = DATA.read template = DATA.read
set :port, 2000 set :port, 2000
set :environment, :production set :environment, :production
disable :protection disable :protection
get "/" do get "/" do
ERB.new(template).result binding ERB.new(template).result binding
end end
post "/setup" do post "/setup" do
if params[:vhost] == "true" if params[:vhost] == "true"
File.open("#{dokku_root}/VHOST", "w") {|f| f.write params[:hostname] } File.open("#{dokku_root}/VHOST", "w") {|f| f.write params[:hostname] }
else else
`rm #{dokku_root}/VHOST` `rm #{dokku_root}/VHOST`
end end
File.open("#{dokku_root}/HOSTNAME", "w") {|f| f.write params[:hostname] } File.open("#{dokku_root}/HOSTNAME", "w") {|f| f.write params[:hostname] }
Open3.capture2("sshcommand acl-add dokku admin", :stdin_data => params[:key]) Open3.capture2("sshcommand acl-add dokku admin", :stdin_data => params[:key])
Thread.new { Thread.new {
`rm /etc/nginx/conf.d/dokku-installer.conf && /etc/init.d/nginx stop && /etc/init.d/nginx start` `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` `rm /etc/init/dokku-installer.conf && stop dokku-installer`
}.run if ARGV[0] == "selfdestruct" }.run if ARGV[0] == "selfdestruct"
end end
__END__ __END__
<html> <html>
<head> <head>
<title>Dokku Setup</title> <title>Dokku Setup</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" /> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head> </head>
<body> <body>
<div class="container" style="width: 640px;"> <div class="container" style="width: 640px;">
<form id="form" role="form"> <form id="form" role="form">
<h1>Dokku Setup <small><%= version %></small></h1> <h1>Dokku Setup <small><%= version %></small></h1>
<div class="form-group"> <div class="form-group">
<h3><small style="text-transform: uppercase;">Admin Access</small></h3> <h3><small style="text-transform: uppercase;">Admin Access</small></h3>
<label for="key">Public Key</label><br /> <label for="key">Public Key</label><br />
<textarea class="form-control" name="key" rows="7" id="key"><%= admin_key %></textarea> <textarea class="form-control" name="key" rows="7" id="key"><%= admin_key %></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<h3><small style="text-transform: uppercase;">Hostname Configuration</small></h3> <h3><small style="text-transform: uppercase;">Hostname Configuration</small></h3>
<div class="form-group"> <div class="form-group">
<label for="hostname">Hostname</label> <label for="hostname">Hostname</label>
<input class="form-control" type="text" id="hostname" name="hostname" value="<%= hostname %>" /> <input class="form-control" type="text" id="hostname" name="hostname" value="<%= hostname %>" />
</div> </div>
<div class="checkbox"> <div class="checkbox">
<label><input id="vhost" name="vhost" type="checkbox" value="true"> Use <abbr title="Nginx will be run on port 80 and backend to your apps based on hostname">virtualhost naming</abbr> for apps</label> <label><input id="vhost" name="vhost" type="checkbox" value="true"> Use <abbr title="Nginx will be run on port 80 and backend to your apps based on hostname">virtualhost naming</abbr> for apps</label>
</div> </div>
<p>Your app URLs will look like:</p> <p>Your app URLs will look like:</p>
<pre id="example">http://hostname:port</pre> <pre id="example">http://hostname:port</pre>
</div> </div>
<button type="button" onclick="setup()" class="btn btn-primary">Finish Setup</button> <span style="padding-left: 20px;" id="result"></span> <button type="button" onclick="setup()" class="btn btn-primary">Finish Setup</button> <span style="padding-left: 20px;" id="result"></span>
</form> </form>
</div> </div>
<div id="error-output"></div> <div id="error-output"></div>
<script> <script>
function setup() { function setup() {
if ($.trim($("#key").val()) == "") { if ($.trim($("#key").val()) == "") {
alert("Your admin public key cannot be blank.") alert("Your admin public key cannot be blank.")
return return
} }
if ($.trim($("#hostname").val()) == "") { if ($.trim($("#hostname").val()) == "") {
alert("Your hostname cannot be blank.") alert("Your hostname cannot be blank.")
return return
} }
data = $("#form").serialize() data = $("#form").serialize()
$("input,textarea,button").prop("disabled", true); $("input,textarea,button").prop("disabled", true);
$.post('/setup', data) $.post('/setup', data)
.done(function() { .done(function() {
$("#result").html("Success!") $("#result").html("Success!")
window.location.href = "http://progrium.viewdocs.io/dokku/application-deployment"; window.location.href = "http://progrium.viewdocs.io/dokku/application-deployment";
}) })
.fail(function(data) { .fail(function(data) {
$("#result").html("Something went wrong...") $("#result").html("Something went wrong...")
$("#error-output").html(data.responseText) $("#error-output").html(data.responseText)
}); });
} }
function update() { function update() {
if ($("#vhost").is(":checked") && $("#hostname").val().match(/^(\d{1,3}\.){3}\d{1,3}$/)) { if ($("#vhost").is(":checked") && $("#hostname").val().match(/^(\d{1,3}\.){3}\d{1,3}$/)) {
alert("In order to use virtualhost naming, the hostname must not be an IP but a valid domain name.") alert("In order to use virtualhost naming, the hostname must not be an IP but a valid domain name.")
$("#vhost").prop('checked', false); $("#vhost").prop('checked', false);
} }
if ($("#vhost").is(':checked')) { if ($("#vhost").is(':checked')) {
$("#example").html("http://&lt;app-name&gt;."+$("#hostname").val()) $("#example").html("http://&lt;app-name&gt;."+$("#hostname").val())
} else { } else {
$("#example").html("http://"+$("#hostname").val()+":&lt;app-port&gt;") $("#example").html("http://"+$("#hostname").val()+":&lt;app-port&gt;")
} }
} }
$("#vhost").change(update); $("#vhost").change(update);
$("#hostname").change(update); $("#hostname").change(update);
update(); update();
</script> </script>
</body> </body>
</html> </html>

View File

@@ -23,4 +23,4 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen.
## Sponsors ## Sponsors
Though we love everybody doing open source, we especially love [Deis](http://deis.io/) for sponsoring Dokku. Though we love everybody doing open source, we especially love [Deis](http://deis.io/) for sponsoring Dokku.

View File

@@ -2,18 +2,16 @@
## Requirements ## 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. 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.
**Note: Support for 12.04 will be sunsetting in the near future after dokku & 14.04 have been more thoroughly tested.**
## Installing the latest Stable version ## Installing the latest Stable version
To install the latest stable version of dokku, you can run the following bootstrapper command: To install the latest stable version of dokku, you can run the following bootstrapper command:
```bash ```bash
wget -qO- https://raw.github.com/progrium/dokku/v0.3.0/bootstrap.sh | sudo DOKKU_TAG=v0.3.0 bash wget -qO- https://raw.github.com/progrium/dokku/v0.3.1/bootstrap.sh | sudo DOKKU_TAG=v0.3.1 bash
``` ```
## Configuring ## Configuring
@@ -115,11 +113,7 @@ sudo BUILD_STACK=true make install
vagrant up vagrant up
``` ```
- Add SSH key to Dokku using `sshcommand`: - 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.
```bash
cat ~/.ssh/id_rsa.pub | make vagrant-acl-add
```
You are now ready to deploy an app or install plugins. You are now ready to deploy an app or install plugins.

View File

@@ -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 [cameron-martin]: https://github.com/cameron-martin
[matto1990]: https://github.com/matto1990 [matto1990]: https://github.com/matto1990
[ohardy]: https://github.com/ohardy [ohardy]: https://github.com/ohardy
[agco-adm]: https://github.com/agco-adm
### Datastores ### Datastores
@@ -140,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][] | | | [Debug](https://github.com/heichblatt/dokku-debug) | [heichblatt][] | |
| [Pre-Deploy Tasks](https://github.com/michaelshobbs/dokku-app-predeploy-tasks) | [michaelshobbs][] | | | [Pre-Deploy Tasks](https://github.com/michaelshobbs/dokku-app-predeploy-tasks) | [michaelshobbs][] | |
| [Hostname](https://github.com/michaelshobbs/dokku-hostname) | [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 | | [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 | | [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 | | [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 | | [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 [8fca220]: https://github.com/progrium/dokku/commit/8fca2204edb0017796d6915ca9157c05b1238e28
[217d00a]: https://github.com/progrium/dokku/commit/217d00a1bc47a7e24d8847617bb08a1633025fc7 [217d00a]: https://github.com/progrium/dokku/commit/217d00a1bc47a7e24d8847617bb08a1633025fc7

98
docs/template.html Normal file
View File

@@ -0,0 +1,98 @@
<!doctype html>
<head>
<meta charset="utf-8">
<title>{{NAME}} :: viewdocs.io</title>
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,600' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://static.gist.io/css/screen.css">
<style type="text/css">
body {
background: #f0f3f3;
font: 500 16px proxima-nova-1, proxima-nova-2, 'Proxima Nova', 'Montserrat', HelveticaNeue, Helvetica, Arial, sans-serif;
}
article pre {
background-color: #fff;
border-radius: 2px;
box-shadow: 0 0 10px rgba(0,0,0,.1);
color: #222;
font-family: 'Source Code Pro', Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
font-size: 14px;
overflow: auto;
padding: 10px;
width: 100%;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
article p code {
background-color: #fff;
border-radius: 2px;
box-shadow: 0 0 10px rgba(0,0,0,.1);
color: #333;
font-family: 'Source Code Pro', Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
font-size: 14px;
padding: 0 4px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
article .highlight {
padding: 0;
}
article h1 {
font-size: 2em;
font-weight: bold;
}
article h2 {
font-size: 1.5em;
font-weight: bold;
}
article h3 {
font-size: 1em;
text-transform: uppercase;
font-weight: bold;
}
article ul, article ol {
list-style-position: outside;
padding-left: 20px;
}
tr, td {
text-align: center;
}
#gistbody h1:first-child {
border-bottom: 1px solid #dadada;
display: block;
color: #000;
font-weight: 700;
font-size: 20px;
line-height: 1;
margin: 0 0 24px 0;
padding-bottom: 31px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.content {
font-size: 1em;
}
</style>
</head>
<body>
<section class="content">
<header>
<h1 id="gistid"><a href="http://github.com/{{USER}}/{{NAME}}">{{NAME}}</a> :: <a href="/{{NAME}}">index</a></h1>
</header>
<article id="gistbody" class="instapaper_body entry-content">
{{CONTENT}}
</article>
</section>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-6824126-17', 'viewdocs.io');
ga('send', 'pageview');
</script>
<script src="//static.getclicky.com/js" type="text/javascript"></script>
<script type="text/javascript">try{ clicky.init(100672863); }catch(e){}</script>
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/100672863ns.gif" /></p></noscript>
</body>
</html>

8
dokku
View File

@@ -12,6 +12,12 @@ if [[ $(id -un) != "dokku" && $1 != plugins-install* ]]; then
exit exit
fi fi
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
export -n SSH_ORIGINAL_COMMAND
$0 $SSH_ORIGINAL_COMMAND
exit $?
fi
case "$1" in case "$1" in
receive) receive)
APP="$2"; IMAGE="dokku/$APP" APP="$2"; IMAGE="dokku/$APP"
@@ -130,7 +136,7 @@ EOF
;; ;;
*) *)
for script in $(ls -d /var/lib/dokku/plugins/*/commands); do for script in $(ls -d $PLUGIN_PATH/*/commands); do
$script "$@" $script "$@"
done done
;; ;;

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
VERSION="$1" VERSION="$1"
IMPORT_DIR="$2" IMPORT_DIR="$2"
TARGET_DIR="$3" TARGET_DIR="$3"
@@ -15,4 +16,3 @@ for app in $APPS; do
done done
exit $ret exit $ret

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
VERSION="$1" VERSION="$1"
BASE_DIR="$2" BASE_DIR="$2"

View File

@@ -1,15 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
VERSION="$1" VERSION="$1"
IMPORT_DIR="$2" IMPORT_DIR="$2"
TARGET_DIR="$3" TARGET_DIR="$3"
[[ -f $IMPORT_DIR/.sshcommand ]] && mv $IMPORT_DIR/.sshcommand $TARGET_DIR/.sshcommand [[ -f $IMPORT_DIR/.sshcommand ]] && mv $IMPORT_DIR/.sshcommand $TARGET_DIR/.sshcommand
if [[ -f $IMPORT_DIR/.ssh/authorized_keys ]]; then if [[ -f $IMPORT_DIR/.ssh/authorized_keys ]]; then
mkdir -p $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 cat $IMPORT_DIR/.ssh/authorized_keys $TARGET_DIR/.ssh/authorized_keys | uniq > $TARGET_DIR/.ssh/authorized_keys
chmod 0700 $TARGET_DIR/.ssh chmod 0700 $TARGET_DIR/.ssh
chmod 0600 $TARGET_DIR/.ssh/* chmod 0600 $TARGET_DIR/.ssh/*
fi fi
[[ -f $IMPORT_DIR/HOSTNAME ]] && mv $IMPORT_DIR/HOSTNAME $TARGET_DIR/HOSTNAME [[ -f $IMPORT_DIR/HOSTNAME ]] && mv $IMPORT_DIR/HOSTNAME $TARGET_DIR/HOSTNAME
[[ -f $IMPORT_DIR/VHOST ]] && mv $IMPORT_DIR/VHOST $TARGET_DIR/VHOST [[ -f $IMPORT_DIR/VHOST ]] && mv $IMPORT_DIR/VHOST $TARGET_DIR/VHOST

View File

@@ -1,28 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in case "$1" in
delete) delete)
if [[ -z $2 ]]; then dokku apps:destroy $2
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
;; ;;
logs) logs)
@@ -50,13 +31,13 @@ case "$1" in
run) run)
if [[ -z $2 ]]; then if [[ -z $2 ]]; then
echo "Please specify an app to run the command on" echo "Please specify an app to run the command on"
exit 1 exit 1
fi fi
APP="$2"; IMAGE="dokku/$APP" APP="$2"; IMAGE="dokku/$APP"
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist" echo "App $APP does not exist"
exit 1 exit 1
fi fi
shift 2 shift 2
@@ -67,8 +48,8 @@ case "$1" in
url) url)
APP="$2"; APP="$2";
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist" echo "App $APP does not exist"
exit 1 exit 1
fi fi
if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then
@@ -85,7 +66,6 @@ case "$1" in
help) help)
cat && cat<<EOF cat && cat<<EOF
delete <app> Delete an application
logs <app> [-t] Show the last logs for an application (-t follows) logs <app> [-t] Show the last logs for an application (-t follows)
run <app> <cmd> Run a command in the environment of an application run <app> <cmd> Run a command in the environment of an application
url <app> Show the URL for an application url <app> Show the URL for an application
@@ -94,4 +74,3 @@ EOF
;; ;;
esac esac

View File

@@ -2,7 +2,7 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then
echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME
fi fi
# temporary hack for https://github.com/progrium/dokku/issues/82 # temporary hack for https://github.com/progrium/dokku/issues/82

View File

@@ -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 {} \;

70
plugins/apps/commands Executable file
View File

@@ -0,0 +1,70 @@
#!/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 ".*" \) | sed 's|^\./||g' | sed 's|'$DOKKU_ROOT'\/||' | tail -n +2
;;
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
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<<EOF
apps List your apps
apps:create <app> Create a new app
apps:destroy <app> Permanently destroy an app
EOF
;;
esac

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
[[ -n $1 ]] && rm -r "$DOKKU_ROOT/$1" > /dev/null [[ -n $1 ]] && rm -r "$DOKKU_ROOT/$1" > /dev/null

7
plugins/apps/pre-delete Executable file
View File

@@ -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

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
CURRENT_BACKUP_VERSION=1 CURRENT_BACKUP_VERSION=1
set -e; case "$1" in
case "$1" in
backup:export) backup:export)
OUTPUT_FILE="$2" OUTPUT_FILE="$2"
BACKUP_DIR="$DOKKU_ROOT" BACKUP_DIR="$DOKKU_ROOT"
@@ -24,9 +26,9 @@ set -e; case "$1" in
# if no file specified, output to stdout # if no file specified, output to stdout
if [[ -z $OUTPUT_FILE ]]; then if [[ -z $OUTPUT_FILE ]]; then
cat $BACKUP_TMP_FILE cat $BACKUP_TMP_FILE
else else
mv $BACKUP_TMP_FILE $OUTPUT_FILE mv $BACKUP_TMP_FILE $OUTPUT_FILE
fi fi
rm -rf $BACKUP_TMP_DIR rm -rf $BACKUP_TMP_DIR
@@ -48,14 +50,14 @@ set -e; case "$1" in
tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR tar xf $INPUT_FILE --directory=$BACKUP_TMP_DIR
if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then if [[ ! -f $BACKUP_TMP_DIR/.dokku_backup_version ]]; then
echo "Unable to determine backup version" echo "Unable to determine backup version"
exit 1 exit 1
fi fi
VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version) VERSION=$(< $BACKUP_TMP_DIR/.dokku_backup_version)
if [[ $VERSION -ne 1 ]]; then if [[ $VERSION -ne 1 ]]; then
echo "Unknown format version $VERSION" echo "Unknown format version $VERSION"
exit 1 exit 1
fi fi
echo "Importing a version $VERSION backup..." echo "Importing a version $VERSION backup..."
@@ -91,4 +93,3 @@ EOF
;; ;;
esac esac

View File

@@ -14,6 +14,7 @@
# in seconds). # in seconds).
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
CONTAINERID="$1"; APP="$2"; PORT="$3" ; HOSTNAME="${4:-localhost}" CONTAINERID="$1"; APP="$2"; PORT="$3" ; HOSTNAME="${4:-localhost}"
# source in app env to get DOKKU_CHECKS_WAIT and any other necessary vars # 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. # after successfully copying the file. Thus, we suppress stderr.
# ref: https://github.com/dotcloud/docker/issues/3986 # ref: https://github.com/dotcloud/docker/issues/3986
if [[ ! -f "$FILENAME" ]] ; then if [[ ! -f "$FILENAME" ]] ; then
echo " check-deploy: $FILENAME not found. attempting to retrieve it from container ..." echo " check-deploy: $FILENAME not found. attempting to retrieve it from container ..."
TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX) TMPDIR=$(mktemp -d /tmp/CHECKS.XXXXX)
docker cp $CONTAINERID:/app/CHECKS $TMPDIR 2> /dev/null || true docker cp $CONTAINERID:/app/CHECKS $TMPDIR 2> /dev/null || true
if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then
echo " CHECKS file not found in container. skipping checks." echo " CHECKS file not found in container. skipping checks."
rm -rf $TMPDIR rm -rf $TMPDIR
exit 0 exit 0
else else
echo " CHECKS file found in container" echo " CHECKS file found in container"
FILENAME=${TMPDIR}/CHECKS FILENAME=${TMPDIR}/CHECKS
function cleanup() { function cleanup() {
echo " removing CHECKS file copied from container" echo " removing CHECKS file copied from container"
rm -rf $TMPDIR rm -rf $TMPDIR
} }
trap cleanup EXIT trap cleanup EXIT
fi fi
fi fi
echo "Waiting $WAIT seconds ..." echo "Waiting $WAIT seconds ..."

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
shopt -s nullglob shopt -s nullglob
VERSION="$1" VERSION="$1"
BASE_DIR="$2" BASE_DIR="$2"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
shopt -s nullglob shopt -s nullglob
VERSION="$1" VERSION="$1"
IMPORT_DIR="$2" IMPORT_DIR="$2"
@@ -7,5 +8,5 @@ TARGET_DIR="$3"
cd $IMPORT_DIR cd $IMPORT_DIR
for file in */ENV; do for file in */ENV; do
cp $file "$TARGET_DIR/$file" cp $file "$TARGET_DIR/$file"
done done

View File

@@ -25,19 +25,20 @@ if [[ $1 == config ]] || [[ $1 == config:* ]]; then
fi fi
config_styled_hash () { config_styled_hash () {
vars=`echo -e "$1"` vars="$1"
prefix="$2"
longest="" longest=""
for word in $vars; do while read -r word; do
KEY=`echo $word | cut -d"=" -f1` KEY=`echo $word | cut -d"=" -f1`
if [ ${#KEY} -gt ${#longest} ]; then if [ ${#KEY} -gt ${#longest} ]; then
longest=$KEY longest=$KEY
fi fi
done done <<< "$vars"
for word in $vars; do while read -r word; do
KEY=`echo $word | cut -d"=" -f1` 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})) num_zeros=$((${#longest} - ${#KEY}))
zeros=" " zeros=" "
@@ -45,19 +46,21 @@ config_styled_hash () {
zeros="$zeros " zeros="$zeros "
num_zeros=$(($num_zeros - 1)) num_zeros=$(($num_zeros - 1))
done done
echo "$KEY:$zeros$VALUE" echo "$prefix$KEY:$zeros$VALUE"
done done <<< "$vars"
} }
config_restart_app() { config_restart_app() {
APP="$1"; APP="$1";
echo "-----> Releasing $APP ..." if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
dokku release $APP echo "-----> Releasing $APP ..."
echo "-----> Release complete!" dokku release $APP
echo "-----> Deploying $APP ..." echo "-----> Release complete!"
dokku deploy $APP echo "-----> Deploying $APP ..."
echo "-----> Deploy complete!" dokku deploy $APP
echo "-----> Deploy complete!"
fi
} }
config_write() { config_write() {
@@ -65,13 +68,13 @@ config_write() {
echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP
if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then
cp -f $ENV_FILE_TEMP $ENV_FILE cp -f $ENV_FILE_TEMP $ENV_FILE
chmod 600 $ENV_FILE
config_restart_app $APP config_restart_app $APP
fi fi
rm -f $ENV_FILE_TEMP rm -f $ENV_FILE_TEMP
} }
case "$1" in case "$1" in
config) config)
APP="$2" APP="$2"
@@ -80,7 +83,7 @@ case "$1" in
exit 1 exit 1
fi 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 for var in "$@"; do
if [[ "$var" == "--shell" ]]; then if [[ "$var" == "--shell" ]]; then
@@ -106,7 +109,7 @@ case "$1" in
KEY="$3" 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) config:set)
@@ -120,9 +123,9 @@ case "$1" in
ENV_ADD="" ENV_ADD=""
ENV_TEMP=`cat "${ENV_FILE}"` ENV_TEMP=`cat "${ENV_FILE}"`
RESTART_APP=false RESTART_APP=false
VARS="${*:3}" shift 2
for var in $VARS; do for var; do
if [[ $var != *"="* ]]; then if [[ $var != *"="* ]]; then
echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]" echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]"
echo "Must specify KEY and VALUE to set." echo "Must specify KEY and VALUE to set."
@@ -130,22 +133,24 @@ case "$1" in
fi fi
done done
for var in $VARS; do for var; do
KEY=`echo ${var} | cut -d"=" -f1` KEY=`echo ${var} | cut -d"=" -f1`
VALUE=`echo ${var} | cut -d"=" -f2-` VALUE=`echo ${var} | cut -d"=" -f2-`
if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then
RESTART_APP=true RESTART_APP=true
ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $KEY=/ d") 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=$(echo -e "${ENV_ADD}" | sed "/^$KEY=/ d")
ENV_ADD="${ENV_ADD}\n${var}" ENV_ADD="${ENV_ADD}$
${var}"
fi fi
done done
ENV_ADD=$(echo "$ENV_ADD" | tail -n +2) #remove first empty line
if [ $RESTART_APP ]; then if [ $RESTART_APP ]; then
echo "-----> Setting config vars and restarting $APP" echo "-----> Setting config vars and restarting $APP"
config_styled_hash "$ENV_ADD" config_styled_hash "$ENV_ADD" " "
config_write "$ENV_TEMP" config_write "$ENV_TEMP"
fi fi
@@ -180,4 +185,3 @@ EOF
;; ;;
esac esac

View File

@@ -1,18 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
VERSION="$1" VERSION="$1"
IMPORT_DIR="$2" IMPORT_DIR="$2"
TARGET_DIR="$3" TARGET_DIR="$3"
APPS="$4" APPS="$4"
while read APP; do while read APP; do
APP_PATH="$TARGET_DIR/$APP"; APP_PATH="$TARGET_DIR/$APP";
git init --bare $APP_PATH > /dev/null git init --bare $APP_PATH > /dev/null
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > $PRERECEIVE_HOOK <<EOF cat > $PRERECEIVE_HOOK <<EOF
#!/usr/bin/env bash #!/usr/bin/env bash
set -e; set -o pipefail; set -e; set -o pipefail;
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
EOF EOF
chmod +x $PRERECEIVE_HOOK chmod +x $PRERECEIVE_HOOK
done < $APPS > /dev/null done < $APPS > /dev/null

View File

@@ -2,19 +2,19 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
git_archive_all() { git_archive_all() {
APP=$1; REV=$2 APP=$1; REV=$2
TMP_WORK_DIR=$(mktemp -d) TMP_WORK_DIR=$(mktemp -d)
chmod 755 $TMP_WORK_DIR chmod 755 $TMP_WORK_DIR
unset GIT_DIR GIT_WORK_TREE unset GIT_DIR GIT_WORK_TREE
git clone $DOKKU_ROOT/$APP $TMP_WORK_DIR > /dev/null git clone $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null
pushd $TMP_WORK_DIR > /dev/null pushd $TMP_WORK_DIR > /dev/null
git config advice.detachedHead false git config advice.detachedHead false
git checkout $REV > /dev/null git checkout $REV &> /dev/null
git submodule update --init --recursive > /dev/null git submodule update --init --recursive &> /dev/null
find -name .git -prune -exec rm -rf {} \; > /dev/null find -name .git -prune -exec rm -rf {} \; > /dev/null
tar c . tar c .
popd > /dev/null popd > /dev/null
rm -rf $TMP_WORK_DIR > /dev/null rm -rf $TMP_WORK_DIR > /dev/null
} }
case "$1" in 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'"-----> WARNING: deploy did not complete, you must push to master."
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\/}:master'" echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\/}:master'"
fi fi
done done
;; ;;
@@ -40,14 +39,15 @@ case "$1" in
APP_PATH=$DOKKU_ROOT/$APP APP_PATH=$DOKKU_ROOT/$APP
if [[ $1 == "git-receive-pack" && ! -d "$APP_PATH/refs" ]]; then if [[ $1 == "git-receive-pack" && ! -d "$APP_PATH/refs" ]]; then
git init --bare $APP_PATH > /dev/null git init --bare $APP_PATH > /dev/null
PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive" PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > $PRERECEIVE_HOOK <<EOF cat > $PRERECEIVE_HOOK <<EOF
#!/usr/bin/env bash #!/usr/bin/env bash
set -e; set -o pipefail; set -e; set -o pipefail;
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
EOF EOF
chmod +x $PRERECEIVE_HOOK chmod +x $PRERECEIVE_HOOK
fi fi
args=$@ args=$@
@@ -57,5 +57,5 @@ EOF
help) help)
cat cat
;; ;;
esac
esac

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
shopt -s nullglob shopt -s nullglob
VERSION="$1" VERSION="$1"
BASE_DIR="$2" BASE_DIR="$2"

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
shopt -s nullglob shopt -s nullglob
VERSION="$1" VERSION="$1"
IMPORT_DIR="$2" IMPORT_DIR="$2"
@@ -8,6 +9,6 @@ TARGET_DIR="$3"
cd $IMPORT_DIR cd $IMPORT_DIR
for file in */tls/server.*; do for file in */tls/server.*; do
mkdir -p $(dirname $TARGET_DIR$file) mkdir -p $(dirname $TARGET_DIR$file)
cp $file $TARGET_DIR$file cp $file $TARGET_DIR$file
done done

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
help)
cat
;;
esac

View File

@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# latest stable NGINX 1.4.x with websocket support # latest stable NGINX 1.4.x with websocket support
apt-get install -qq -y software-properties-common python-software-properties apt-get install -qq -y software-properties-common python-software-properties

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
sudo /etc/init.d/nginx reload > /dev/null sudo /etc/init.d/nginx reload > /dev/null

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; PORT="$2" APP="$1"; PORT="$2"
WILDCARD_SSL="$DOKKU_ROOT/tls" WILDCARD_SSL="$DOKKU_ROOT/tls"
SSL="$DOKKU_ROOT/$APP/tls" SSL="$DOKKU_ROOT/$APP/tls"
@@ -56,6 +57,7 @@ $SSL_DIRECTIVES
proxy_set_header X-Forwarded-Port \$server_port; proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec; proxy_set_header X-Request-Start \$msec;
} }
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
} }
EOF EOF
@@ -79,6 +81,7 @@ server {
proxy_set_header X-Forwarded-Port \$server_port; proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec; proxy_set_header X-Request-Start \$msec;
} }
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
} }
EOF EOF

View File

@@ -1,3 +1,15 @@
#!/bin/bash #!/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"
}

View File

@@ -4,5 +4,5 @@ set -ex;
REMOTE=$1 REMOTE=$1
REPO=$2 REPO=$2
ssh $REMOTE config:set $REPO CONFTEST=config-test ssh $REMOTE config:set $REPO CONFTEST=config-test HELLO=\"Hello world\"

View File

@@ -6,6 +6,10 @@ app.get('/', function(request, response) {
response.send(process.env.CONFTEST); response.send(process.env.CONFTEST);
}); });
app.get('/hello', function(request, response) {
response.send(process.env.HELLO);
});
var port = process.env.PORT || 5000; var port = process.env.PORT || 5000;
app.listen(port, function() { app.listen(port, function() {
console.log("Listening on " + port); console.log("Listening on " + port);