Compare commits

...

93 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
af671b2aba Release 0.3.10 2014-12-19 15:17:17 -05:00
Jose Diaz-Gonzalez
45b2f87b15 Merge pull request #831 from progrium/nginx-docs
Nginx docs
2014-12-19 15:13:14 -05:00
Jose Diaz-Gonzalez
3d6727a1b8 Add documentation for configuring the nginx domains and vhosts 2014-12-19 15:10:10 -05:00
Jose Diaz-Gonzalez
bf4781a5d7 Use shell keyword for codeblock guard 2014-12-19 15:09:38 -05:00
Michael Hobbs
2d48d81d09 Merge pull request #828 from andrewsomething/port
Display the port for an app when falling back to the ip address.
2014-12-18 14:10:11 -08:00
Andrew Starr-Bochicchio
294b419da5 Display the port for an app when falling back to the ip address. 2014-12-17 21:20:18 -05:00
Jose Diaz-Gonzalez
f1bfb3ed3a Merge pull request #827 from expa/mh-mv-default-vhost-to-core
Handle IP only access
2014-12-17 19:53:59 -05:00
Michael Hobbs
56472bd08c VHOST fallback 2014-12-16 23:01:32 -08:00
Michael Hobbs
e99e2201cb mv default VHOST creation to core install 2014-12-16 20:25:44 -08:00
Jose Diaz-Gonzalez
5bf1ba7ed7 Merge pull request #783 from progrium/nginx-cleanup
New domains plugin and nginx extension
2014-12-16 17:15:30 -05:00
Jose Diaz-Gonzalez
5d014d0a8e Merge pull request #823 from expa/nginx-cleanup
show URLS with scheme. now with bug fixes!!!
2014-12-16 16:26:47 -05:00
Michael Hobbs
59f047bb45 include SSL_VHOSTS in NOSSL_SERVER_NAME so we can redirect from http to https on the secure hostname as well 2014-12-16 12:15:10 -08:00
Michael Hobbs
1b208778f3 bugfixes
- don't match substrings in VHOSTS
 - handle case where NOSSL_SERVER_NAME is \' \'
 - rebuild nginx config on ssl import
 - prevent cwd errors after we rm the temp dir
2014-12-15 18:10:14 -08:00
Michael Hobbs
a6cdae5abf reset VHOST to default upon domains:clear 2014-12-15 18:04:00 -08:00
Michael Hobbs
50115d3640 print out urls with scheme 2014-12-15 18:02:57 -08:00
Michael Hobbs
78d3921a6f don't break other nginx plugins like nginx-alt 2014-12-15 13:15:40 -08:00
Jose Diaz-Gonzalez
23d4224beb Merge pull request #818 from expa/nginx-cleanup
rebuild nginx config on domain change
2014-12-14 18:31:43 -05:00
Michael Hobbs
4e0670f1ac rebuild nginx config on domain change 2014-12-12 17:53:30 -08:00
Jose Diaz-Gonzalez
0bd8d71bb9 Release 0.3.9 2014-12-12 09:58:02 -05:00
Jose Diaz-Gonzalez
12ee9bc3e7 Merge pull request #816 from progrium/build-env-docs
Add documentation for user-env feature
2014-12-12 09:56:46 -05:00
Jose Diaz-Gonzalez
a991c450be Remove user-env-compile plugins from docs 2014-12-12 09:55:41 -05:00
Jose Diaz-Gonzalez
a900aa45d6 Add documentation for the recent build-env feature addition 2014-12-12 09:54:26 -05:00
Jose Diaz-Gonzalez
3c8b3cedea Merge pull request #814 from progrium/dokku-env-vars
Source files in $DOKKU_ROOT/.dokkurc directory and add `dokku trace` command
2014-12-12 09:25:51 -05:00
Jose Diaz-Gonzalez
dec8056ef5 Link to gist.github.com 2014-12-12 01:10:10 -05:00
Jose Diaz-Gonzalez
784e2cfd5e Add a note about enabling dokku trace via the cli 2014-12-12 01:09:59 -05:00
Jose Diaz-Gonzalez
b9b9d6303a Add a dokku trace command to allow easy toggling of the DOKKU_TRACE option 2014-12-12 01:07:43 -05:00
Jose Diaz-Gonzalez
39912ce5db Allow sourcing in any file in .dokkurc
This allows us to configure dokku env-vars individually. Such a feature is useful if a developer would like to enable or disable DOKKU_TRACE without parsing a dokkurc file.
2014-12-12 01:07:08 -05:00
Jose Diaz-Gonzalez
7d8ec62a86 Merge pull request #787 from progrium/build-env
Official user-env-compile plugin
2014-12-11 21:15:45 -05:00
Jose Diaz-Gonzalez
8cd4863126 Merge pull request #813 from expa/build-env
build-env todos
2014-12-11 18:18:26 -05:00
Michael Hobbs
7c8feb9e0d build-env todos 2014-12-11 14:56:25 -08:00
Jose Diaz-Gonzalez
d6ef5e3447 Merge pull request #812 from expa/build-env
create build env for both dokku and new style buildpacks
2014-12-11 16:33:28 -05:00
Michael Hobbs
498e250e2e link to commit id and line in comment 2014-12-11 12:52:04 -08:00
Michael Hobbs
7d5e0ba5aa create build env for both dokku and new style buildpacks 2014-12-11 12:05:55 -08:00
Jose Diaz-Gonzalez
a7b8eb5581 Merge pull request #811 from abossard/patch-1
Please increase the server_names_hash_bucket_size
2014-12-11 10:22:44 -05:00
Andre Bossard
79788e5690 Please increase the server_names_hash_bucket_size
I use Dokku in a private environment with very long hostname.... 64 was always a lot to short.
2014-12-11 09:59:13 +01:00
Jose Diaz-Gonzalez
ae61ef3f1e Add backup support to nginx.conf.template files 2014-12-11 02:40:20 -05:00
Jose Diaz-Gonzalez
1d45ca0cdd Add backup export/import hooks for associated VHOST files 2014-12-11 02:38:08 -05:00
Jose Diaz-Gonzalez
b4c864bea7 Use sed to indent output of dokku url command 2014-12-11 02:34:24 -05:00
Jose Diaz-Gonzalez
01e7f1cdb6 Output *all* hosts on multiple lines 2014-12-11 02:34:08 -05:00
Jose Diaz-Gonzalez
0865ff3f79 Use updated VHOST file instead of URL file when outputting the current URL to an app
Note that this may include more than one URL to an app
2014-12-11 02:16:52 -05:00
Jose Diaz-Gonzalez
11b126a845 Do not overwrite URL file 2014-12-11 02:14:52 -05:00
Jose Diaz-Gonzalez
605ba27eeb Use a one-liner for the "Configuring" echo statement 2014-12-11 02:12:46 -05:00
Jose Diaz-Gonzalez
8109c9c569 Delete the VHOST file, not the URL file, when NO_VHOST is set
The URL file is useful for understanding what port docker decided to host our app internally on.
2014-12-11 02:10:49 -05:00
Jose Diaz-Gonzalez
9111902542 Fix issue where VHOST was not properly being set
The URL file is being rewritten on every deploy by `dokku deploy` and thus that file was incorrect. Instead, we just reuse the old logic from the nginx-vhosts plugin to handle creation of the VHOST file
2014-12-11 02:09:54 -05:00
Jose Diaz-Gonzalez
4955f9c600 Fix test for file 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
976dc3009c Use a normal conditional 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
0b4b2b29a8 Add missing env var 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
e84526490e Move VHOST file creation to a single domains:setup command
This helps remove duplication and also ensures that all hosts have a proper setup after running `make copyfiles`

Note that this command is not exposed in help as it is not generally useful to developers
2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
66171551d8 Add domains plugin as written in https://github.com/jtangelder/dokku-nginx-alt
This plugin conforms to the heroku api for setting and removing domains. Note that it does not yet update the URL file for a given application.
2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
f23809e75f Implement the ability to set multiple server names for a given application
Adding a hostname to the $APP/VHOST file will enable it as a virtualhost for the application.

In addition, any hostname set that matches an associated ssl certificate will also be set as an ssl host. Note that if a hostname does not have a matching SSL host, then it will result in an erroring application.

For the moment, running `dokku url` on an app may not correctly display the current hostnames for said app.
2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
b967514c55 Allow overriding of the nginx.conf template via nginx.conf.template 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
a6c34ddd6f Use a template to create an application's nginx.conf 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
8f0e794893 Remove extra dash 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
68a1d1af38 one-liner 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
eeff3d52eb Combine calls to restart nginx into a single command 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
8aa196c660 Remove extra reload command 2014-12-11 01:36:44 -05:00
Jose Diaz-Gonzalez
d9d66c58ab Fix reference to $APP 2014-12-08 22:16:05 -05:00
Jose Diaz-Gonzalez
155f4e9aba Release 0.3.8 2014-12-08 22:14:03 -05:00
Jose Diaz-Gonzalez
1bfbdb449b Merge pull request #808 from progrium/proper-editorconfig
Ensure makefiles are properly formatted
2014-12-08 22:12:21 -05:00
Jose Diaz-Gonzalez
b3ca3368e8 Ensure makefiles are properly formatted 2014-12-08 22:12:04 -05:00
Jose Diaz-Gonzalez
04921d6876 Merge pull request #807 from progrium/799-force-nginx-conf
#799: Force nginx conf
2014-12-08 22:05:17 -05:00
Jose Diaz-Gonzalez
a915b8888f Ensure ruby is installed when running the dokku-installer 2014-12-08 21:57:10 -05:00
Jose Diaz-Gonzalez
129a5fd33d Force install a default nginx.conf. Closes #799 2014-12-08 21:20:54 -05:00
Jose Diaz-Gonzalez
e567ce1a90 Merge pull request #806 from progrium/fix-remote-user
Dokku pushes now happen as the dokku user, not git. Refs #796
2014-12-08 20:59:22 -05:00
Jose Diaz-Gonzalez
489f131ffc Dokku pushes now happen as the dokku user, not git. Refs #796 2014-12-08 20:58:50 -05:00
Jose Diaz-Gonzalez
45ec8df7be Merge pull request #805 from ademuk/patch-1
Fixed import-ssl server.crt/key check
2014-12-08 20:36:18 -05:00
Adem Gaygusuz
469d1e3f49 Fix crt/key check 2014-12-09 00:37:47 +00:00
Jose Diaz-Gonzalez
7ca2f49d78 Merge pull request #801 from joelvh/patch-1
Point users to upgrade guides
2014-12-02 08:55:48 -05:00
Joel Van Horn
69176d2d9a Point users to upgrade guides 2014-12-02 00:33:44 -05:00
Jose Diaz-Gonzalez
ad030b21d4 Merge pull request #796 from progrium/795-better-docs
795 better docs
2014-11-27 15:13:31 -05:00
Jose Diaz-Gonzalez
8c8f5e17f1 Tell users to change directory to dokku before running vagrant up. Refs #795 2014-11-27 15:10:33 -05:00
Jose Diaz-Gonzalez
e0b994c415 Standardize on dokku.me as the test hostname. Refs #795 2014-11-27 15:09:46 -05:00
Jose Diaz-Gonzalez
a12b1e2b56 Release 0.3.7 2014-11-25 15:46:48 -05:00
Jose Diaz-Gonzalez
590c5fc017 Merge pull request #789 from mmerickel/fix.deploy-vhost 2014-11-25 15:44:19 -05:00
Michael Merickel
ee5c35dd9d do not output message when creating ENV file
This fixes a bug introduced when deploying apps where the
nginx-vhosts plugin runs ``dokku config:get $APP NO_VHOST``. The initial
run of this actually was creating the ``ENV`` file and dumping to
stdout the value "NO_VHOST=-----> Creating /home/dokku/foo/ENV". This
was obviously no good because nginx-vhosts was considering this to be a
value of true.

I've modified this to simply not return anything when the value does not
exist. A better update may be to output the messages to stderr instead
of stdout.
2014-11-25 15:43:36 -05:00
Jose Diaz-Gonzalez
42a1363996 Merge pull request #788 from mmerickel/fix.apps-plugin
fix apps plugin issues in 0.3.6
2014-11-25 13:28:17 -05:00
Michael Merickel
4ae8cf8180 fix search for apps if DOKKU_ROOT is a symlink 2014-11-25 11:56:05 -06:00
Michael Merickel
aef3a68d2b fix app plugin that was always searching for empty app name 2014-11-25 11:55:25 -06:00
Jose Diaz-Gonzalez
6ddc7275dd First pass at official user-env-compile plugin
- Uses ENV and APP/ENV files
- Supports old BUILD_ENV files (which are likely in wide-use)
- Allows user's to override globals with app-specific configuration

Closes #284
Closes #683
Closes #763

Refs #503
Refs #678
2014-11-25 11:24:58 -05:00
Jose Diaz-Gonzalez
58ca13e838 Release 0.3.6 2014-11-25 10:44:32 -05:00
Jose Diaz-Gonzalez
7c2f21fd2a Merge pull request #782 from progrium/simplified-config
Simplified config
2014-11-24 13:17:27 -05:00
Jose Diaz-Gonzalez
887637fb6b Merge pull request #785 from lsde/master
fix missing semicolon in nginx config
2014-11-24 10:33:26 -05:00
Jonas Svatos
c706344a94 fix missing semicolon in nginx config 2014-11-24 13:22:50 +01:00
Jose Diaz-Gonzalez
a1bbc1ec4d Release 0.3.5 2014-11-24 02:17:50 -05:00
Jose Diaz-Gonzalez
793f1b6058 Merge pull request #784 from progrium/no-vhost-hotfix
Fix NO_VHOST check
2014-11-24 02:16:39 -05:00
Jose Diaz-Gonzalez
20977fc2a2 Fix NO_VHOST check
It used to check if NO_VHOST is unset or set to the empty string
It now checks if NO_VHOST is set to a non-empty string
2014-11-24 02:16:21 -05:00
Jose Diaz-Gonzalez
407436b4cc Exit 0 if there is no configuration
heroku config:get exits 0 in this case
2014-11-23 23:32:42 -05:00
Jose Diaz-Gonzalez
04dbe31919 Unify the way in which all error messages are specified
Other parts of dokku use one-liners where possible, so these parts should as well
2014-11-23 23:32:42 -05:00
Jose Diaz-Gonzalez
56185fc1c2 Correct plugin example
$APP is not available until after the if guards
2014-11-23 23:32:42 -05:00
Jose Diaz-Gonzalez
303bd77226 Simplify if statement 2014-11-23 23:32:42 -05:00
Jose Diaz-Gonzalez
c6e39c08f0 Simplify env var checking in config plugin
All checks are now done within the commands, and we only need to ensure the config file exists.
2014-11-23 23:32:42 -05:00
Jose Diaz-Gonzalez
12194e2cc8 Add proper error handling to each config command 2014-11-23 23:32:42 -05:00
Jose Diaz-Gonzalez
a3b3a6a12a Unify missing app error messages 2014-11-23 23:32:42 -05:00
29 changed files with 608 additions and 276 deletions

View File

@@ -4,3 +4,8 @@ root = true
insert_final_newline = true
indent_style = space
indent_size = 2
[Makefile]
insert_final_newline = true
indent_style = tab
indent_size = 4

View File

@@ -1,5 +1,48 @@
# History
## 0.3.10
- #783: @josegonzalez New domains plugin and nginx extension
- #818: @michaelhobbs rebuild nginx config on domain change
- #827: @michaelhobbs Handle IP only access
- #828: @michaelhobbs Display the port for an app when falling back to the ip address
## 0.3.9
- #787: @josegonzalez/@michaelhobbs Official user-env-compile plugin
- Uses ENV and APP/ENV files
- Supports old `BUILD_ENV` files (which are likely in wide-use)
- Allows user's to override globals with app-specific configuration
- Migrate `$DOKKU_ROOT/BUILD_ENV` to `$DOKKU_ROOT/ENV` if the former exists and the latter does not
- Drop `BUILD_ENV` support in favor of just `ENV` via a `mv` command
- Add default ENV with `CURL_TIMEOUT` and `CURL_CONNECT_TIMEOUT`
- #811: @abossard Increased `server_names_hash_bucket_size` in nginx.conf to 512
- #814: @josegonzalez Source files in $DOKKU_ROOT/.dokkurc directory and add `dokku trace` command
- #816: @josegonzalez Add documentation for user-env feature
## 0.3.8
- #796: @josegonzalez Better vagrant documentation
- #801: @joelvh Point users to upgrade guides
- #805: @ademuk Fixed import-ssl server.crt/key check
- #806: @josegonzalez Dokku pushes now happen as the dokku user, not git. Refs #796
- #807: @josegonzalez Write proper nginx conf upon installation. Closes #799
- #808: @josegonzalez Ensure makefiles are properly formatted
## 0.3.7
- #788: @mmerickel fix apps plugin issues in 0.3.6
- #789: @mmerickel do not output message when creating ENV file
## 0.3.6
- #782: @josegonzalez Simplified config checking
- #785: @lsde fix missing semicolon in nginx config
## 0.3.5
- #784: @josegonzalez Fix NO_VHOST check
## 0.3.4
- #780: @josegonzalez Output error message when a command is not found. Closes #778

View File

@@ -91,6 +91,7 @@ count:
@find tests -type f | xargs cat | wc -l
dokku-installer:
apt-get install -qq -y ruby
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

View File

@@ -10,7 +10,11 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. S
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.4/bootstrap.sh | sudo DOKKU_TAG=v0.3.4 bash
$ wget -qO- https://raw.github.com/progrium/dokku/v0.3.10/bootstrap.sh | sudo DOKKU_TAG=v0.3.10 bash
### Upgrading
[View the docs for upgrading](http://progrium.viewdocs.io/dokku/upgrading) from an older version of Dokku.
## Documentation

View File

@@ -21,7 +21,7 @@ if ARGV[0] == "onboot"
exit
end
version = "v0.3.4"
version = "v0.3.10"
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

View File

@@ -4,8 +4,8 @@ Now you can deploy apps on your Dokku. Let's deploy the [Heroku Node.js sample a
```
$ cd node-js-sample
$ git remote add progrium dokku@progriumapp.com:node-js-app
$ git push progrium master
$ git remote add dokku dokku@dokku.me:node-js-app
$ git push dokku master
Counting objects: 296, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (254/254), done.
@@ -18,12 +18,12 @@ Total 296 (delta 25), reused 276 (delta 13)
... blah blah blah ...
-----> Application deployed:
http://node-js-app.progriumapp.com
http://node-js-app.dokku.me
```
You're done!
Dokku only supports deploying from its master branch, so if you'd like to deploy a different local branch use: ```git push progrium <local branch>:master```
Dokku only supports deploying from its master branch, so if you'd like to deploy a different local branch use: ```git push dokku <local branch>:master```
Right now Buildstep supports buildpacks for Node.js, Ruby, Python, [and more](https://github.com/progrium/buildstep#supported-buildpacks). It's not hard to add more, [go add more](https://github.com/progrium/buildstep#adding-buildpacks)!
Please check the documentation for your particular build pack as you may need to include configuration files (such as a Procfile) in your project root.
@@ -53,38 +53,38 @@ Alternatively, you may push an app to your dokku host with a name like "00-defau
The name of remote repository is used as the name of application to be deployed, as for example above:
$ git remote add progrium git@progriumapp.com:node-js-app
$ git push progrium master
$ git remote add dokku dokku@dokku.me:node-js-app
$ git push dokku master
Is deployed to,
remote: -----> Application deployed:
remote: http://node-js-app.progriumapp.com
remote: http://node-js-app.dokku.me
You can also specify fully qualified names, say `app.progrium.com`, as
You can also specify fully qualified names, say `app.dokku.me`, as
$ git remote add progrium git@progriumapp.com:app.progrium.com
$ git push progrium master
$ git remote add dokku dokku@dokku.me:app.dokku.me
$ git push dokku master
So, after deployment the application will be available at,
remote: -----> Application deployed:
remote: http://app.progrium.com
remote: http://app.dokku.me
This is in particular useful, then you want to deploy to root domain, as
$ git remote add progrium git@progriumapp.com:progrium.com
$ git push progrium master
$ git remote add dokku dokku@dokku.me:dokku.me
$ git push dokku master
... deployment ...
remote: -----> Application deployed:
remote: http://progrium.com
remote: http://dokku.me
# Removing a deployed app
SSH onto the server, then execute:
```bash
```shell
dokku delete myapp
```

View File

@@ -11,4 +11,6 @@ config:set <app> KEY1=VALUE1 [KEY2=VALUE2 ...] - set one or more config vars
config:unset <app> 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.
The variables are available both at at run time and during the application build/compilation step. You no longer need a `user-env` plugin as Dokku handles this functionality in a way equivalent to how Heroku handles it.
> Note: Global `BUILD_ENV` files are currently migrated into a global `ENV` file. Configuring your global `ENV` file is manual, and should be considered potentially dangerous as configuration applies to all applications.

View File

@@ -10,8 +10,8 @@ Ubuntu 14.04 x64 x64. Ideally have a domain ready to point to your host. It's de
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.3.4/bootstrap.sh | sudo DOKKU_TAG=v0.3.4 bash
```shell
wget -qO- https://raw.github.com/progrium/dokku/v0.3.10/bootstrap.sh | sudo DOKKU_TAG=v0.3.10 bash
```
## Configuring
@@ -20,7 +20,7 @@ Set up a domain and a wildcard domain pointing to that host. Make sure `/home/do
You'll have to add a public key associated with a username by doing something like this from your local machine:
$ cat ~/.ssh/id_rsa.pub | ssh progriumapp.com "sudo sshcommand acl-add dokku progrium"
$ cat ~/.ssh/id_rsa.pub | ssh dokku.me "sudo sshcommand acl-add dokku $USER"
That's it!
@@ -28,7 +28,7 @@ That's it!
### Development via bash script
```bash
```shell
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
```
@@ -41,7 +41,7 @@ You may also wish to take a look at the [advanced installation](http://progrium.
If you plan on developing dokku, the easiest way to install from your own repository is cloning
the repository and calling the install script. Example:
```bash
```shell
git clone https://github.com/yourusername/dokku.git
cd dokku
sudo make install
@@ -52,7 +52,7 @@ repositories. The `DOCKER_URL`, `PLUGINHOOK_URL`, `SSHCOMMAND_URL` and `STACK_UR
environment variables may be set to override the defaults (see the `Makefile` for how these
apply). Example:
```bash
```shell
sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/sshcommand make install
```
@@ -61,7 +61,7 @@ sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/sshcom
The bootstrap script allows the dokku repository URL to be overridden to bootstrap a host from
your own clone of dokku using the `DOKKU_REPO` environment variable. Example:
```bash
```shell
wget https://raw.github.com/progrium/dokku/master/bootstrap.sh
chmod +x bootstrap.sh
sudo DOKKU_REPO=https://github.com/yourusername/dokku.git ./bootstrap.sh
@@ -73,7 +73,7 @@ Dokku ships with a pre-built version of the [buildstep](https://github.com/progr
default. If you want to build your own version you can specify that with an env
variable.
```bash
```shell
git clone https://github.com/progrium/dokku.git
cd dokku
sudo BUILD_STACK=true make install
@@ -110,6 +110,7 @@ sudo BUILD_STACK=true make install
# - `BOX_MEMORY`
# - `DOKKU_DOMAIN`
# - `DOKKU_IP`.
cd path/to/dokku
vagrant up
```
@@ -140,7 +141,7 @@ Deploy using the following StackScript:
* Run the following commands:
```bash
```shell
apt-get update
apt-get install lxc wget bsdtar linux-image-extra-$(uname -r)
@@ -149,6 +150,6 @@ Deploy using the following StackScript:
```
* After this, you can install dokku the default way:
```bash
```shell
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
```

View File

@@ -43,15 +43,39 @@ dokku nginx:import-ssl myapp < archive-of-certs.tar
This archive should is expanded via `tar xvf`. It should contain `server.crt` and `server.key`.
## Disabling VHOSTS
## Customizing the nginx configuration
If desired, it is possible to disable vhosts by setting the `NO_VHOST` environment variable:
> New as of 0.3.10
```bash
dokku config:set myapp NO_VHOST=1
Dokku currently templates out an nginx configuration that is included in the `nginx-vhosts` plugin. If you'd like to provide a custom template for your application, you should copy the existing template - ssl or non-ssl - into your `$DOKKU_ROOT/$APP` directory at the file `nginx.conf.template`.
For instance - assuming defaults - to customize the nginx template in use for the `myapp` application, create a file at `/home/dokku/myapp/nginx.conf.template` with the following contents:
```
server {
listen [::]:80;
listen 80;
server_name $NOSSL_SERVER_NAME;
# set a custom header for requests
add_header X-Served-By www-ec2-01;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec;
}
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
}
```
On subsequent deploys, the nginx virtualhost will be discarded. This is useful when deploying internal-facing services that should not be publicly routeable.
The above is a sample, http configuration that adds an `X-Served-By` header to requests. The template is manually uploaded this template file and **must** it owned by `dokku:dokku`.
## Customizing hostnames
@@ -65,7 +89,7 @@ The `subdomain` is inferred from the pushed application name, while the `domain`
You can optionally override this in a plugin by implementing the `nginx-hostname` pluginhook. For example, you can reverse the subdomain with the following sample `nginx-hostname` pluginhook:
```bash
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
@@ -76,3 +100,39 @@ echo "$NEW_SUBDOMAIN.$VHOST"
```
If the `nginx-hostname` has no output, the normal hostname algorithm will be executed.
You can also use the built-in `domains` plugin to handle:
### Disabling VHOSTS
If desired, it is possible to disable vhosts by setting the `NO_VHOST` environment variable:
```shell
dokku config:set myapp NO_VHOST=1
```
On subsequent deploys, the nginx virtualhost will be discarded. This is useful when deploying internal-facing services that should not be publicly routeable.
### Domains plugin
> New as of 0.3.10
The domains plugin allows you to specify custom domains for applications. This plugin is aware of any ssl certificates that are imported via `nginx:import-ssl`. Be aware that setting `NO_VHOST` will override any custom domains.
Custom domains are also backed up via the built-in `backup` plugin
```shell
# where `myapp` is the name of your app
# add a domain to an app
dokku domains:add myapp example.com
# list custom domains for app
dokku domains myapp
# clear all custom domains for app
dokku domains:clear myapp
# remove a custom domain from app
dokku domains:remove myapp example.com
```

View File

@@ -11,7 +11,7 @@ Let's take a quick look at the current dokku nginx plugin that's shipped with do
## Installing a plugin
```bash
```shell
cd /var/lib/dokku/plugins
git clone <git url>
dokku plugins-install
@@ -32,14 +32,14 @@ If you create your own plugin:
The below plugin is a dummy `dokku hello` plugin. If your plugin exposes commands, this is a good template for your `commands` file:
```bash
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
hello)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$APP" ]] && echo "App $APP does not exist" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2";
echo "Hello $APP"
@@ -208,8 +208,6 @@ Note: The following plugins have been supplied by our community and may not have
| [SSH Deployment Keys](https://github.com/cedricziel/dokku-deployment-keys)<sup>2</sup> | [cedricziel][] | 2014-01-17: compatible with upstream/master |
| [SSH Hostkeys](https://github.com/cedricziel/dokku-hostkeys-plugin)<sup>3</sup> | [cedricziel][] | 2014-01-17: compatible with upstream/master |
| [Supply env vars to buildpacks](https://github.com/cameron-martin/dokku-build-env) | [cameron-martin][] | Works with v0.2.3 |
| [user-env-compile](https://github.com/musicglue/dokku-user-env-compile)<sup>1</sup> | [musicglue][] | Compatible with dokku master branch |
| [user-env-compile](https://github.com/motin/dokku-user-env-compile)<sup>1</sup> | [motin][] | Compatible with 0.2.1 |
| [VHOSTS Custom Configuration](https://github.com/neam/dokku-nginx-vhosts-custom-configuration) | [motin][] | Compatible with 0.3.1 |
| [Volume (persistent storage)](https://github.com/ohardy/dokku-volume) | [ohardy][] | Compatible with 0.2.0 |
@@ -218,8 +216,6 @@ Note: The following plugins have been supplied by our community and may not have
[98332de]: https://github.com/dyson/dokku-persistent-storage/commit/98332de4b5b640610bee535f4d5260263074e18b
[a043e98]: https://github.com/stuartpb/dokku-bind-port/commit/a043e9892f4815b6525c850131e09fd64db5c1fa
<sup>1</sup> Similar to the heroku-labs feature (see https://devcenter.heroku.com/articles/labs-user-env-compile)
<sup>2</sup> Adds the possibility to add SSH deployment keys to receive private hosted packages
<sup>3</sup> Adds the ability to add custom hosts to the containers known_hosts file to be able to ssh them easily (useful with deployment keys)

View File

@@ -1,11 +1,11 @@
# Remote commands
Dokku commands can be run over ssh. Anywhere you would run `dokku <command>`, just run `ssh -t dokku@progriumapp.com <command>`
Dokku commands can be run over ssh. Anywhere you would run `dokku <command>`, just run `ssh -t dokku@dokku.me <command>`
The `-t` is used to request a pty. It is highly recommended to do so.
To avoid the need to type the `-t` option each time, simply create/modify a section in the `.ssh/config` on the client side, as follows:
```
Host progriumapp.com
Host dokku.me
RequestTTY yes
```
@@ -13,7 +13,7 @@ RequestTTY yes
It's possible to run commands in the environment of the deployed application:
```bash
```shell
dokku run node-js-app ls -alh
dokku run <app> <cmd>
```

View File

@@ -43,11 +43,16 @@ __Solution:__
The `remote rejected` error does not give enough information. Anything could have failed.
Create a `/home/dokku/dokkurc` file containing the following :
To enable dokku tracing, simply run the following command:
# Since 0.3.9
dokku trace
In versions older than 0.3.9, you can create a `/home/dokku/dokkurc` file containing the following :
export DOKKU_TRACE=1
This will trace all of dokku's activity. If this does not help you create a pastebin or a gist containing the full log, and create an issue.
This will trace all of dokku's activity. If this does not help you, create a [gist](https://gist.github.com) containing the full log, and create an issue.
***

View File

@@ -6,7 +6,7 @@ Dokku is in active development. You can update the deployment step and the build
To update the deploy step (this is updated less frequently):
```bash
```shell
cd ~/dokku
git pull origin master
sudo make install
@@ -16,7 +16,7 @@ Nothing needs to be restarted. Changes will take effect on the next push / deplo
To update the build step:
```bash
```shell
git clone https://github.com/progrium/buildstep.git
cd buildstep
git pull origin master
@@ -34,7 +34,7 @@ This should be summary of breaking changes between 0.1 and 0.2 version with inst
software-properties-common is now a dependency for plugins. Before running dokku install script, make sure it is installed.
```bash
```shell
> sudo apt-get install software-properties-common
```

3
dokku
View File

@@ -10,6 +10,7 @@ export DOKKU_NOT_IMPLEMENTED_EXIT=10
export DOKKU_VALID_EXIT=0
[[ -f $DOKKU_ROOT/dokkurc ]] && source $DOKKU_ROOT/dokkurc
[[ -d $DOKKU_ROOT/.dokkurc ]] && for f in $DOKKU_ROOT/.dokkurc/*; do source $f; done
[[ $DOKKU_TRACE ]] && set -x
@@ -36,7 +37,7 @@ case "$1" in
echo "-----> Deploying $APP ..."
dokku deploy $APP
echo "=====> Application deployed:"
echo " $(dokku url $APP)"
echo "$(dokku urls $APP | sed "s/^/ /")"
echo
;;

View File

@@ -2,20 +2,32 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
trace)
[[ -d $DOKKU_ROOT/.dokkurc ]] || mkdir -p $DOKKU_ROOT/.dokkurc
[[ "$2" == "on" ]] || [[ "$2" == "off" ]] || {
echo "Valid trace options are [on/off]"
exit 1
}
if [[ "$2" == "on" ]]; then
echo "Enabling dokku trace"
echo "export DOKKU_TRACE=1" > $DOKKU_ROOT/.dokkurc/DOKKU_TRACE
fi
if [[ "$2" == "off" ]]; then
echo "Disabling dokku trace"
rm -f $DOKKU_ROOT/.dokkurc/DOKKU_TRACE
fi
;;
delete)
dokku apps:destroy $2
;;
logs)
if [[ -z $2 ]]; then
echo "Please specify an app to run the command on"
exit 1
fi
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2";
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist"
exit 1
fi
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
CONTAINER=$(<$DOKKU_ROOT/$APP/CONTAINER)
@@ -30,30 +42,40 @@ case "$1" in
;;
run)
if [[ -z $2 ]]; then
echo "Please specify an app to run the command on"
exit 1
fi
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"; IMAGE="dokku/$APP"
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist"
exit 1
fi
shift 2
DOCKER_ARGS=$(: | pluginhook docker-args $APP)
docker run -i -t $DOCKER_ARGS $IMAGE /exec "$@"
;;
url)
APP="$2";
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist"
exit 1
url | urls)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"; SCHEME="http"; SSL="$DOKKU_ROOT/$APP/tls"
if [[ -e "$SSL/server.crt" ]] && [[ -e "$SSL/server.key" ]]; then
SCHEME="https"
fi
if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then
echo $(< "$DOKKU_ROOT/$APP/URL")
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
case "$1" in
url)
echo "$SCHEME://$(head -n1 "$DOKKU_ROOT/$APP/VHOST")"
;;
urls)
for vhost in $(< "$DOKKU_ROOT/$APP/VHOST"); do
echo "$SCHEME://$vhost"
done
;;
esac
elif [[ -f "$DOKKU_ROOT/VHOST" ]]; then
echo "$SCHEME://$(< "$DOKKU_ROOT/VHOST")"
else
echo "$SCHEME://$(< "$DOKKU_ROOT/HOSTNAME"):$(< "$DOKKU_ROOT/$APP/PORT")"
fi
;;
@@ -68,7 +90,8 @@ case "$1" in
cat && cat<<EOF
logs <app> [-t] Show the last logs for an application (-t follows)
run <app> <cmd> Run a command in the environment of an application
url <app> Show the URL for an application
url <app> Show the first URL for an application (compatibility)
urls <app> Show all URLs for an application
version Print dokku's version
EOF
;;

View File

@@ -5,6 +5,10 @@ if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then
echo $(hostname -f) > $DOKKU_ROOT/HOSTNAME
fi
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
[[ $(dig +short $(< "$DOKKU_ROOT/HOSTNAME")) ]] && cp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/VHOST"
fi
# temporary hack for https://github.com/progrium/dokku/issues/82
# redeploys all apps after a reboot
case "$DOKKU_DISTRO" in

View File

@@ -4,39 +4,23 @@ 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
find $DOKKU_ROOT -follow -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
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ -d "$DOKKU_ROOT/$2" ]] && echo " ! Name is already taken" && exit 1
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
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
[[ "$2" == "tls" ]] && echo "Unable to destroy tls directory" && exit 1
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)."

31
plugins/build-env/pre-build Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE="dokku/$APP"; BUILD_ENV=""
[[ -f "$DOKKU_ROOT/BUILD_ENV" ]] && cat "$DOKKU_ROOT/BUILD_ENV" >> "$DOKKU_ROOT/ENV" && rm "$DOKKU_ROOT/BUILD_ENV"
[[ ! $(grep CURL_CONNECT_TIMEOUT "$DOKKU_ROOT/ENV") ]] && echo "export CURL_CONNECT_TIMEOUT=5" >> "$DOKKU_ROOT/ENV"
[[ ! $(grep CURL_TIMEOUT "$DOKKU_ROOT/ENV") ]] && echo "export CURL_TIMEOUT=30" >> "$DOKKU_ROOT/ENV"
if [[ -f "$DOKKU_ROOT/ENV" ]]; then
BUILD_ENV+=$(< "$DOKKU_ROOT/ENV")
fi
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
BUILD_ENV+=" "
BUILD_ENV+=$(< "$DOKKU_ROOT/$APP/ENV")
fi
if [[ ! -z "$BUILD_ENV" ]]; then
echo "-----> Adding BUILD_ENV to build environment..."
# create build env files for use in buildpacks like this:
# https://github.com/niteoweb/heroku-buildpack-buildout/blob/5879fa3418f7d8e079f1aa5816ba1adde73f4948/bin/compile#L34
id=$(echo $BUILD_ENV |sed 's@export @@g'| docker run -i -a stdin $IMAGE /bin/bash -c "for ENV_VAR in `cat`; do echo \$ENV_VAR |sed 's@^\([^=]*\)=\(.*\)\$@echo \2 >/tmp/env/\1@g' >>/tmp/set_env.sh; done && mkdir -p /tmp/env && /bin/bash /tmp/set_env.sh")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null
# create build env for 'old style' buildpacks and dokku plugins
id=$(echo "$BUILD_ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "cat >> /app/.env")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null
fi

View File

@@ -1,28 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# Check if name is specified
if [[ $1 == config ]] || [[ $1 == config:* ]]; then
if [[ -z $2 ]]; then
echo "You must specify an app name"
exit 1
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
echo "App $APP does not exist"
exit 1
fi
[ -f $ENV_FILE ] || {
echo "-----> Creating $ENV_FILE"
touch $ENV_FILE
}
fi
fi
ENV_FILE="$DOKKU_ROOT/$2/ENV"
ENV_FILE_TEMP="$DOKKU_ROOT/$2/ENV.tmp"
config_create () {
[ -f $ENV_FILE ] || {
touch $ENV_FILE
}
}
config_styled_hash () {
vars="$1"
@@ -76,12 +61,12 @@ config_write() {
case "$1" in
config)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [ ! -f $ENV_FILE ] || [ ! -s $ENV_FILE ] ; then
echo "$APP has no config vars"
exit 1
fi
config_create
[[ ! -s $ENV_FILE ]] && echo "$APP has no config vars" && exit 1
VARS=`cat $ENV_FILE | grep -Eo "export ([a-zA-Z_][a-zA-Z0-9_]*=.*)" | cut -d" " -f2-`
@@ -97,14 +82,19 @@ case "$1" in
;;
config:get)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z $3 ]]; then
echo "Usage: dokku config:get APP KEY"
echo "Must specify KEY."
exit 1
fi
if [ ! -f $ENV_FILE ] || [ ! -s $ENV_FILE ] ; then
exit 1
config_create
if [[ ! -s $ENV_FILE ]] ; then
exit 0
fi
KEY="$3"
@@ -113,13 +103,17 @@ case "$1" in
;;
config:set)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z "${*:3}" ]]; then
echo "Usage: dokku config:set APP KEY1=VALUE1 [KEY2=VALUE2 ...]"
echo "Must specify KEY and VALUE to set."
exit 1
fi
APP="$2"; APP_DIR="$DOKKU_ROOT/$APP"
config_create
ENV_ADD=""
ENV_TEMP=`cat "${ENV_FILE}"`
RESTART_APP=false
@@ -157,13 +151,17 @@ ${var}"
;;
config:unset)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z $3 ]]; then
echo "Usage: dokku config:unset APP KEY1 [KEY2 ...]"
echo "Must specify KEY to unset."
exit 1
fi
APP="$2"; APP_DIR="$DOKKU_ROOT/$APP"
config_create
ENV_TEMP=`cat "${ENV_FILE}"`
VARS="${*:3}"

9
plugins/domains/backup-export Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
shopt -s nullglob
VERSION="$1"
BASE_DIR="$2"
cat; for i in $BASE_DIR/*/VHOST; do echo $i; done
cat; for i in $BASE_DIR/*/nginx.conf.template; do echo $i; done

15
plugins/domains/backup-import Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
shopt -s nullglob
VERSION="$1"
IMPORT_DIR="$2"
TARGET_DIR="$3"
cd $IMPORT_DIR
for file in */VHOST; do
cp $file "$TARGET_DIR/$file"
done
for file in */nginx.conf.template; do
cp $file "$TARGET_DIR/$file"
done

112
plugins/domains/commands Executable file
View File

@@ -0,0 +1,112 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
domains)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
dokku domains:setup $APP
echo "=== $APP Domain Names"
cat "$DOKKU_ROOT/$APP/VHOST"
;;
domains:setup)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"; VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
if [[ ! -f $VHOST_PATH ]]; then
if [[ -f "$DOKKU_ROOT/VHOST" ]];then
VHOST=$(< "$DOKKU_ROOT/VHOST")
else
VHOST=$(< "$DOKKU_ROOT/HOSTNAME")
fi
if [[ "$VHOST" =~ ([0-9]{1,3}[\.]){3}[0-9]{1,3} ]];then
echo "ip found as hostname. disabling vhost support"
[[ ! $(grep -q NO_VHOST "$DOKKU_ROOT/$APP/ENV") ]] && echo "export NO_VHOST='1'" >> "$DOKKU_ROOT/$APP/ENV"
else
echo "-----> Creating new $VHOST_PATH..."
SUBDOMAIN=${APP/%\.${VHOST}/}
hostname=$(: | pluginhook nginx-hostname $APP $SUBDOMAIN $VHOST)
if [[ ! -n $hostname ]]; then
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
hostname="${APP/\//-}"
else
hostname="${APP/\//-}.$VHOST"
fi
fi
echo "$hostname" > $VHOST_PATH
fi
fi
;;
domains:add)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z $3 ]]; then
echo "Usage: dokku $1 $APP DOMAIN"
echo "Must specify DOMAIN."
exit 1
fi
if [[ $(grep $3 "$DOKKU_ROOT/$APP/VHOST" > /dev/null 2>&1; echo $?) -eq 0 ]]; then
echo "$3 is already defined for $APP"
exit 1
fi
dokku domains:setup $APP
echo "$3" >> "$DOKKU_ROOT/$APP/VHOST"
pluginhook post-domains-update $APP
echo "-----> Added $3 to $APP"
;;
domains:clear)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
rm -f "$DOKKU_ROOT/$APP/VHOST"
dokku domains:setup $APP
pluginhook post-domains-update $APP
echo "-----> Cleared domains in $APP"
;;
domains:remove)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2"
if [[ -z $3 ]]; then
echo "Usage: dokku $1 $2 DOMAIN"
echo "Must specify DOMAIN."
exit 1
fi
dokku domains:setup $APP
sed -i "/^$3$/d" "$DOKKU_ROOT/$APP/VHOST"
pluginhook post-domains-update $APP
echo "-----> Removed $3 from $APP"
;;
help | domains:help)
cat && cat<<EOF
domains <app> List custom domains for app
domains:add <app> DOMAIN Add a custom domain to app
domains:clear <app> Clear all custom domains for app
domains:remove <app> DOMAIN Remove a custom domain from app
EOF
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac

7
plugins/domains/install Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
for app in $(ls -d $DOKKU_ROOT/*/CONTAINER); do
APP=$(basename $(dirname $app));
dokku domains:setup $APP
done

View File

@@ -1,43 +1,118 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
restart_nginx () {
case "$DOKKU_DISTRO" in
ubuntu)
sudo /etc/init.d/nginx reload > /dev/null
;;
opensuse)
sudo /sbin/service nginx reload > /dev/null
;;
esac
}
case "$1" in
nginx:build-config)
APP="$2"; PORT="$3"
[[ -z "$PORT" ]] && PORT=$(< "$DOKKU_ROOT/$APP/PORT")
VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
WILDCARD_SSL="$DOKKU_ROOT/tls"
SSL="$DOKKU_ROOT/$APP/tls"
[[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV
if [[ ! -n "$NO_VHOST" ]]; then
NONSSL_VHOSTS=`cat $VHOST_PATH`
if [[ -e "$SSL/server.crt" ]] && [[ -e "$SSL/server.key" ]]; then
SSL_INUSE="$SSL"
SSL_DIRECTIVES=$(cat <<EOF
ssl_certificate $SSL_INUSE/server.crt;
ssl_certificate_key $SSL_INUSE/server.key;
EOF
)
elif [[ -e "$WILDCARD_SSL/server.crt" ]] && [[ -e "$WILDCARD_SSL/server.key" ]]; then
SSL_INUSE="$WILDCARD_SSL"
SSL_DIRECTIVES=""
fi
NGINX_CONF="$PLUGIN_PATH/nginx-vhosts/templates/nginx.conf"
SCHEME="http"
if [[ -n "$SSL_INUSE" ]]; then
NGINX_CONF="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf"
SCHEME="https"
SSL_HOSTNAME=`openssl x509 -in $SSL_INUSE/server.crt -noout -subject | tr '/' '\n' | grep CN= | cut -c4-`
SSL_HOSTNAME=`echo "$SSL_HOSTNAME" | sed 's|\.|\\.|g' | sed 's/\*/\.\*/g'`
SSL_VHOSTS=`egrep ^"$SSL_HOSTNAME"$ $VHOST_PATH`
NONSSL_VHOSTS=`egrep -v ^"$SSL_HOSTNAME"$ $VHOST_PATH || exit 0`
while read line; do
echo "-----> Configuring SSL for $line..."
SSL_SERVER_NAME=$line
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
done <<< "$SSL_VHOSTS"
fi
APP_NGINX_TEMPLATE="$DOKKU_ROOT/$APP/nginx.conf.template"
if [[ -f $APP_NGINX_TEMPLATE ]]; then
echo "-----> Overriding default nginx.conf with detected nginx.conf.template"
NGINX_CONF=$APP_NGINX_TEMPLATE
fi
cat $VHOST_PATH | xargs -i echo "-----> Configuring {}..."
# Include SSL_VHOSTS so we can redirect http to https on that hostname as well
NOSSL_SERVER_NAME=`echo $NONSSL_VHOSTS $SSL_VHOSTS| tr '\n' ' '`
echo "-----> Creating $SCHEME nginx.conf"
echo "upstream $APP { server 127.0.0.1:$PORT; }" > $DOKKU_ROOT/$APP/nginx.conf
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
echo "-----> Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $PORT
echo " Reloading nginx"
restart_nginx
else
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
echo "-----> NO_VHOST set, deleting $APP/VHOST"
rm "$DOKKU_ROOT/$APP/VHOST"
fi
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
echo "-----> NO_VHOST set, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf"
echo "-----> NO_VHOST set, reloading nginx after nginx.conf deletion"
restart_nginx
fi
fi
;;
nginx:import-ssl)
if [[ -z $2 ]]; then
echo "Please specify an app to create"
exit 1
fi
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
[[ -t 0 ]] && echo "Tar archive containing server.crt and server.key expected on stdin" && exit 1
APP="$2"
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
echo "App $APP does not exist"
exit 1
fi
if [[ -t 0 ]]; then
echo "Tar archive containing server.crt and server.key expected on stdin"
exit 1
fi
TEMP_DIR=`mktemp -d`
cd $TEMP_DIR
tar xvf - <&0
if [[ -f "$TEMP_DIR/server.crt" ]]; then
echo "Tar archive missing server.crt"
exit 1
fi
if [[ -f "$TEMP_DIR/server.key" ]]; then
echo "Tar archive missing server.key"
exit 1
fi
[[ ! -f "$TEMP_DIR/server.crt" ]] && echo "Tar archive missing server.crt" && exit 1
[[ ! -f "$TEMP_DIR/server.key" ]] && echo "Tar archive missing server.key" && exit 1
mkdir -p "$DOKKU_ROOT/$APP/tls"
mv "$TEMP_DIR/server.crt" "$DOKKU_ROOT/$APP/tls/server.crt"
mv "$TEMP_DIR/server.key" "$DOKKU_ROOT/$APP/tls/server.key"
cd $DOKKU_ROOT
rm -rf $TEMP_DIR
dokku nginx:build-config $APP
;;
help | nginx:help)
cat && cat<<EOF
nginx:import-ssl <app> Imports a tarball from stdin; should contain server.crt and server.key
nginx:build-config <app> (Re)builds nginx config for given app
EOF
;;

View File

@@ -32,11 +32,37 @@ ssl_prefer_server_ciphers on;
EOF
fi
echo 'server_names_hash_bucket_size 64' >| /etc/nginx/conf.d/server_names_hash_bucket_size.conf
cat<<EOF > /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
[[ $(dig +short $(< "$DOKKU_ROOT/HOSTNAME")) ]] && cp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/VHOST"
fi
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
EOF
echo 'server_names_hash_bucket_size 512;' >| /etc/nginx/conf.d/server_names_hash_bucket_size.conf
case "$DOKKU_DISTRO" in
ubuntu)

View File

@@ -2,134 +2,13 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; PORT="$2"
WILDCARD_SSL="$DOKKU_ROOT/tls"
SSL="$DOKKU_ROOT/$APP/tls"
set +e
NO_VHOST=$(dokku config:get $APP NO_VHOST)
set -e
set +e; NO_VHOST=$(dokku config:get $APP NO_VHOST); set -e
if [[ -z "$NO_VHOST" ]]; then
if [[ -n "$NO_VHOST" ]]; then
echo "-----> NO_VHOST config detected"
elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
dokku domains:setup $APP
fi
if [[ -f "$DOKKU_ROOT/VHOST" && ! -z "$NO_VHOST" ]]; then
VHOST=$(< "$DOKKU_ROOT/VHOST")
SUBDOMAIN=${APP/%\.${VHOST}/}
hostname=$(: | pluginhook nginx-hostname $APP $SUBDOMAIN $VHOST)
if [[ ! -n $hostname ]]; then
if [[ "$APP" == *.* ]] && [[ "$SUBDOMAIN" == "$APP" ]]; then
hostname="${APP/\//-}"
else
hostname="${APP/\//-}.$VHOST"
fi
fi
if [[ -e "$SSL/server.crt" ]] && [[ -e "$SSL/server.key" ]]; then
SSL_INUSE="$SSL"
SSL_DIRECTIVES=$(cat <<EOF
ssl_certificate $SSL_INUSE/server.crt;
ssl_certificate_key $SSL_INUSE/server.key;
EOF
)
elif [[ -e "$WILDCARD_SSL/server.crt" ]] && [[ -e "$WILDCARD_SSL/server.key" ]] && [[ $hostname = `openssl x509 -in $WILDCARD_SSL/server.crt -noout -subject | tr '/' '\n' | grep CN= | cut -c4-` ]]; then
SSL_INUSE="$WILDCARD_SSL"
SSL_DIRECTIVES=""
fi
if [[ -n "$SSL_INUSE" ]]; then
echo "-----> Creating ssl nginx.conf"
cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf
upstream $APP { server 127.0.0.1:$PORT; }
server {
listen [::]:80;
listen 80;
server_name $hostname;
return 301 https://\$host\$request_uri;
}
server {
listen [::]:443 ssl spdy;
listen 443 ssl spdy;
server_name $hostname;
$SSL_DIRECTIVES
keepalive_timeout 70;
add_header Alternate-Protocol 443:npn-spdy/2;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec;
}
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
}
EOF
echo "https://$hostname" > "$DOKKU_ROOT/$APP/URL"
else
echo "-----> Creating non-ssl nginx.conf"
cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf
upstream $APP { server 127.0.0.1:$PORT; }
server {
listen [::]:80;
listen 80;
server_name $hostname;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec;
}
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
}
EOF
echo "http://$hostname" > "$DOKKU_ROOT/$APP/URL"
fi
echo "-----> Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $PORT
echo " Reloading nginx"
case "$DOKKU_DISTRO" in
ubuntu)
sudo /etc/init.d/nginx reload > /dev/null
;;
opensuse)
sudo /sbin/service nginx reload > /dev/null
;;
esac
else
if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then
echo "------> NO_VHOST set, deleting $APP/URL"
rm "$DOKKU_ROOT/$APP/URL"
fi
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
echo "------> NO_VHOST set, deleting $APP/nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf"
echo "------> NO_VHOST set, reloading nginx after nginx.conf deletion"
case "$DOKKU_DISTRO" in
ubuntu)
sudo /etc/init.d/nginx reload > /dev/null
;;
opensuse)
sudo /sbin/service nginx reload > /dev/null
;;
esac
sudo /etc/init.d/nginx reload > /dev/null
fi
fi
dokku nginx:build-config $APP $PORT

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
dokku nginx:build-config $APP

View File

@@ -0,0 +1,17 @@
server {
listen [::]:80;
listen 80;
server_name $NOSSL_SERVER_NAME;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec;
}
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
}

View File

@@ -0,0 +1,28 @@
server {
listen [::]:80;
listen 80;
server_name $NOSSL_SERVER_NAME;
return 301 https://$SSL_SERVER_NAME\$request_uri;
}
server {
listen [::]:443 ssl spdy;
listen 443 ssl spdy;
server_name $SSL_SERVER_NAME;
$SSL_DIRECTIVES
keepalive_timeout 70;
add_header Alternate-Protocol 443:npn-spdy/2;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header X-Forwarded-Port \$server_port;
proxy_set_header X-Request-Start \$msec;
}
include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;
}