Compare commits
185 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d211223f58 | ||
|
|
c4540701fd | ||
|
|
74fa016bc1 | ||
|
|
5668f76cdd | ||
|
|
7e1e0ebb80 | ||
|
|
976c0be189 | ||
|
|
e2e36a5045 | ||
|
|
6bb513f12c | ||
|
|
48eca101f1 | ||
|
|
0e63b4e069 | ||
|
|
cd8292f7fa | ||
|
|
626cd958a5 | ||
|
|
15bd9db79c | ||
|
|
114cecc911 | ||
|
|
2a469df5e4 | ||
|
|
4d162aa209 | ||
|
|
b40a86a2fc | ||
|
|
cc8b1fccc1 | ||
|
|
e674591567 | ||
|
|
b39b0d4c78 | ||
|
|
0da389e8af | ||
|
|
182ae4a50a | ||
|
|
1aee972a82 | ||
|
|
b3269e3c95 | ||
|
|
c0f8764292 | ||
|
|
6ebb897150 | ||
|
|
ba4e87cb8b | ||
|
|
ea66619f3c | ||
|
|
62906cd542 | ||
|
|
9a71fff3f1 | ||
|
|
8880a9ce84 | ||
|
|
e61e6e94af | ||
|
|
d08cec5913 | ||
|
|
473f28b0c3 | ||
|
|
dda2ac03ee | ||
|
|
db6e71b7d6 | ||
|
|
daeea6ba13 | ||
|
|
0bfa25f73e | ||
|
|
b35190101c | ||
|
|
2ceed0cbdf | ||
|
|
eedb05d656 | ||
|
|
587de65441 | ||
|
|
7a6450f0f0 | ||
|
|
a90090bacd | ||
|
|
3bf68616ad | ||
|
|
450f9f19b2 | ||
|
|
f17b799638 | ||
|
|
6e0eb5938a | ||
|
|
af38e4f25a | ||
|
|
b6b8f4ddc1 | ||
|
|
140f5a4939 | ||
|
|
f86a6704bd | ||
|
|
c2c18af425 | ||
|
|
c5a74fac90 | ||
|
|
43869dd48d | ||
|
|
bd0b14692a | ||
|
|
a785bf82e6 | ||
|
|
1f6badc6a1 | ||
|
|
0816ee7575 | ||
|
|
0d2e5f1a14 | ||
|
|
7dd52ef1fc | ||
|
|
347366b6e4 | ||
|
|
3639f16137 | ||
|
|
eac3eba50e | ||
|
|
5606a308b6 | ||
|
|
9980b74688 | ||
|
|
414b1fd744 | ||
|
|
b99e26811b | ||
|
|
2e69ff6041 | ||
|
|
d9a989d6b0 | ||
|
|
75180f7f9b | ||
|
|
fc466e2c05 | ||
|
|
a54f9ebc7c | ||
|
|
1da6cd6b3c | ||
|
|
c5337cf6a2 | ||
|
|
b0189049b7 | ||
|
|
fc4699dee9 | ||
|
|
6eefcbb87c | ||
|
|
d9334900fb | ||
|
|
f92d8d9a6a | ||
|
|
b836c1f65a | ||
|
|
cb1aac75fb | ||
|
|
4aedb6507a | ||
|
|
02277cc411 | ||
|
|
495994daf0 | ||
|
|
56d0af02c4 | ||
|
|
1a70dd1707 | ||
|
|
e9ddde8a82 | ||
|
|
da92419023 | ||
|
|
4aa970ace8 | ||
|
|
a36aaab686 | ||
|
|
c1d901723d | ||
|
|
952ff31189 | ||
|
|
713a8d4f31 | ||
|
|
42712f8896 | ||
|
|
e0adfd035f | ||
|
|
379ee525a8 | ||
|
|
b9e7a09f4c | ||
|
|
a6c7cc50ce | ||
|
|
981e857ab1 | ||
|
|
c8c4a6a0c6 | ||
|
|
383deb2b1b | ||
|
|
9fdff11687 | ||
|
|
2f0f2889db | ||
|
|
dce031d38d | ||
|
|
31fafe55d3 | ||
|
|
833f308d2f | ||
|
|
0c715d4b39 | ||
|
|
a529f6fce8 | ||
|
|
0d838d1248 | ||
|
|
3d2af158ff | ||
|
|
673d43b532 | ||
|
|
290745d324 | ||
|
|
a18fa7afbe | ||
|
|
e9663caf5c | ||
|
|
5968e81b17 | ||
|
|
3aa5231f7e | ||
|
|
3c056527e8 | ||
|
|
0fe3d92fd7 | ||
|
|
2b8ea890ad | ||
|
|
9242a5dd31 | ||
|
|
d960b9c246 | ||
|
|
9f7a33ca3e | ||
|
|
39dd4fc700 | ||
|
|
1fa19591bf | ||
|
|
7c1ef003b7 | ||
|
|
e1f8654a74 | ||
|
|
c2fa8d14c9 | ||
|
|
eb0935a691 | ||
|
|
9d504fe93a | ||
|
|
e74c6460fb | ||
|
|
2cb957d1dd | ||
|
|
807e1b97b4 | ||
|
|
33258663f4 | ||
|
|
3361a20a30 | ||
|
|
979c1155c2 | ||
|
|
4ae7af091a | ||
|
|
7348d7790c | ||
|
|
715921c60e | ||
|
|
636e139e4a | ||
|
|
ddf893bc8a | ||
|
|
9a704bc656 | ||
|
|
d44788721f | ||
|
|
d88efd5cc4 | ||
|
|
930987ad02 | ||
|
|
14cc01dd5b | ||
|
|
bbc03dbfdd | ||
|
|
d5cc7595fd | ||
|
|
435f7e69eb | ||
|
|
0f8be7c946 | ||
|
|
d42bb79d38 | ||
|
|
389b5efa06 | ||
|
|
5c85e8bf65 | ||
|
|
99d2601f2f | ||
|
|
e27d0e6fa5 | ||
|
|
33f872183e | ||
|
|
4d7671dee3 | ||
|
|
f55e047619 | ||
|
|
661b6706de | ||
|
|
a8f08bd5a8 | ||
|
|
b299f66c28 | ||
|
|
b5495ed0c3 | ||
|
|
99c9bb2863 | ||
|
|
d6aa8d59f1 | ||
|
|
d9d3a16e5c | ||
|
|
5105c4f71d | ||
|
|
23a6656566 | ||
|
|
a2ed0ef2b6 | ||
|
|
e2d3107e8a | ||
|
|
0e5bc10ae7 | ||
|
|
b3053fe392 | ||
|
|
12ee6953bb | ||
|
|
9dfa7ccee6 | ||
|
|
45e53d3d9d | ||
|
|
ea7e3dc61d | ||
|
|
50fe9e39ad | ||
|
|
9312a99664 | ||
|
|
d8f69746bb | ||
|
|
e45db108d8 | ||
|
|
845c7e7dea | ||
|
|
e33d17b7dd | ||
|
|
96c6d46dd1 | ||
|
|
30f9ab740d | ||
|
|
5224a6c678 | ||
|
|
bc8750ebe3 |
1
AUTHORS
1
AUTHORS
@@ -1,6 +1,7 @@
|
||||
# If you're submitting a patch, please add your name here in alphabetical order as part of the patch.
|
||||
# This file lists all individuals having contributed content to the repository.
|
||||
#
|
||||
3onyc <3onyc@x3tech.com>
|
||||
Alexander <iam.asm89@gmail.com>
|
||||
Alexander Beletsky <alexander.beletsky@gmail.com>
|
||||
Alexis Gavoty <kload@kload.fr>
|
||||
|
||||
77
HISTORY.md
77
HISTORY.md
@@ -1,5 +1,82 @@
|
||||
# History
|
||||
|
||||
## 0.3.20
|
||||
|
||||
This release pegs Dokku to Docker 1.6.2. Docker 1.7.0 introduced changes in `docker ps` which cause incompatibilities with many popular dokku plugins.
|
||||
|
||||
### New Features
|
||||
|
||||
- #1245: @arthurschreiber Support config variables containing `\n`
|
||||
- #1257: @josegonzalez Split nginx ssl logs by $APP
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- #1207: @rockymadden Fixed bug with client commands taking verb, appname, and also arguments.
|
||||
- #1251: @josegonzalez Fallback to using /etc/init.d/nginx reload directly to restart nginx
|
||||
- #1264: @josegonzalez Require lxc-docker-1.6.2
|
||||
|
||||
### Docs Changes
|
||||
|
||||
- #1252: @josegonzalez Fix ssh port for vagrant installation. Closes #1139. [ci skip]
|
||||
- #1250: @josegonzalez SSL documentation is misleading
|
||||
|
||||
## 0.3.19
|
||||
|
||||
### New Features
|
||||
|
||||
- #1118: @michaelhobbs Heroku-style Container-Level scaling
|
||||
- #1210: @cddr Split nginx logs out by $APP
|
||||
- #1232: @michaelhobbs Allow passing of docker build options and document dockerfile deployment. Closes #1231
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- #1179: @follmann Prevent dismissal of URLs in CHECKS file that contain query params
|
||||
- #1193: @michaelhobbs Handle docker opts over ssh without escaping quotes. closes #1187
|
||||
- #1198: @3onyc Check web_config before key_file (Fixes #1196)
|
||||
- #1200: @josegonzalez Fix lintball from #1198
|
||||
- #1202: @michaelhobbs Filter out literal wildcard when deploying an unrelated domain. Closes #1185
|
||||
- #1204: @3onyc Fix bootstrap.sh, install curl when it's missing, make curl follow redirects, don't suppress stderr
|
||||
- #1206: @rockymadden Handle for installs in /usr/local/bin and the like.
|
||||
- #1212: @michaelhobbs Let circleci dictate docker install (fixes master)
|
||||
- #1217: @kirushanth-sakthivetpillai Fix broken ssl wildcard redirect
|
||||
- #1227: @Flink Use --no-cache when building Dockerfile
|
||||
- #1246: @josegonzalez Ensure we call apt-get before installing packages
|
||||
|
||||
### Docs Changes
|
||||
|
||||
- #1168: @cjblomqvist [docs] Update git-rev plugin to point to maintained version
|
||||
- #1180: @sherbondy [docs] Clarify usage around official dokku `docker-options` plugin
|
||||
- #1192: @alessio [docs] Add reference to dokku-events plugin
|
||||
- #1218: @michaelhobbs [docs] add dokku-logspout plugin
|
||||
- #1224: @lmars [docs] Add link from plugin-creation to pluginhooks
|
||||
- #1237: @zyegfryed [docs] Typo (at at -> at)
|
||||
|
||||
## 0.3.18
|
||||
|
||||
- #1111: @michaelhobbs Call pre-build-dockerfile before docker build
|
||||
- #1119: @joshco Logging info suggesting tuned CHECKS
|
||||
- #1120: @josegonzalez [docs] Add freenode shield to readme
|
||||
- #1121: @josegonzalez Prompt users to run the web installer via MOTD. Closes #943
|
||||
- #1129: @josegonzalez Validate nginx configuration before restarting nginx
|
||||
- #1137: @YellowApple [docs] Safer installation method
|
||||
- #1138: @chrisbutcher [docs] Include tip about using sshcommand acl-add
|
||||
- #1140: @NigelThorne [docs] Replaced reference to gitreceive with sshcommand as per #746
|
||||
- #1144: @protonet Allow git-remote with different port
|
||||
- #1145: @michaelhobbs allow docker-options over ssh. plus test. closes #1135
|
||||
- #1146: @michaelhobbs Don't re-deploy on domains:add. allow multple domains on command line. Closes #1142
|
||||
- #1147: @michaelhobbs Utilize all 4 free CircleCI containers
|
||||
- #1148: @TheEmpty [docs] Add information about 444 for nginx in default_sever.
|
||||
- #1150: @cjblomqvist [docs] Add monit plugin
|
||||
- #1151: @LTe Do not kill docker container with SIGKILL
|
||||
- #1153: @econya [docs] Add README-section: how to contribute
|
||||
- #1058: @josegonzalez Move bootstrap script to use debian package where possible
|
||||
- #1171: @josegonzalez Use debconf for package configuration
|
||||
- #1172: @michaelhobbs unify default and custom nginx template processing
|
||||
- #1173: @josegonzalez [docs] standardize readme badges
|
||||
- #1178: @jagandecapri [docs] Update plugins.md
|
||||
- #1189: @vincentfretin wait 30 seconds and not 30 minutes
|
||||
- #1190: @josegonzalez Fix docker gpg key installation
|
||||
|
||||
## 0.3.17
|
||||
|
||||
- #1056: @joshco New check retries feature
|
||||
|
||||
16
Makefile
16
Makefile
@@ -14,7 +14,7 @@ ifeq (vagrant-dokku,$(firstword $(MAKECMDGOALS)))
|
||||
$(eval $(RUN_ARGS):;@:)
|
||||
endif
|
||||
|
||||
.PHONY: all install copyfiles version plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku
|
||||
.PHONY: all apt-update install copyfiles man-db version plugins dependencies sshcommand pluginhook docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku
|
||||
|
||||
include tests.mk
|
||||
include deb.mk
|
||||
@@ -61,12 +61,18 @@ plugin-dependencies: pluginhook
|
||||
plugins: pluginhook docker
|
||||
dokku plugins-install
|
||||
|
||||
dependencies: sshcommand pluginhook docker help2man
|
||||
dependencies: apt-update sshcommand pluginhook docker help2man man-db
|
||||
$(MAKE) -e stack
|
||||
|
||||
apt-update:
|
||||
apt-get update
|
||||
|
||||
help2man:
|
||||
apt-get install -qq -y help2man
|
||||
|
||||
man-db:
|
||||
apt-get install -qq -y man-db
|
||||
|
||||
sshcommand:
|
||||
wget -qO /usr/local/bin/sshcommand ${SSHCOMMAND_URL}
|
||||
chmod +x /usr/local/bin/sshcommand
|
||||
@@ -80,15 +86,17 @@ docker: aufs
|
||||
apt-get install -qq -y curl
|
||||
egrep -i "^docker" /etc/group || groupadd docker
|
||||
usermod -aG docker dokku
|
||||
curl --silent https://get.docker.com/gpg | apt-key add -
|
||||
ifndef CI
|
||||
curl -sSL https://get.docker.com/gpg | apt-key add -
|
||||
echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
|
||||
apt-get update
|
||||
ifdef DOCKER_VERSION
|
||||
apt-get install -qq -y lxc-docker-${DOCKER_VERSION}
|
||||
else
|
||||
apt-get install -qq -y lxc-docker
|
||||
apt-get install -qq -y lxc-docker-1.6.2
|
||||
endif
|
||||
sleep 2 # give docker a moment i guess
|
||||
endif
|
||||
|
||||
aufs:
|
||||
ifndef CI
|
||||
|
||||
13
README.md
13
README.md
@@ -1,4 +1,4 @@
|
||||
# Dokku [](https://circleci.com/gh/progrium/dokku/tree/master) [](https://packagecloud.io/dokku/dokku)
|
||||
# Dokku [](https://circleci.com/gh/progrium/dokku/tree/master) [](https://packagecloud.io/dokku/dokku) [](https://webchat.freenode.net/?channels=dokku) [](http://progrium.viewdocs.io/dokku/index)
|
||||
|
||||
Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. Sponsored by our friends at [Deis](http://deis.io/).
|
||||
|
||||
@@ -8,9 +8,10 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. S
|
||||
|
||||
## Installing
|
||||
|
||||
To install the latest stable release, you can run the following command as a user that has access to `sudo`:
|
||||
To install the latest stable release, you can run the following commands as a user that has access to `sudo`:
|
||||
|
||||
wget -qO- https://raw.github.com/progrium/dokku/v0.3.17/bootstrap.sh | sudo DOKKU_TAG=v0.3.17 bash
|
||||
wget https://raw.github.com/progrium/dokku/v0.3.20/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.3.20 bash bootstrap.sh
|
||||
|
||||
### Upgrading
|
||||
|
||||
@@ -24,6 +25,12 @@ Full documentation - including advanced installation docs - are available online
|
||||
|
||||
You can use [Github Issues](https://github.com/progrium/dokku/issues), check [Troubleshooting](http://progrium.viewdocs.io/dokku/troubleshooting) in the documentation, or join us on [freenode in #dokku](https://webchat.freenode.net/?channels=%23dokku)
|
||||
|
||||
## Contribution
|
||||
|
||||
After checking [Github Issues](https://github.com/progrium/dokku/issues), the [Troubleshooting Guide](http://progrium.viewdocs.io/dokku/troubleshooting) or having a chat with us on [freenode in #dokku](https://webchat.freenode.net/?channels=%23dokku), feel free to fork and create a Pull Request.
|
||||
|
||||
While we may not merge your PR as is, they serve to start conversations and improve the general dokku experience for all users.
|
||||
|
||||
## Sponsors
|
||||
|
||||
Dokku is currently sponsored by the enterprise grade, multi-host PaaS project [Deis](http://deis.io/).
|
||||
|
||||
12
Vagrantfile
vendored
12
Vagrantfile
vendored
@@ -1,8 +1,7 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
BOX_NAME = ENV["BOX_NAME"] || "trusty"
|
||||
BOX_URI = ENV["BOX_URI"] || "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
|
||||
BOX_NAME = ENV["BOX_NAME"] || "chef/ubuntu-14.04"
|
||||
BOX_MEMORY = ENV["BOX_MEMORY"] || "1024"
|
||||
DOKKU_DOMAIN = ENV["DOKKU_DOMAIN"] || "dokku.me"
|
||||
DOKKU_IP = ENV["DOKKU_IP"] || "10.0.0.2"
|
||||
@@ -19,7 +18,6 @@ Vagrant::configure("2") do |config|
|
||||
config.ssh.forward_agent = true
|
||||
|
||||
config.vm.box = BOX_NAME
|
||||
config.vm.box_url = BOX_URI
|
||||
config.vm.synced_folder File.dirname(__FILE__), "/root/dokku"
|
||||
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
@@ -36,24 +34,24 @@ Vagrant::configure("2") do |config|
|
||||
vm.vm.network :forwarded_port, guest: 80, host: FORWARDED_PORT
|
||||
vm.vm.hostname = "#{DOKKU_DOMAIN}"
|
||||
vm.vm.network :private_network, ip: DOKKU_IP
|
||||
vm.vm.provision :shell, :inline => "DEBIAN_FRONTEND=noninteractive apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}"
|
||||
vm.vm.provision :shell, :inline => "export DEBIAN_FRONTEND=noninteractive && apt-get update > /dev/null && apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}"
|
||||
vm.vm.provision :shell, :inline => "cd /root/dokku && make dokku-installer"
|
||||
end
|
||||
|
||||
config.vm.define "dokku-deb", autostart: false do |vm|
|
||||
vm.vm.network :forwarded_port, guest: 80, host: ENV['FORWARDED_PORT']
|
||||
vm.vm.network :forwarded_port, guest: 80, host: FORWARDED_PORT
|
||||
vm.vm.hostname = "#{DOKKU_DOMAIN}"
|
||||
vm.vm.network :private_network, ip: DOKKU_IP
|
||||
vm.vm.provision :shell, :inline => "cd /root/dokku && make install-from-deb"
|
||||
end
|
||||
|
||||
config.vm.define "build", autostart: false do |vm|
|
||||
vm.vm.provision :shell, :inline => "DEBIAN_FRONTEND=noninteractive apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}"
|
||||
vm.vm.provision :shell, :inline => "apt-get update > /dev/null && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install git > /dev/null && cd /root/dokku && #{make_cmd}"
|
||||
vm.vm.provision :shell, :inline => "cd /root/dokku && make deb-all"
|
||||
end
|
||||
|
||||
if Pathname.new(PUBLIC_KEY_PATH).exist?
|
||||
config.vm.provision :file, source: PUBLIC_KEY_PATH, destination: '/tmp/id_rsa.pub'
|
||||
config.vm.provision :shell, :inline => "rm -f /root/.ssh/authorized_keys && cp /tmp/id_rsa.pub /root/.ssh/authorized_keys"
|
||||
config.vm.provision :shell, :inline => "rm -f /root/.ssh/authorized_keys && mkdir -p /root/.ssh && sudo cp /tmp/id_rsa.pub /root/.ssh/authorized_keys"
|
||||
end
|
||||
end
|
||||
|
||||
69
bootstrap.sh
69
bootstrap.sh
@@ -1,37 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
#
|
||||
# A script to bootstrap dokku.
|
||||
# It expects to be run on Ubuntu 14.04 via 'sudo'
|
||||
# If installing a tag higher than 0.3.13, it may install dokku via a package (so long as the package is higher than 0.3.13)
|
||||
# It checks out the dokku source code from Github into ~/dokku and then runs 'make install' from dokku source.
|
||||
|
||||
set -eo pipefail
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export DOKKU_REPO=${DOKKU_REPO:-"https://github.com/progrium/dokku.git"}
|
||||
|
||||
if ! command -v apt-get &>/dev/null
|
||||
then
|
||||
if ! command -v apt-get &>/dev/null; then
|
||||
echo "This installation script requires apt-get. For manual installation instructions, consult http://progrium.viewdocs.io/dokku/advanced-installation ."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get install -qq -y git make curl software-properties-common man-db help2man
|
||||
|
||||
which curl > /dev/null || apt-get install -qq -y curl
|
||||
[[ $(lsb_release -sr) == "12.04" ]] && apt-get install -qq -y python-software-properties
|
||||
|
||||
cd ~
|
||||
test -d dokku || git clone $DOKKU_REPO
|
||||
cd dokku
|
||||
git fetch origin
|
||||
dokku_install_source() {
|
||||
apt-get install -qq -y git make software-properties-common
|
||||
cd /root
|
||||
if [ ! -d /root/dokku ]; then
|
||||
git clone $DOKKU_REPO /root/dokku
|
||||
fi
|
||||
|
||||
cd /root/dokku
|
||||
git fetch origin
|
||||
git checkout $DOKKU_CHECKOUT
|
||||
make install
|
||||
}
|
||||
|
||||
dokku_install_package() {
|
||||
curl -sSL https://get.docker.io/gpg | apt-key add -
|
||||
curl -sSL https://packagecloud.io/gpg.key | apt-key add -
|
||||
|
||||
echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
|
||||
echo "deb https://packagecloud.io/dokku/dokku/ubuntu/ trusty main" > /etc/apt/sources.list.d/dokku.list
|
||||
|
||||
sudo apt-get update > /dev/null
|
||||
sudo apt-get install -qq -y "linux-image-extra-$(uname -r)" apt-transport-https
|
||||
|
||||
if [[ -n $DOKKU_CHECKOUT ]]; then
|
||||
sudo apt-get install -qq -y dokku=$DOKKU_CHECKOUT
|
||||
else
|
||||
sudo apt-get install -qq -y dokku
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -n $DOKKU_BRANCH ]]; then
|
||||
git checkout origin/$DOKKU_BRANCH
|
||||
export DOKKU_CHECKOUT="origin/$DOKKU_BRANCH"
|
||||
dokku_install_source
|
||||
elif [[ -n $DOKKU_TAG ]]; then
|
||||
git checkout $DOKKU_TAG
|
||||
export DOKKU_SEMVER="${DOKKU_TAG//v}"
|
||||
major=$(echo $DOKKU_SEMVER | awk '{split($0,a,"."); print a[1]}')
|
||||
minor=$(echo $DOKKU_SEMVER | awk '{split($0,a,"."); print a[2]}')
|
||||
patch=$(echo $DOKKU_SEMVER | awk '{split($0,a,"."); print a[3]}')
|
||||
|
||||
# 0.3.13 was the first version with a debian package
|
||||
if [[ "$major" -eq "0" ]] && [[ "$minor" -lt "4" ]] && [[ "$patch" -lt "13" ]]; then
|
||||
export DOKKU_CHECKOUT="$DOKKU_TAG"
|
||||
dokku_install_source
|
||||
else
|
||||
export DOKKU_CHECKOUT="$DOKKU_SEMVER"
|
||||
dokku_install_package
|
||||
fi
|
||||
else
|
||||
dokku_install_package
|
||||
fi
|
||||
|
||||
make install
|
||||
|
||||
echo
|
||||
echo "Almost done! For next steps on configuration:"
|
||||
echo " http://progrium.viewdocs.io/dokku/advanced-installation#user-content-configuring"
|
||||
|
||||
|
||||
14
circle.yml
14
circle.yml
@@ -5,19 +5,9 @@ dependencies:
|
||||
cache_directories:
|
||||
- "~/docker"
|
||||
override:
|
||||
# need to add the dokku user to the docker group
|
||||
- sudo -E CI=true make -e sshcommand
|
||||
- sudo usermod -G docker dokku
|
||||
- sudo -E CI=true DOCKER_VERSION=1.5.0 make -e install: { timeout: 300 }
|
||||
- make -e ci-dependencies
|
||||
#### circle does some weird *expletive* with regards to root and gh auth (needed for gitsubmodules test)
|
||||
- sudo rsync -a ~ubuntu/.ssh/ ~root/.ssh/
|
||||
- sudo chown -R root:root ~root/.ssh/
|
||||
- sudo sed -e 's:/home/ubuntu:/root:g' ~root/.ssh/config
|
||||
####
|
||||
- sudo -E make -e setup-deploy-tests
|
||||
- ./tests/ci/parallel_runner.sh setup: { timeout: 300 }
|
||||
post:
|
||||
- sudo -E make -e lint
|
||||
test:
|
||||
override:
|
||||
- ./tests/ci/parallel_runner.sh: { parallel: true, timeout: 1800 }
|
||||
- ./tests/ci/parallel_runner.sh testing: { parallel: true, timeout: 1800 }
|
||||
|
||||
@@ -21,7 +21,7 @@ if ARGV[0] == "onboot"
|
||||
exit
|
||||
end
|
||||
|
||||
version = "v0.3.17"
|
||||
version = "v0.3.20"
|
||||
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
|
||||
|
||||
@@ -102,6 +102,11 @@ if [[ ! -z $DOKKU_HOST ]]; then
|
||||
if [[ ! "$1" =~ --* ]]; then
|
||||
verb=$1
|
||||
shift
|
||||
|
||||
if [[ "$1" == "$appname" ]]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
args="$*"
|
||||
else
|
||||
long_args="--"
|
||||
@@ -119,7 +124,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
|
||||
ssh -t "dokku@$DOKKU_HOST" $long_args "$verb" "$appname" "${args[@]}"
|
||||
}
|
||||
|
||||
if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]]; then
|
||||
if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then
|
||||
_dokku "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
@@ -137,10 +137,10 @@ function install_prerequisites {
|
||||
sudo apt-get install -qq -y curl > /dev/null 2>&1
|
||||
|
||||
logit "Installing docker gpg key"
|
||||
curl --silent https://get.docker.com/gpg 2> /dev/null | apt-key add - > /dev/null 2>&1
|
||||
curl -sSL https://get.docker.com/gpg 2> /dev/null | apt-key add - > /dev/null 2>&1
|
||||
|
||||
logit "Installing dokku gpg key"
|
||||
curl --silent https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - > /dev/null 2>&1
|
||||
curl -sSL https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - > /dev/null 2>&1
|
||||
|
||||
logit "Running apt-get update"
|
||||
sudo apt-get update > /dev/null
|
||||
|
||||
7
deb.mk
7
deb.mk
@@ -31,10 +31,10 @@ GOPATH = /home/vagrant/gocode
|
||||
install-from-deb:
|
||||
echo "--> Initial apt-get update"
|
||||
sudo apt-get update > /dev/null
|
||||
sudo apt-get install -y apt-transport-https
|
||||
sudo apt-get install -y apt-transport-https curl
|
||||
|
||||
echo "--> Installing docker gpg key"
|
||||
curl --silent https://get.docker.com/gpg 2> /dev/null | apt-key add - 2>&1 >/dev/null
|
||||
curl -sSL https://get.docker.com/gpg | apt-key add -
|
||||
|
||||
echo "--> Installing dokku gpg key"
|
||||
curl --silent https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - 2>&1 >/dev/null
|
||||
@@ -61,7 +61,7 @@ deb-all: deb-buildstep deb-dokku deb-gems deb-pluginhook deb-sshcommand
|
||||
deb-setup:
|
||||
echo "-> Updating deb repository and installing build requirements"
|
||||
sudo apt-get update > /dev/null
|
||||
sudo apt-get install -qq -y git ruby1.9.1-dev 2>&1 > /dev/null
|
||||
sudo apt-get install -qq -y gcc git ruby1.9.1-dev 2>&1 > /dev/null
|
||||
command -v fpm > /dev/null || sudo gem install fpm --no-ri --no-rdoc
|
||||
ssh -o StrictHostKeyChecking=no git@github.com || true
|
||||
|
||||
@@ -138,6 +138,7 @@ deb-pluginhook: deb-setup
|
||||
|
||||
echo "-> Copying files into place"
|
||||
mkdir -p /tmp/build/usr/local/bin $(GOPATH)
|
||||
sudo apt-get update > /dev/null
|
||||
sudo apt-get install -qq -y git golang mercurial 2>&1 > /dev/null
|
||||
export PATH=$(PATH):$(GOROOT)/bin:$(GOPATH)/bin && export GOROOT=$(GOROOT) && export GOPATH=$(GOPATH) && go get "code.google.com/p/go.crypto/ssh/terminal"
|
||||
export PATH=$(PATH):$(GOROOT)/bin:$(GOPATH)/bin && export GOROOT=$(GOROOT) && export GOPATH=$(GOPATH) && cd /tmp/tmp/pluginhook && go build -o pluginhook
|
||||
|
||||
21
debian/config
vendored
Executable file
21
debian/config
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
readonly ACTION="${1:-configure}"
|
||||
readonly VERSION="${2:-dev}"
|
||||
|
||||
db_input "high" "dokku/web_config" || true
|
||||
db_go || true
|
||||
|
||||
db_get "dokku/web_config"
|
||||
if [ $RET = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
db_input "high" "dokku/hostname" || true
|
||||
db_input "high" "dokku/vhost_enable" || true
|
||||
if [ "$ACTION" != "reconfigure" ]; then
|
||||
db_input "high" "dokku/key_file" || true
|
||||
fi
|
||||
db_go || true
|
||||
2
debian/control
vendored
2
debian/control
vendored
@@ -3,7 +3,7 @@ Version: 0.3.12
|
||||
Section: base
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Depends: locales, git, make, curl, software-properties-common, lxc-docker (>= 1.4.0), gcc, python-software-properties, man-db, buildstep, sshcommand, pluginhook
|
||||
Depends: locales, git, make, curl, software-properties-common, lxc-docker-1.6.2, gcc, python-software-properties, man-db, buildstep, sshcommand, pluginhook
|
||||
Pre-Depends: nginx, dnsutils, ruby, ruby-dev, rubygem-rack, rubygem-rack-protection, rubygem-sinatra, rubygem-tilt, apparmor, cgroup-lite
|
||||
Provides: dokku
|
||||
Maintainer: Jose Diaz-Gonzalez <dokku@josediazgonzalez.com>
|
||||
|
||||
25
debian/postinst
vendored
25
debian/postinst
vendored
@@ -1,6 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}"
|
||||
|
||||
case "$1" in
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
@@ -19,6 +23,27 @@ case "$1" in
|
||||
if [ -f /etc/init/dokku-installer.conf ] && service dokku-installer status 2> /dev/null | grep waiting; then
|
||||
sudo service dokku-installer start
|
||||
fi
|
||||
|
||||
db_get "dokku/web_config"
|
||||
if [ "$RET" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
db_get "dokku/vhost_enable"
|
||||
if [ "$RET" = "true" ]; then
|
||||
db_get "dokku/hostname"
|
||||
echo "$RET" > "${DOKKU_ROOT}/VHOST"
|
||||
else
|
||||
rm -f "${DOKKU_ROOT}/VHOST"
|
||||
fi
|
||||
|
||||
db_get "dokku/hostname"
|
||||
echo "$RET" > "${DOKKU_ROOT}/HOSTNAME"
|
||||
|
||||
if [ -z "${DEBCONF_RECONFIGURE}" ]; then
|
||||
db_get "dokku/key_file"
|
||||
sshcommand acl-add dokku default < "$RET"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
53
debian/preinst
vendored
53
debian/preinst
vendored
@@ -1,28 +1,47 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
case "$1" in
|
||||
install)
|
||||
INIT_CONF="/etc/init/dokku-installer.conf"
|
||||
NGINX_CONF="/etc/nginx/conf.d/dokku-installer.conf"
|
||||
db_get "dokku/web_config"
|
||||
if [ "$RET" = "true" ]; then
|
||||
INIT_CONF="/etc/init/dokku-installer.conf"
|
||||
NGINX_CONF="/etc/nginx/conf.d/dokku-installer.conf"
|
||||
|
||||
rm -f $INIT_CONF
|
||||
touch $INIT_CONF
|
||||
echo 'start on runlevel [2345]' >> $INIT_CONF
|
||||
echo 'exec /usr/local/share/dokku/contrib/dokku-installer.rb selfdestruct' >> $INIT_CONF
|
||||
rm -f $INIT_CONF
|
||||
touch $INIT_CONF
|
||||
echo 'start on runlevel [2345]' >> $INIT_CONF
|
||||
echo 'exec /usr/local/share/dokku/contrib/dokku-installer.rb selfdestruct' >> $INIT_CONF
|
||||
|
||||
rm -f $NGINX_CONF
|
||||
touch $NGINX_CONF
|
||||
echo 'upstream dokku-installer { server 127.0.0.1:2000; }' >> $NGINX_CONF
|
||||
echo 'server {' >> $NGINX_CONF
|
||||
echo ' listen 80;' >> $NGINX_CONF
|
||||
echo ' location / {' >> $NGINX_CONF
|
||||
echo ' proxy_pass http://dokku-installer;' >> $NGINX_CONF
|
||||
echo ' }' >> $NGINX_CONF
|
||||
echo '}' >> $NGINX_CONF
|
||||
rm -f $NGINX_CONF
|
||||
touch $NGINX_CONF
|
||||
|
||||
rm -f /etc/nginx/sites-enabled/*
|
||||
service nginx reload
|
||||
{
|
||||
echo 'upstream dokku-installer { server 127.0.0.1:2000; }'
|
||||
echo 'server {'
|
||||
echo ' listen 80;'
|
||||
echo ' location / {'
|
||||
echo ' proxy_pass http://dokku-installer;'
|
||||
echo ' }'
|
||||
echo '}'
|
||||
} >> $NGINX_CONF
|
||||
|
||||
rm -f /etc/nginx/sites-enabled/*
|
||||
service nginx reload || /etc/init.d/nginx reload
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${DEBCONF_RECONFIGURE}" ]; then
|
||||
db_get "dokku/key_file"
|
||||
if [ ! -f "$RET" ]; then
|
||||
echo "Error: keyfile '$RET' not found."
|
||||
echo " you can enter a new keyfile path when you restart the installation."
|
||||
db_reset "dokku/key_file"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
upgrade)
|
||||
|
||||
19
debian/templates
vendored
Normal file
19
debian/templates
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Template: dokku/web_config
|
||||
Description: Use the web-based config page?
|
||||
Type: boolean
|
||||
Default: true
|
||||
|
||||
Template: dokku/vhost_enable
|
||||
Description: Use vhost based deployments?
|
||||
Type: boolean
|
||||
Default: false
|
||||
|
||||
Template: dokku/hostname
|
||||
Description: Machine's hostname or IP
|
||||
Type: string
|
||||
Default: dokku.me
|
||||
|
||||
Template: dokku/key_file
|
||||
Description: Keyfile for initial user
|
||||
Type: string
|
||||
Default: /root/.ssh/id_rsa.pub
|
||||
@@ -3,7 +3,7 @@
|
||||
You can always install dokku straight from the latest - potentially unstable - master release via the following bash command:
|
||||
|
||||
```shell
|
||||
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
|
||||
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo DOKKU_BRANCH=master bash
|
||||
```
|
||||
|
||||
## Development
|
||||
@@ -19,7 +19,7 @@ sudo make install
|
||||
The `Makefile` allows source URLs to be overridden to include customizations from your own repositories. The `DOCKER_URL`, `PLUGINHOOK_URL`, `SSHCOMMAND_URL` and `STACK_URL` environment variables may be set to override the defaults (see the `Makefile` for how these apply). Example:
|
||||
|
||||
```shell
|
||||
sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/gitreceive make install
|
||||
sudo SSHCOMMAND_URL=https://raw.github.com/yourusername/sshcommand/master/sshcommand make install
|
||||
```
|
||||
|
||||
## Bootstrap a server from your own repository
|
||||
@@ -29,7 +29,7 @@ The bootstrap script allows the dokku repository URL to be overridden to bootstr
|
||||
```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
|
||||
sudo DOKKU_REPO=https://github.com/yourusername/dokku.git DOKKU_BRANCH=master ./bootstrap.sh
|
||||
```
|
||||
|
||||
## Custom buildstep build
|
||||
|
||||
@@ -28,6 +28,14 @@ Dokku only supports deploying from its master branch, so if you'd like to deploy
|
||||
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.
|
||||
|
||||
## Deploying to server over SSH
|
||||
|
||||
Pushing to the dokku remote may prompt you to input a password for the dokku user. It's preferable, however, to use key-based authentication, and you can add your public key to the dokku user's authorized_keys file with:
|
||||
|
||||
```
|
||||
cat ~/.ssh/id_rsa.pub | ssh [sudouser]@[yourdomain].com "sudo sshcommand acl-add dokku [description]"
|
||||
```
|
||||
|
||||
## Deploying with private git submodules
|
||||
|
||||
Dokku uses git locally (i.e. not a docker image) to build its own copy of your app repo, including submodules. This is done as the `dokku` user. Therefore, in order to deploy private git submodules, you'll need to drop your deploy key in `~dokku/.ssh` and potentially add github.com (or your VCS host key) into `~dokku/.ssh/known_hosts`. A decent test like this should help confirm you've done it correctly.
|
||||
@@ -42,6 +50,14 @@ ssh -T git@github.com
|
||||
|
||||
If buildpack detection isn't working well for you or you want to specify a custom buildpack for one repository you can create & commit a file in the root of your git repository named `.env` containing `export BUILDPACK_URL=<repository>` before pushing. This will tell buildstep to fetch the specified buildpack and use it instead of relying on the built-in buildpacks & their detection methods.
|
||||
|
||||
## Dockerfile deployment
|
||||
|
||||
Deployment of `Dockerfile` repos is supported as of v0.3.15. Simply place a Dockerfile in the root of your repo and push to dokku. If you are converting from a heroku/dokku buildpack deployment, ensure you are not setting `$BUILDPACK_URL` or including a `.buildpacks` file in the root of your repo.
|
||||
|
||||
By default, we will extract the first `EXPOSE` port and tell nginx to proxy your app to that port. Alternatively, you can set `$DOCKERFILE_PORT` in your app's dokku configuration.
|
||||
|
||||
Setting `$DOKKU_DOCKERFILE_CACHE_BUILD` to `true` or `false` will enable or disable docker's image layer cache. Lastly, for more granular build control, you may also pass any `docker build` option to `docker`, by setting `$DOKKU_DOCKER_BUILD_OPTS`.
|
||||
|
||||
## Default vhost
|
||||
|
||||
You might notice the default vhost for Nginx will be one of the apps. If an app doesn't exist, it will use this vhost and it may be confusing for it to go to another app. You can create a default vhost using a configuration under `sites-enabled`. You just have to change one thing in the main nginx.conf:
|
||||
|
||||
@@ -20,7 +20,7 @@ that include the hostname, for example:
|
||||
You can also specify the protocol to explicitly check HTTPS requests.
|
||||
|
||||
The default behavior is to wait for 5 seconds before running the first check,
|
||||
and timeout each check to 30 minutes.
|
||||
and timeout each check to 30 seconds.
|
||||
|
||||
By default, checks will be attempted 5 times. (Retried 4 times)
|
||||
|
||||
|
||||
@@ -11,6 +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 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.
|
||||
The variables are available both 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 and sourced before app-specific variables. This means that app-specific variables will take precedence over global variables. Configuring your global `ENV` file is manual, and should be considered potentially dangerous as configuration applies to all applications.
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
If you create your own plugin:
|
||||
|
||||
1. Take a look at the plugins shipped with dokku and hack away!
|
||||
2. Upload your plugin to github with a repository name in form of `dokku-<name>` (e.g. `dokku-mariadb`)
|
||||
3. Edit [this page](http://progrium.viewdocs.io/dokku/plugins) and add a link to it.
|
||||
4. Subscribe to the [dokku development blog](http://progrium.com) to be notified about API changes and releases
|
||||
2. Check out the [list of hooks](http://progrium.viewdocs.io/dokku/development/pluginhooks) your plugin can implement.
|
||||
3. Upload your plugin to github with a repository name in form of `dokku-<name>` (e.g. `dokku-mariadb`)
|
||||
4. Edit [this page](http://progrium.viewdocs.io/dokku/plugins) and add a link to it.
|
||||
5. Subscribe to the [dokku development blog](http://progrium.com) to be notified about API changes and releases
|
||||
|
||||
### Sample plugin
|
||||
|
||||
|
||||
@@ -14,45 +14,53 @@ $ dokku help
|
||||
...
|
||||
````
|
||||
|
||||
Add some options
|
||||
Add some options (first, for the deployed/running app and second when executing `dokku run`)
|
||||
|
||||
```bash
|
||||
$ dokku docker-options:add myapp deploy "-v /host/path:/container/path"
|
||||
$ dokku docker-options:add myapp run "-v /another/container/path"
|
||||
$ dokku docker-options:add myapp "-link container_name:alias"
|
||||
```
|
||||
|
||||
Check what we added
|
||||
|
||||
```bash
|
||||
$ dokku docker-options myapp
|
||||
-link container_name:alias
|
||||
-v /host/path:/container/path
|
||||
-v /another/container/path
|
||||
Deploy options:
|
||||
-v /host/path:/container/path
|
||||
Run options:
|
||||
-v /another/container/path
|
||||
```
|
||||
|
||||
Remove an option
|
||||
```bash
|
||||
$ dokku docker-options:remove myapp "-link container_name:alias"
|
||||
$ dokku docker-options:remove myapp run "--link container_name:alias"
|
||||
```
|
||||
|
||||
Note about `dokku` phases and `docker-options`
|
||||
------------
|
||||
`dokku` deploys your application in multiple "phases" and the `docker-options` plugin allows you to pass arguments to the underlying docker container in the following 3 phases/containers
|
||||
- `build`: the container that executes the appropriate buildpack
|
||||
- `deploy`: the container that executes your running/deployed application
|
||||
- `run`: the container that executes any arbitrary command via `dokku run myapp`
|
||||
|
||||
|
||||
Advanced Usage (avoid if possible)
|
||||
------------
|
||||
|
||||
In your applications folder (/home/dokku/app_name) create a file called DOCKER_OPTIONS.
|
||||
In your applications folder (`/home/dokku/app_name`) create a file called `DOCKER_OPTIONS_RUN` (or `DOCKER_OPTIONS_BUILD` or `DOCKER_OPTIONS_DEPLOY`).
|
||||
|
||||
Inside this file list one docker option per line. For example:
|
||||
|
||||
```bash
|
||||
-link container_name:alias
|
||||
--link container_name:alias
|
||||
-v /host/path:/container/path
|
||||
-v /another/container/path
|
||||
```
|
||||
|
||||
The above example will result in the following options being passed to docker during deploy and docker run:
|
||||
The above example will result in the following options being passed to docker during `dokku run`:
|
||||
|
||||
```bash
|
||||
-link container_name:alias -v /host/path:/container/path -v /another/container/path
|
||||
--link container_name:alias -v /host/path:/container/path -v /another/container/path
|
||||
```
|
||||
|
||||
You may also include comments (lines beginning with a #) and blank lines in the DOCKER_OPTIONS file.
|
||||
|
||||
36
docs/getting-started/install/debian.md
Normal file
36
docs/getting-started/install/debian.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Debian Package Installation Notes
|
||||
|
||||
As of 0.3.18, dokku defaults to being installed via debian package. While certain hosts may require extra work to get running, you may optionally wish to automate the installation of dokku without the use of our `bootstrap.sh` bash script. The following are the steps run by said script:
|
||||
|
||||
```shell
|
||||
curl --silent https://get.docker.io/gpg 2> /dev/null | apt-key add - 2>&1 >/dev/null
|
||||
curl --silent https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - 2>&1 >/dev/null
|
||||
|
||||
echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
|
||||
echo "deb https://packagecloud.io/dokku/dokku/ubuntu/ trusty main" > /etc/apt/sources.list.d/dokku.list
|
||||
|
||||
sudo apt-get update > /dev/null
|
||||
sudo apt-get install -qq -y linux-image-extra-`uname -r` apt-transport-https
|
||||
sudo apt-get install -qq -y dokku
|
||||
```
|
||||
|
||||
## Unattended installation
|
||||
|
||||
In case you want to perform an unattended installation of dokku, this is made possible through [debconf](https://en.wikipedia.org/wiki/Debconf_%28software_package%29), which allows you to configure a package before installing it.
|
||||
|
||||
You can set any of the below options through the `debconf-set-selections` command, for example to enable vhost-based deployments:
|
||||
|
||||
```bash
|
||||
echo "dokku dokku/vhost_enable boolean true" | debconf-set-selections
|
||||
```
|
||||
|
||||
After setting the desired options, proceed with the installation as described above.
|
||||
|
||||
### debconf options
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| ------------------ | ------- | --------------------- | ------------------------------------------------------------------------ |
|
||||
| dokku/web_config | boolean | true | Use web-based config for below options |
|
||||
| dokku/vhost_enable | boolean | false | Use vhost-based deployments (e.g. <app>.dokku.me) |
|
||||
| dokku/hostname | string | dokku.me | Hostname, used as vhost domain and for showing app URL after deploy |
|
||||
| dokku/key_file | string | /root/.ssh/id_rsa.pub | SSH key to add to the Dokku user (Will be ignored on `dpkg-reconfigure`) |
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
```
|
||||
Host dokku.me
|
||||
Port 2222
|
||||
Port 22
|
||||
```
|
||||
|
||||
- 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.
|
||||
|
||||
@@ -11,13 +11,9 @@ 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:
|
||||
|
||||
```shell
|
||||
# This may need to be run twice
|
||||
wget -qO- https://raw.github.com/progrium/dokku/v0.3.17/bootstrap.sh | sudo DOKKU_TAG=v0.3.17 bash
|
||||
|
||||
# Install the web installer. See `Configuring` under
|
||||
# `Advanced Install Customization` if you wish to perform the
|
||||
# rest of the install via CLI
|
||||
cd /root/dokku && make dokku-installer
|
||||
# installs dokku via apt-get
|
||||
wget https://raw.github.com/progrium/dokku/v0.3.20/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.3.20 bash bootstrap.sh
|
||||
|
||||
# Go to your server's IP and follow the web installer
|
||||
```
|
||||
@@ -29,5 +25,6 @@ For various reasons, certain hosting providers may have other steps that should
|
||||
|
||||
As well, you may wish to customize your installation in some other fashion. or experiment with vagrant. The guides below should get you started:
|
||||
|
||||
- [Debian Package Installation Notes](http://progrium.viewdocs.io/dokku/getting-started/install/debian)
|
||||
- [Vagrant Installation Notes](http://progrium.viewdocs.io/dokku/getting-started/install/vagrant)
|
||||
- [Advanced Install Customization](http://progrium.viewdocs.io/dokku/advanced-installation)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Nginx
|
||||
|
||||
Dokku uses nginx as it's server for routing requests to specific applications.
|
||||
Dokku uses nginx as it's server for routing requests to specific applications. By default, access and error logs are written for each app to `/var/log/nginx/${APP}-access.log` and `/var/log/nginx/${APP}-error.log` respectively
|
||||
|
||||
## TLS/SPDY support
|
||||
|
||||
@@ -8,9 +8,18 @@ Dokku provides easy TLS/SPDY support out of the box. This can be done app-by-app
|
||||
|
||||
### Per App
|
||||
|
||||
To enable TLS connection to to one of your applications, copy or symlink the `.crt` and `.key` files into the application's `/home/dokku/:app/tls` folder (create this folder if it doesn't exist) as `server.crt` and `server.key` respectively.
|
||||
To enable TLS connections to to one of your applications, do the following:
|
||||
|
||||
* Create a key file and a cert file.
|
||||
* You can find detailed steps for generating a self-signed certificate at https://devcenter.heroku.com/articles/ssl-certificate-self
|
||||
* If you are not paranoid and need it just for a DEV or STAGING app, you can use http://www.selfsignedcertificate.com/ to generate your 2 files more easily.
|
||||
* Rename your files to server.key and server.crt
|
||||
* tar these 2 files together, *without* subdirectories. Example: tar cvf cert-key.tar server.crt server.key
|
||||
* Install the pair for your app, like this: ssh dokku@ip-of-your-dokku-server nginx:import-ssl < cert-key.tar
|
||||
|
||||
You will need to repeat the steps above for each domain used to serve your app. You can't simply create
|
||||
a single tar with all key/cert files in it (see https://github.com/progrium/dokku/issues/1195).
|
||||
|
||||
Redeployment of the application will be needed to apply TLS configuration. Once it is redeployed, the application will be accessible by `https://` (redirection from `http://` is applied as well).
|
||||
|
||||
### All Subdomains
|
||||
|
||||
@@ -56,6 +65,8 @@ server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
server_name $NOSSL_SERVER_NAME;
|
||||
access_log /var/log/nginx/${APP}-access.log;
|
||||
error_log /var/log/nginx/${APP}-error.log;
|
||||
|
||||
# set a custom header for requests
|
||||
add_header X-Served-By www-ec2-01;
|
||||
@@ -77,6 +88,12 @@ server {
|
||||
|
||||
The above is a sample http configuration that adds an `X-Served-By` header to requests. The template file **must** be owned by the user `dokku:dokku`.
|
||||
|
||||
A few tips for custom nginx templates:
|
||||
|
||||
- Special characters - dollar signs, spaces inside of quotes, etc. - should be escaped with a single backslash or can cause deploy failures.
|
||||
- Templated files will be validated via `nginx -t`.
|
||||
- Application environment variables can be used within your nginx configuration.
|
||||
|
||||
## Customizing hostnames
|
||||
|
||||
Applications typically have the following structure for their hostname:
|
||||
@@ -161,7 +178,7 @@ d6499edb0edb dokku/node-js-app:latest "/bin/bash -c '/star About a mi
|
||||
|
||||
# Default site
|
||||
|
||||
By default, dokku will route any received request with an unknown HOST header value to the lexicographically first site in the nginx config stack. If this is not the desired behavior, you may want to add the following configuration to nginx. This will catch all unknown HOST header values and return a `410 Gone` response.
|
||||
By default, dokku will route any received request with an unknown HOST header value to the lexicographically first site in the nginx config stack. If this is not the desired behavior, you may want to add the following configuration to nginx. This will catch all unknown HOST header values and return a `410 Gone` response. You can replace the `return 410;` with `return 444;` which will cause nginx to not respond to requests that do not match known domains (connection refused).
|
||||
|
||||
```
|
||||
server {
|
||||
|
||||
@@ -29,6 +29,7 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
|
||||
[agco-adm]: https://github.com/agco-adm
|
||||
[ademuk]: https://github.com/ademuk
|
||||
[alessio]: https://github.com/alessio
|
||||
[alex-sherwin]: https://github.com/alex-sherwin
|
||||
[alexanderbeletsky]: https://github.com/alexanderbeletsky
|
||||
[Aomitayo]: https://github.com/Aomitayo
|
||||
@@ -37,6 +38,7 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
[cameron-martin]: https://github.com/cameron-martin
|
||||
[cedricziel]: https://github.com/cedricziel
|
||||
[cef]: https://github.com/cef
|
||||
[cjblomqvist]: https://github.com/cjblomqvist
|
||||
[darkpixel]: https://github.com/darkpixel
|
||||
[dyson]: https://github.com/dyson
|
||||
[F4-Group]: https://github.com/F4-Group
|
||||
@@ -79,6 +81,7 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
[Flink]: https://github.com/Flink
|
||||
[ribot]: https://github.com/ribot
|
||||
[Benjamin-Dobell]: https://github.com/Benjamin-Dobell
|
||||
[jagandecapri]: https://github.com/jagandecapri
|
||||
|
||||
### Datastores
|
||||
|
||||
@@ -140,6 +143,7 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
| [Supervisord](https://github.com/statianzo/dokku-supervisord) | [statianzo][] | Compatible with 0.2.0 |
|
||||
| [Logging Supervisord](https://github.com/sehrope/dokku-logging-supervisord) | [sehrope][] | Works with dokku @ [c77cbf1][] - no 0.2.0 compatibility |
|
||||
| [Forego](https://github.com/iskandar/dokku-forego) | [iskandar][] | Compatible with 0.2.x |
|
||||
| [Monit](https://github.com/cjblomqvist/dokku-monit) | [cjblomqvist][] | |
|
||||
|
||||
[c77cbf1]: https://github.com/progrium/dokku/commit/c77cbf1d3ae07f0eafb85082ed7edcae9e836147
|
||||
[28de3ec]: https://github.com/progrium/dokku/commit/28de3ecaa3231a223f83fd8d03f373308673bc40
|
||||
@@ -152,7 +156,8 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
| [Docker Direct](https://github.com/heichblatt/dokku-docker-direct) | [heichblatt][] | |
|
||||
| [Dokku Name](https://github.com/alex-sherwin/dokku-name) | [alex-sherwin][] | dokku >= [c77cbf1][] |
|
||||
| [Dokku Registry](https://github.com/agco-adm/dokku-registry)<sup>1</sup> | [agco-adm][] | |
|
||||
| [git rev-parse HEAD in env](https://github.com/nornagon/dokku-git-rev) | [nornagon][] | Compatible with 0.2.0 |
|
||||
| [Events Logger](https://github.com/alessio/dokku-events) | [alessio][] | dokku >= v0.3.13 |
|
||||
| [git rev-parse HEAD in env](https://github.com/cjblomqvist/dokku-git-rev) | [cjblomqvist][] | Compatible with 0.3.0 |
|
||||
| [Graduate (Environment Management)](https://github.com/glassechidna/dokku-graduate) | [Benjamin-Dobell][] | dokku >= v0.3.14 |
|
||||
| [HTTP Auth Secure Apps](https://github.com/matto1990/dokku-secure-apps) | [matto1990][] | Works with v0.2.3 |
|
||||
| [Host Port binding](https://github.com/stuartpb/dokku-bind-port) | [stuartpb][] | dokku >= [c77cbf1][]. 2014-02-17: [a043e98][] targeting dokku @ [latest][217d00a] |
|
||||
@@ -192,6 +197,7 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
| [Bower install](https://github.com/alexanderbeletsky/dokku-bower-install) | [alexanderbeletsky][] | |
|
||||
| [Bower/Grunt](https://github.com/thrashr888/dokku-bower-grunt-build-plugin) | [thrashr888][] | |
|
||||
| [Bower/Gulp](https://github.com/gdi2290/dokku-bower-gulp-build-plugin) | [gdi2290][] | |
|
||||
| [Bower/Gulp](https://github.com/jagandecapri/dokku-bower-gulp-build-plugin) | [jagandecapri][] | |
|
||||
| [HipChat Notifications](https://github.com/cef/dokku-hipchat) | [cef][] | |
|
||||
| [Slack Notifications](https://github.com/ribot/dokku-slack) | [ribot][] | |
|
||||
| [Graphite/statsd](https://github.com/jlachowski/dokku-graphite-plugin) | [jlachowski][] | |
|
||||
@@ -201,6 +207,7 @@ Note: The following plugins have been supplied by our community and may not have
|
||||
| [Webhooks](https://github.com/nickstenning/dokku-webhooks) | [nickstenning][] | |
|
||||
| [Rails logs](https://github.com/Flink/dokku-rails-logs) | [Flink][] | |
|
||||
| [Airbrake deploy](https://github.com/Flink/dokku-airbrake-deploy) | [Flink][] | |
|
||||
| [Logspout](https://github.com/michaelshobbs/dokku-logspout) | [michaelshobbs][] | |
|
||||
|
||||
<sup>1</sup> Forked from [jezdez/dokku-elasticsearch-plugin](https://github.com/jezdez/dokku-elasticsearch-plugin): uses Elasticsearch 1.2 (instead of 0.90), doesn't depend on dokku-link, runs as elasticsearch user instead of root, and turns off multicast autodiscovery for use in a VPS environment.
|
||||
|
||||
|
||||
@@ -4,10 +4,38 @@ Dokku supports rudimentary process (really container) management via the `ps` pl
|
||||
|
||||
```
|
||||
ps <app> List processes running in app container(s)
|
||||
ps:rebuildall Rebuild all apps
|
||||
ps:rebuild <app> Rebuild an app
|
||||
ps:restartall Restart all deployed app containers
|
||||
ps:restart <app> Restart app container(s)
|
||||
ps:scale <app> <proc>=<count> [<proc>=<count>] Set how many processes of a given process to run
|
||||
ps:start <app> Start app container(s)
|
||||
ps:stop <app> Stop app container(s)
|
||||
ps:restart <app> Restart app container(s)
|
||||
ps:restartall Restart all deployed app containers
|
||||
```
|
||||
|
||||
*NOTE*: As of v0.3.14, `dokku deploy:all` in now deprecated by `ps:restartall` and will be removed in a future version.
|
||||
|
||||
|
||||
## Scaling
|
||||
|
||||
Dokku allows you to run multiple process types at different container counts. For example, if you had an app that contained 1 web app listener and 1 background job processor, dokku can, spin up 1 container for each process type defined in the Procfile. By default we will only start the web process. However, if you wanted 2 job processors running simultaneously, you can modify this behavior in a few ways.
|
||||
|
||||
## Include a DOKKU_SCALE file in your repo
|
||||
|
||||
Dokku expects this file to contain one line for every process defined in your Procfile. Example:
|
||||
```
|
||||
web=1
|
||||
worker=2
|
||||
```
|
||||
|
||||
|
||||
## Use the ps:scale command. Example:
|
||||
```
|
||||
dokku ps:scale app_name web=1 worker=2
|
||||
```
|
||||
*NOTE*: Dokku will always use the DOKKU_SCALE file that ships with the repo to override any local settings.
|
||||
|
||||
|
||||
## The web proctype
|
||||
|
||||
Like Heroku, we handle the `web` proctype differently from others. The `web` proctype is the only proctype that will invoke custom checks as defined by a CHECKS file. It is also the only proctype that will be launched in a container that is either proxied via nginx or bound to an external port.
|
||||
|
||||
@@ -141,3 +141,31 @@ When specifying your port you may want to use something similar to:
|
||||
|
||||
Please see https://github.com/progrium/dokku/issues/282
|
||||
|
||||
***
|
||||
|
||||
__Symptom:__ Deployment fails because of slow internet connection, messages shows `gzip: stdin: unexpected end of file`
|
||||
|
||||
__Solution:__
|
||||
|
||||
If you see output similar this when deploying:
|
||||
|
||||
```
|
||||
Command: 'set -o pipefail; curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/ruby-2.0.0-p451-default-cache.tgz -s -o - | tar zxf -' failed unexpectedly:
|
||||
!
|
||||
! gzip: stdin: unexpected end of file
|
||||
! tar: Unexpected EOF in archive
|
||||
! tar: Unexpected EOF in archive
|
||||
! tar: Error is not recoverable: exiting now
|
||||
```
|
||||
|
||||
it might that the curl command that is supposed to fetch the buildpack (anything in the low megabyte file size range) takes too long to finish, due to slowish connection. To overwrite the default values (connection timeout: 3 seconds, total maximum time for operation: 30 seconds), edit `/home/dokku/ENV` like the following:
|
||||
|
||||
```
|
||||
#/home/dokku/ENV
|
||||
export CURL_TIMEOUT=600
|
||||
export CURL_CONNECT_TIMEOUT=30
|
||||
```
|
||||
|
||||
References
|
||||
* https://github.com/progrium/dokku/issues/509
|
||||
* https://github.com/dokku-alt/dokku-alt/issues/169
|
||||
|
||||
@@ -1,73 +1,62 @@
|
||||
# Upgrading
|
||||
|
||||
Dokku is in active development. You can update the deployment step and the build step separately.
|
||||
This document covers upgrades for the 0.3.0 series and up. If upgrading from previous versions, we recommend [a fresh install](http://progrium.viewdocs.io/dokku/installation) on a new server.
|
||||
|
||||
**Note**: If you are upgrading from a revision prior to [27d4bc8c3c](https://github.com/progrium/dokku/commit/27d4bc8c3c19fe580ef3e65f2f85b85101cd83e4), follow the instructions in [this wiki entry](https://github.com/progrium/dokku/wiki/Migrating-to-Dokku-0.2.0).
|
||||
> As of 0.3.18, dokku is installed by default via a debian package. Source-based installations are still available, though not recommended.
|
||||
|
||||
To update the deploy step (this is updated less frequently):
|
||||
## Dokku
|
||||
|
||||
If dokku was installed via a debian package, you can upgrade dokku via the following command:
|
||||
|
||||
```shell
|
||||
sudo apt-get install dokku
|
||||
```
|
||||
|
||||
For unattended upgrades, you may run the following command:
|
||||
|
||||
```shell
|
||||
sudo apt-get install -qq -y dokku
|
||||
```
|
||||
|
||||
If you have installed dokku from source, you may run the following commands to upgrade:
|
||||
|
||||
```shell
|
||||
cd ~/dokku
|
||||
git pull --tags origin master
|
||||
|
||||
# continue to install from source
|
||||
sudo DOKKU_BRANCH=master make install
|
||||
|
||||
# upgrade to debian package-based installation
|
||||
sudo make install
|
||||
```
|
||||
|
||||
Nothing needs to be restarted. Changes will take effect on the next push / deployment.
|
||||
|
||||
To update the build step:
|
||||
All changes will take effect upon next application deployment. To trigger a rebuild of every application, simply run the following command:
|
||||
|
||||
```shell
|
||||
dokku ps:rebuildall
|
||||
```
|
||||
|
||||
## Buildstep image
|
||||
|
||||
If dokku was installed via a debian package, you can upgrade buildstep via the following command:
|
||||
|
||||
```shell
|
||||
sudo apt-get install buildstep
|
||||
```
|
||||
|
||||
For unattended upgrades, you may run the following command:
|
||||
|
||||
```shell
|
||||
sudo apt-get install -qq -y buildstep
|
||||
```
|
||||
|
||||
In some cases, it may be desirable to run a specific version of buildstep. To install/upgrade buildstep from source, run the following commands:
|
||||
|
||||
```shell
|
||||
cd /tmp
|
||||
git clone https://github.com/progrium/buildstep.git
|
||||
cd buildstep
|
||||
git pull origin master
|
||||
sudo make build
|
||||
```
|
||||
|
||||
This will build a fresh Ubuntu Quantal image, install a number of packages, and
|
||||
eventually replace the Docker image for buildstep.
|
||||
|
||||
## Migrating from 0.1.0 to 0.2.0
|
||||
|
||||
This should be summary of breaking changes between 0.1 and 0.2 version with instructions to upgrade.
|
||||
|
||||
### software-properties-common
|
||||
|
||||
software-properties-common is now a dependency for plugins. Before running dokku install script, make sure it is installed.
|
||||
|
||||
```shell
|
||||
> sudo apt-get install software-properties-common
|
||||
```
|
||||
|
||||
### Gitreceive removed
|
||||
|
||||
PR [#270](https://github.com/progrium/dokku/pull/270).
|
||||
|
||||
Starting with Dokku 0.2.0, [Gitrecieve](https://github.com/progrium/gitreceive) is replaced by a `git` plugin.
|
||||
|
||||
Dokku no longer uses the `git` user. Everything is done with the `dokku` user account.
|
||||
|
||||
This causes the remote url to change. Instead of pushing to `git@hostname:app`, you should now push to `dokku@hostname:app`.
|
||||
The url must be modified using the `git remote set-url` command :
|
||||
|
||||
git remote set-url deploy dokku@hostname:app
|
||||
|
||||
Where `deploy` is the name of the remote.
|
||||
|
||||
Additionally, the repositiories on the server must be migrated to work with dokku 0.2.0
|
||||
|
||||
There is an upgrade [script](https://gist.github.com/plietar/7201430), which is meant to automate this migration. To use it:
|
||||
|
||||
1. run the script as root
|
||||
2. `git pull` to get the latest version of dokku
|
||||
3. make install
|
||||
4. `dokku ps:restartall`
|
||||
|
||||
TDB.
|
||||
|
||||
### Cache directory
|
||||
|
||||
Commit [#6350f373](https://github.com/progrium/dokku/commit/6350f373be2cef4f3bb90912099e1be6196522d1)
|
||||
|
||||
Buildstep have to be re-installed in order to support cache directory.
|
||||
|
||||
TDB.
|
||||
|
||||
119
dokku
119
dokku
@@ -37,7 +37,7 @@ fi
|
||||
|
||||
if [[ -n "$SSH_ORIGINAL_COMMAND" ]]; then
|
||||
export -n SSH_ORIGINAL_COMMAND
|
||||
if [[ $1 =~ config-* ]];then
|
||||
if [[ $1 =~ config-* ]] || [[ $1 =~ docker-options* ]];then
|
||||
xargs $0 <<<$SSH_ORIGINAL_COMMAND
|
||||
exit $?
|
||||
else
|
||||
@@ -66,67 +66,102 @@ case "$1" in
|
||||
APP="$2"; IMAGE="dokku/$APP"
|
||||
pluginhook pre-deploy $APP
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
|
||||
oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||
fi
|
||||
|
||||
# start the app
|
||||
DOCKER_ARGS=$(: | pluginhook docker-args $APP deploy)
|
||||
DOCKER_ARGS+=$(: | pluginhook docker-args-deploy $APP)
|
||||
BIND_EXTERNAL=$(pluginhook bind-external-ip $APP)
|
||||
|
||||
is_image_buildstep_based "$IMAGE" && DOKKU_BUILDSTEP=true
|
||||
[[ -n "$DOKKU_BUILDSTEP" ]] && START_CMD="/start web"
|
||||
[[ -z "$DOKKU_BUILDSTEP" ]] && DOKKU_DOCKERFILE_PORT=$(dokku config:get $APP DOKKU_DOCKERFILE_PORT || true)
|
||||
DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
oldids=$(get_container_ids $APP)
|
||||
|
||||
if [[ "$BIND_EXTERNAL" = "false" ]];then
|
||||
port=${DOKKU_DOCKERFILE_PORT:=5000}
|
||||
id=$(docker run -d -e PORT=$port $DOCKER_ARGS $IMAGE $START_CMD)
|
||||
ipaddr=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $id)
|
||||
else
|
||||
id=$(docker run -d -p 5000 -e PORT=5000 $DOCKER_ARGS $IMAGE $START_CMD)
|
||||
port=$(docker port $id 5000 | sed 's/[0-9.]*://')
|
||||
ipaddr=127.0.0.1
|
||||
fi
|
||||
while read line || [ -n "$line" ]
|
||||
do
|
||||
PROC_TYPE=${line%%=*}
|
||||
PROC_COUNT=${line#*=}
|
||||
CONTAINER_INDEX=1
|
||||
|
||||
# if we can't post-deploy successfully, kill new container
|
||||
kill_new() {
|
||||
docker inspect $id &> /dev/null && docker kill $id > /dev/null
|
||||
trap - INT TERM EXIT
|
||||
kill -9 $$
|
||||
}
|
||||
while [[ $CONTAINER_INDEX -le $PROC_COUNT ]];do
|
||||
id=""; port=""; ipaddr=""
|
||||
DOKKU_CONTAINER_ID_FILE="$DOKKU_ROOT/$APP/CONTAINER.$PROC_TYPE.$CONTAINER_INDEX"
|
||||
DOKKU_IP_FILE="$DOKKU_ROOT/$APP/IP.$PROC_TYPE.$CONTAINER_INDEX"
|
||||
DOKKU_PORT_FILE="$DOKKU_ROOT/$APP/PORT.$PROC_TYPE.$CONTAINER_INDEX"
|
||||
|
||||
# run checks first, then post-deploy hooks, which switches Nginx traffic
|
||||
trap kill_new INT TERM EXIT
|
||||
dokku_log_info1 "Running pre-flight checks"
|
||||
pluginhook check-deploy $APP $port $ipaddr $id
|
||||
trap - INT TERM EXIT
|
||||
# start the app
|
||||
DOCKER_ARGS=$(: | pluginhook docker-args $APP deploy)
|
||||
DOCKER_ARGS+=" -e DYNO=$PROC_TYPE "
|
||||
DOCKER_ARGS+=$(: | pluginhook docker-args-deploy $APP)
|
||||
BIND_EXTERNAL=$(pluginhook bind-external-ip $APP)
|
||||
|
||||
# now using the new container
|
||||
echo $id > "$DOKKU_ROOT/$APP/CONTAINER"
|
||||
echo $ipaddr > "$DOKKU_ROOT/$APP/IP"
|
||||
echo $port > "$DOKKU_ROOT/$APP/PORT"
|
||||
echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL"
|
||||
[[ -n "$DOKKU_BUILDSTEP" ]] && START_CMD="/start $PROC_TYPE"
|
||||
[[ -z "$DOKKU_BUILDSTEP" ]] && DOKKU_DOCKERFILE_PORT=$(dokku config:get $APP DOKKU_DOCKERFILE_PORT || true)
|
||||
|
||||
if [[ "$BIND_EXTERNAL" = "false" ]] && [[ "$PROC_TYPE" == "web" ]];then
|
||||
port=${DOKKU_DOCKERFILE_PORT:=5000}
|
||||
id=$(docker run -d -e PORT=$port $DOCKER_ARGS $IMAGE $START_CMD)
|
||||
ipaddr=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $id)
|
||||
elif [[ "$BIND_EXTERNAL" = "true" ]] && [[ "$PROC_TYPE" == "web" ]];then
|
||||
id=$(docker run -d -p 5000 -e PORT=5000 $DOCKER_ARGS $IMAGE $START_CMD)
|
||||
port=$(docker port $id 5000 | sed 's/[0-9.]*://')
|
||||
ipaddr=127.0.0.1
|
||||
elif [[ "$PROC_TYPE" != "web" ]];then
|
||||
id=$(docker run -d $DOCKER_ARGS $IMAGE $START_CMD)
|
||||
fi
|
||||
|
||||
# if we can't post-deploy successfully, kill new container
|
||||
kill_new() {
|
||||
docker inspect $id &> /dev/null && docker stop $id > /dev/null && docker kill $id > /dev/null
|
||||
trap - INT TERM EXIT
|
||||
kill -9 $$
|
||||
}
|
||||
|
||||
# run checks first, then post-deploy hooks, which switches Nginx traffic
|
||||
trap kill_new INT TERM EXIT
|
||||
dokku_log_info1 "Running pre-flight checks"
|
||||
pluginhook check-deploy $APP $id $PROC_TYPE $port $ipaddr
|
||||
trap - INT TERM EXIT
|
||||
|
||||
# now using the new container
|
||||
[[ -n "$id" ]] && echo $id > "$DOKKU_CONTAINER_ID_FILE"
|
||||
[[ -n "$ipaddr" ]] && echo $ipaddr > "$DOKKU_IP_FILE"
|
||||
[[ -n "$port" ]] && echo $port > "$DOKKU_PORT_FILE"
|
||||
[[ -n "$port" ]] && echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL"
|
||||
|
||||
# cleanup pre-migration files
|
||||
rm -f $DOKKU_ROOT/$APP/CONTAINER $DOKKU_ROOT/$APP/IP $DOKKU_ROOT/$APP/PORT
|
||||
|
||||
CONTAINER_INDEX=$(( CONTAINER_INDEX + 1 ))
|
||||
done
|
||||
# cleanup when we scale down
|
||||
if [[ "$PROC_COUNT" == 0 ]]; then
|
||||
CONTAINER_IDX_OFFSET=0
|
||||
else
|
||||
CONTAINER_IDX_OFFSET=$((PROC_COUNT + 1))
|
||||
fi
|
||||
find $DOKKU_ROOT/$APP -maxdepth 1 -name "CONTAINER.$PROC_TYPE.*" | sort -t . -k 4 -n | tail -n +$CONTAINER_IDX_OFFSET | xargs rm -f
|
||||
find $DOKKU_ROOT/$APP -maxdepth 1 -name "IP.$PROC_TYPE.*" | sort -t . -k 4 -n | tail -n +$CONTAINER_IDX_OFFSET | xargs rm -f
|
||||
find $DOKKU_ROOT/$APP -maxdepth 1 -name "PORT.$PROC_TYPE.*" | sort -t . -k 4 -n | tail -n +$CONTAINER_IDX_OFFSET | xargs rm -f
|
||||
done < "$DOKKU_SCALE_FILE"
|
||||
|
||||
dokku_log_info1 "Running post-deploy"
|
||||
pluginhook post-deploy $APP $port $ipaddr
|
||||
pluginhook post-deploy $APP $port $ipaddr
|
||||
|
||||
# kill the old container
|
||||
if [[ -n "$oldid" ]]; then
|
||||
if [[ -n "$oldids" ]]; then
|
||||
# Let the old container finish processing requests, before terminating it
|
||||
WAIT="${DOKKU_WAIT_TO_RETIRE:-60}"
|
||||
dokku_log_info1 "Shutting down old container in $WAIT seconds"
|
||||
dokku_log_info1 "Shutting down old containers in $WAIT seconds"
|
||||
for oldid in $oldids; do
|
||||
dokku_log_info2 "$oldid"
|
||||
done
|
||||
(
|
||||
exec >/dev/null 2>/dev/null </dev/null
|
||||
trap '' INT HUP
|
||||
sleep $WAIT
|
||||
docker kill $oldid
|
||||
for oldid in $oldids; do
|
||||
docker stop $oldid &> /dev/null
|
||||
docker kill $oldid &> /dev/null # force a kill as docker seems to not send SIGKILL as the docs would indicate
|
||||
done
|
||||
) & disown -a
|
||||
# Use trap since disown/nohup don't seem to keep child alive
|
||||
# Give child process just enough time to set the traps
|
||||
sleep 0.1
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
cleanup)
|
||||
|
||||
@@ -7,6 +7,7 @@ case "$1" in
|
||||
APP="$2"; IMAGE="dokku/$APP"; IMAGE_SOURCE_TYPE="$3"; TMP_WORK_DIR="$4"
|
||||
CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||
|
||||
[[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source "$DOKKU_ROOT/$APP/ENV"
|
||||
pushd "$TMP_WORK_DIR" &> /dev/null
|
||||
|
||||
case "$IMAGE_SOURCE_TYPE" in
|
||||
@@ -38,10 +39,12 @@ case "$1" in
|
||||
DOCKERFILE_PORT=$(grep EXPOSE Dockerfile | head -1 | awk '{ print $2 }' || true)
|
||||
[[ -n "$DOCKERFILE_PORT" ]] && dokku config:set-norestart $APP DOKKU_DOCKERFILE_PORT=$DOCKERFILE_PORT
|
||||
|
||||
# sticking with same pattern of building app image before pre-build for now.
|
||||
docker build -t "$IMAGE" .
|
||||
# buildstep pluginhooks don't necessarily make sense for dockerfiles. call the new breed!!!
|
||||
pluginhook pre-build-dockerfile "$APP"
|
||||
|
||||
[[ "$DOKKU_DOCKERFILE_CACHE_BUILD" == "false" ]] && DOKKU_DOCKER_BUILD_OPTS="$DOKKU_DOCKER_BUILD_OPTS --no-cache"
|
||||
docker build $DOKKU_DOCKER_BUILD_OPTS -t "$IMAGE" .
|
||||
|
||||
pluginhook post-build-dockerfile "$APP"
|
||||
;;
|
||||
|
||||
@@ -108,15 +111,23 @@ case "$1" in
|
||||
;;
|
||||
|
||||
ls)
|
||||
apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (echo "You haven't depoyed any applications yet" && exit 1)
|
||||
dokku_apps=$(ls -d $DOKKU_ROOT/*/ 2>/dev/null) || (echo "You haven't deployed any applications yet" && exit 1)
|
||||
|
||||
dokku_col_log_info2_quiet "App Name" "Container id"
|
||||
dokku_col_log_info1_quiet "App Name" "Container Type" "Container Id" "Status"
|
||||
|
||||
for app in $apps; do
|
||||
if [[ -f $app/CONTAINER ]]; then
|
||||
dokku_col_log_msg "$(basename $app)" "$(< $app/CONTAINER)"
|
||||
for dokku_app in $dokku_apps; do
|
||||
APP=$(basename $dokku_app)
|
||||
DOKKU_APP_CIDS=$(get_container_ids $APP)
|
||||
DOCKER_RUNNING_CONTAINERS=$(docker ps -q --no-trunc)
|
||||
if [[ -n $DOKKU_APP_CIDS ]]; then
|
||||
for DOKKU_APP_CID in $DOKKU_APP_CIDS; do
|
||||
DOKKU_APP_CONTAINER_STATUS="stopped"
|
||||
[[ $DOCKER_RUNNING_CONTAINERS =~ $DOKKU_APP_CID ]] && DOKKU_APP_CONTAINER_STATUS="running"
|
||||
DOKKU_APP_CONTAINER_TYPE=$(grep -l $DOKKU_APP_CID $DOKKU_ROOT/$APP/CONTAINER.* | awk -F. '{ print $2 }')
|
||||
dokku_col_log_msg "$APP" "$DOKKU_APP_CONTAINER_TYPE" "${DOKKU_APP_CID:0:12}" "$DOKKU_APP_CONTAINER_STATUS"
|
||||
done
|
||||
else
|
||||
dokku_col_log_msg "$(basename $app)"
|
||||
dokku_col_log_msg "$APP" "NOT_DEPLOYED" "NOT_DEPLOYED" "NOT_DEPLOYED"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
@@ -126,13 +137,23 @@ case "$1" in
|
||||
verify_app_name "$2"
|
||||
APP="$2";
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
|
||||
CONTAINER=$(<$DOKKU_ROOT/$APP/CONTAINER)
|
||||
if (is_deployed $APP); then
|
||||
CONTAINER_IDS=( $(get_container_ids $APP) )
|
||||
LAST_CONTAINER_ID=${CONTAINER_IDS[${#CONTAINER_IDS[@]} - 1]}
|
||||
|
||||
if [[ $3 == "-t" ]]; then
|
||||
docker logs --follow $CONTAINER
|
||||
DOKKU_LOGS_ARGS="--follow"
|
||||
else
|
||||
docker logs $CONTAINER | tail -n 100
|
||||
DOKKU_LOGS_ARGS="--tail 100"
|
||||
fi
|
||||
for CID in "${CONTAINER_IDS[@]}";do
|
||||
if [[ "$CID" != "$LAST_CONTAINER_ID" ]];then
|
||||
DOKKU_LOGS_CMD+="docker logs $DOKKU_LOGS_ARGS $CID& "
|
||||
else
|
||||
DOKKU_LOGS_CMD+="docker logs $DOKKU_LOGS_ARGS $CID; "
|
||||
fi
|
||||
done
|
||||
bash -c "($DOKKU_LOGS_CMD)"
|
||||
else
|
||||
echo "Application's container not found"
|
||||
fi
|
||||
@@ -180,7 +201,9 @@ case "$1" in
|
||||
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then
|
||||
echo "$SCHEME://$(< "$DOKKU_ROOT/VHOST")"
|
||||
else
|
||||
echo "$SCHEME://$(< "$DOKKU_ROOT/HOSTNAME"):$(< "$DOKKU_ROOT/$APP/PORT")"
|
||||
for PORT_FILE in $DOKKU_ROOT/$APP/PORT.*; do
|
||||
echo "$SCHEME://$(< "$DOKKU_ROOT/HOSTNAME"):$(< "$PORT_FILE")"
|
||||
done
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
@@ -41,3 +41,18 @@ WantedBy=multi-user.target
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
cat<<EOF > /etc/update-motd.d/99-dokku
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f "/home/dokku/HOSTNAME" ]; then
|
||||
echo "\nTo avoid cli-based dokku configuration, use the web installer"
|
||||
echo "Debian-based installs should have this running and available"
|
||||
echo "on port 80. You can also install it via the following commands:"
|
||||
echo ""
|
||||
echo " cd /root/dokku"
|
||||
echo " sudo make dokku-installer\n"
|
||||
fi
|
||||
EOF
|
||||
chmod +x /etc/update-motd.d/99-dokku
|
||||
|
||||
@@ -40,11 +40,12 @@ case "$1" in
|
||||
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
|
||||
DOKKU_APP_CIDS=$(get_container_ids $APP)
|
||||
if [[ -n $DOKKU_APP_CIDS ]]; then
|
||||
for ID in $DOKKU_APP_CIDS;do
|
||||
docker stop $ID > /dev/null || true
|
||||
docker rm $ID > /dev/null || true
|
||||
done
|
||||
fi
|
||||
|
||||
docker images | grep $IMAGE | awk '{print $3}' | xargs docker rmi &> /dev/null &
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
# You can also specify the protocol to explicitly check HTTPS requests.
|
||||
#
|
||||
# The default behavior is to wait for 5 seconds before running the first check,
|
||||
# and timeout each check to 30 minutes.
|
||||
# and timeout each check to 30 seconds.
|
||||
#
|
||||
# By default, checks will be retried 5 times.
|
||||
# By default, checks will be retried 5 times.
|
||||
|
||||
# You can change these by setting WAIT, TIMEOUT and ATTEMPTS to different values, for
|
||||
# example:
|
||||
@@ -37,15 +37,16 @@
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
APP="$1"; DOKKU_APP_LISTEN_PORT="$2"; DOKKU_APP_LISTEN_IP="$3"; DOKKU_APP_CONTAINER_ID="$4"
|
||||
APP="$1"; DOKKU_APP_CONTAINER_ID="$2"; DOKKU_APP_CONTAINER_TYPE="$3"; DOKKU_APP_LISTEN_PORT="$4"; DOKKU_APP_LISTEN_IP="$5"
|
||||
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
|
||||
DOKKU_APP_LISTEN_PORT=$(< "$DOKKU_ROOT/$APP/PORT")
|
||||
fi
|
||||
if [[ -z "$DOKKU_APP_LISTEN_IP" ]] && [[ -f "$DOKKU_ROOT/$APP/IP" ]]; then
|
||||
DOKKU_APP_LISTEN_IP=$(< "$DOKKU_ROOT/$APP/IP")
|
||||
fi
|
||||
if [[ -z "$DOKKU_APP_CONTAINER_ID" ]] && [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
|
||||
DOKKU_APP_CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||
if [[ -z "$DOKKU_APP_CONTAINER_ID" ]]; then
|
||||
DOKKU_APP_CIDS=( $(get_container_ids $APP) )
|
||||
DOKKU_APP_CONTAINER_ID=${DOKKU_APP_CIDS[0]}
|
||||
fi
|
||||
|
||||
|
||||
@@ -77,13 +78,16 @@ cleanup() {
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ ! -s "${TMPDIR}/CHECKS" ]] ; then
|
||||
dokku_log_verbose "CHECKS file not found in container: running simple container check..."
|
||||
if [[ ! -s "${TMPDIR}/CHECKS" ]] || [[ "$DOKKU_APP_CONTAINER_TYPE" != "web" ]]; then
|
||||
dokku_log_verbose "For more efficient zero downtime deployments, create a file CHECKS."
|
||||
dokku_log_verbose "See http://progrium.viewdocs.io/dokku/checks-examples.md for examples"
|
||||
dokku_log_verbose "CHECKS file not found in container: Running simple container check..."
|
||||
|
||||
rm -rf $TMPDIR
|
||||
|
||||
# simple default check to see if the container stuck around
|
||||
# for more thorough checks, create a CHECKS file
|
||||
DOKKU_DEFAULT_WAIT=$((WAIT+TIMEOUT))
|
||||
DOKKU_DEFAULT_WAIT=10
|
||||
dokku_log_info1 "Waiting for $DOKKU_DEFAULT_WAIT seconds ..."
|
||||
sleep $DOKKU_DEFAULT_WAIT
|
||||
|
||||
@@ -113,30 +117,31 @@ do
|
||||
ATTEMPT=$(( ATTEMPT + 1 ))
|
||||
dokku_log_info1 "Attempt $ATTEMPT/$ATTEMPTS Waiting for $WAIT seconds ..."
|
||||
sleep $WAIT
|
||||
|
||||
|
||||
|
||||
|
||||
# -q do not use .curlrc (must come first)
|
||||
# --compressed Test compression handled correctly
|
||||
# --fail Fail on server errors (4xx, 5xx)
|
||||
# --location Follow redirects
|
||||
CURL_OPTIONS="-q --compressed --fail --location --max-time $TIMEOUT"
|
||||
|
||||
|
||||
|
||||
|
||||
exec < "$FILENAME"
|
||||
while read CHECK_URL EXPECTED ; do
|
||||
# Ignore empty lines and lines starting with #
|
||||
# shellcheck disable=SC1001
|
||||
[[ -z "$CHECK_URL" || "$CHECK_URL" =~ ^\# ]] && continue
|
||||
# Ignore variables
|
||||
[[ "$CHECK_URL" =~ ^.+= ]] && continue
|
||||
|
||||
# Ignore if it's not a URL in a supported format
|
||||
# shellcheck disable=SC1001
|
||||
! [[ "$CHECK_URL" =~ ^(http(s)?:)?\/.+ ]] && continue
|
||||
|
||||
if [[ "$CHECK_URL" =~ ^https?: ]] ; then
|
||||
URL_PROTOCOL=${CHECK_URL%:*}
|
||||
CHECK_URL=${CHECK_URL#*:}
|
||||
else
|
||||
URL_PROTOCOL="http"
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$CHECK_URL" =~ ^//.+ ]] ; then
|
||||
# To test a URL with specific host name, we still make request to localhost,
|
||||
# but we set Host header to $SEND_HOST.
|
||||
@@ -146,22 +151,22 @@ do
|
||||
UNPREFIXED=${CHECK_URL#//}
|
||||
URL_HOSTNAME=${UNPREFIXED%%/*}
|
||||
URL_PATHNAME=${UNPREFIXED#$URL_HOSTNAME}
|
||||
|
||||
|
||||
HEADERS="-H Host:$URL_HOSTNAME"
|
||||
else
|
||||
URL_HOSTNAME=localhost
|
||||
URL_PATHNAME=$CHECK_URL
|
||||
fi
|
||||
|
||||
|
||||
# This URL will show up in the messages
|
||||
LOG_URL="$URL_PROTOCOL://$URL_HOSTNAME$URL_PATHNAME"
|
||||
# And how we formulate the CURL request
|
||||
CURL_ARGS="$CURL_OPTIONS $URL_PROTOCOL://$DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT$URL_PATHNAME $HEADERS"
|
||||
|
||||
|
||||
dokku_log_verbose "CHECKS expected result:"
|
||||
dokku_log_verbose "$LOG_URL => \"$EXPECTED\""
|
||||
[[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS"
|
||||
|
||||
|
||||
# Capture HTTP response or CURL error message
|
||||
if OUTPUT=$(curl -# $CURL_ARGS 2>&1) ; then
|
||||
# OUTPUT contains the HTTP response
|
||||
@@ -175,7 +180,7 @@ do
|
||||
FAILEDCHECKS=$(( FAILEDCHECKS + 1 ))
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
if [ $FAILEDCHECKS -gt 0 ]; then
|
||||
dokku_log_warn "Check attempt $ATTEMPT/$ATTEMPTS failed."
|
||||
SUCCESS=0
|
||||
|
||||
@@ -34,36 +34,36 @@ dokku_log_info2_quiet() {
|
||||
}
|
||||
|
||||
dokku_col_log_info1() {
|
||||
printf "%-40s %-40s\n" "-----> $@"
|
||||
printf "%-25s %-25s %-25s %-25s\n" "-----> $@"
|
||||
}
|
||||
|
||||
dokku_col_log_info1_quiet() {
|
||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
|
||||
printf "%-40s %-40s\n" "-----> $@"
|
||||
printf "%-25s %-25s %-25s %-25s\n" "-----> $@"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
dokku_col_log_info2() {
|
||||
printf "%-40s %-40s\n" "=====> $@"
|
||||
printf "%-25s %-25s %-25s %-25s\n" "=====> $@"
|
||||
}
|
||||
|
||||
dokku_col_log_info2_quiet() {
|
||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
|
||||
printf "%-40s %-40s\n" "=====> $@"
|
||||
printf "%-25s %-25s %-25s %-25s\n" "=====> $@"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
dokku_col_log_msg() {
|
||||
printf "%-40s %-40s\n" "$@"
|
||||
printf "%-25s %-25s %-25s %-25s\n" "$@"
|
||||
}
|
||||
|
||||
dokku_col_log_msg_quiet() {
|
||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
|
||||
printf "%-40s %-40s\n" "$@"
|
||||
printf "%-25s %-25s %-25s %-25s\n" "$@"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
@@ -104,17 +104,37 @@ dokku_container_log_verbose_quiet() {
|
||||
|
||||
verify_app_name() {
|
||||
local APP="$1"
|
||||
[[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null"
|
||||
[[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
|
||||
IMAGE="dokku/$APP"
|
||||
return 0
|
||||
}
|
||||
|
||||
verify_image() {
|
||||
local IMAGE="$1"
|
||||
DOKKU_APP_IMAGES=$(docker images -q $IMAGE)
|
||||
if [[ -n "$DOKKU_APP_IMAGES" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_image_buildstep_based() {
|
||||
# circleci can't support --rm as they run lxc in lxc
|
||||
[[ ! -f "/home/ubuntu/.circlerc" ]] && local DOCKER_ARGS="--rm"
|
||||
docker run --entrypoint="/bin/bash" $DOCKER_ARGS "$@" -c "[[ -f /exec ]]"
|
||||
}
|
||||
|
||||
is_number() {
|
||||
local NUMBER=$1; local NUM_RE='^[0-9]+$'
|
||||
if [[ $NUMBER =~ $NUM_RE ]];then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
@@ -134,3 +154,39 @@ parse_args() {
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
copy_from_image() {
|
||||
local IMAGE="$1"; local SRC_FILE="$2"; local DST_DIR="$3"; verify_app_name $APP
|
||||
|
||||
if verify_image "$IMAGE"; then
|
||||
CID=$(docker run -d $IMAGE bash)
|
||||
docker cp "$CID:$SRC_FILE" "$DST_DIR"
|
||||
docker rm -f "$CID" &> /dev/null
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_deployed() {
|
||||
APP="$1"
|
||||
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] || [[ $(ls $DOKKU_ROOT/$APP/CONTAINER.* &> /dev/null; echo $?) -eq 0 ]];then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_container_ids() {
|
||||
APP="$1"
|
||||
verify_app_name $APP
|
||||
[[ -f $DOKKU_ROOT/$APP/CONTAINER ]] && DOKKU_CIDS+=$(< $DOKKU_ROOT/$APP/CONTAINER)
|
||||
|
||||
shopt -s nullglob
|
||||
for DOKKU_CID_FILE in $DOKKU_ROOT/$APP/CONTAINER.*; do
|
||||
DOKKU_CIDS+=" "
|
||||
DOKKU_CIDS+=$(< $DOKKU_CID_FILE)
|
||||
DOKKU_CIDS+=" "
|
||||
done
|
||||
shopt -u nullglob
|
||||
echo $DOKKU_CIDS
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ config_styled_hash () {
|
||||
|
||||
config_write() {
|
||||
ENV_TEMP="$1"
|
||||
echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP
|
||||
echo "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP
|
||||
if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then
|
||||
cp -f $ENV_FILE_TEMP $ENV_FILE
|
||||
chmod 600 $ENV_FILE
|
||||
@@ -137,8 +137,9 @@ case "$1" in
|
||||
|
||||
if [[ $KEY =~ [a-zA-Z_][a-zA-Z0-9_]* ]]; then
|
||||
RESTART_APP=true
|
||||
ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $KEY=/ d")
|
||||
ENV_TEMP="${ENV_TEMP}\nexport $KEY='$VALUE'"
|
||||
ENV_TEMP=$(echo "${ENV_TEMP}" | sed "/^export $KEY=/ d")
|
||||
ENV_TEMP="${ENV_TEMP}
|
||||
export $KEY='$VALUE'"
|
||||
ENV_ADD=$(echo -e "${ENV_ADD}" | sed "/^$KEY=/ d")
|
||||
ENV_ADD="${ENV_ADD}$
|
||||
${var}"
|
||||
|
||||
@@ -81,7 +81,8 @@ get_passed_docker_option() {
|
||||
|
||||
add_passed_docker_option() {
|
||||
local passed_phases=("${!1}")
|
||||
local passed_option_string=$2
|
||||
shift
|
||||
local passed_option_string="$*"
|
||||
local phase
|
||||
for phase in "${passed_phases[@]}"; do
|
||||
get_phase_file_path $phase
|
||||
@@ -94,7 +95,8 @@ add_passed_docker_option() {
|
||||
|
||||
remove_passed_docker_option() {
|
||||
local passed_phases=("${!1}")
|
||||
local passed_option_string=$2
|
||||
shift
|
||||
local passed_option_string="$*"
|
||||
local phase
|
||||
for phase in "${passed_phases[@]}"; do
|
||||
get_phase_file_path $phase
|
||||
|
||||
@@ -45,7 +45,7 @@ case "$1" in
|
||||
VHOST=$(< "$DOKKU_ROOT/HOSTNAME")
|
||||
fi
|
||||
if [[ "$VHOST" =~ $RE_IPV4 ]] || [[ "$VHOST" =~ $RE_IPV6 ]];then
|
||||
echo "unsupported vhost config found. disabling vhost support"
|
||||
dokku_log_info2 "unsupported vhost config found. disabling vhost support"
|
||||
dokku config:set-norestart $APP NO_VHOST=1
|
||||
else
|
||||
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then
|
||||
@@ -71,8 +71,8 @@ case "$1" in
|
||||
verify_app_name "$2"
|
||||
APP="$2"
|
||||
|
||||
if [[ -z $3 ]]; then
|
||||
echo "Usage: dokku $1 $APP DOMAIN"
|
||||
if [[ -z "${*:3}" ]]; then
|
||||
echo "Usage: dokku $1 $APP DOMAIN [DOMAIN ...]"
|
||||
echo "Must specify DOMAIN."
|
||||
exit 1
|
||||
fi
|
||||
@@ -82,12 +82,17 @@ case "$1" in
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shift 2
|
||||
dokku domains:setup $APP
|
||||
echo "$3" >> "$DOKKU_ROOT/$APP/VHOST"
|
||||
for DOMAIN in "$@";do
|
||||
echo "$DOMAIN" >> "$DOKKU_ROOT/$APP/VHOST"
|
||||
done
|
||||
# we need to restart the app to make sure we're binding to the appropriate network interface
|
||||
dokku ps:restart $APP
|
||||
dokku nginx:build-config $APP
|
||||
pluginhook post-domains-update $APP
|
||||
dokku_log_info1 "Added $3 to $APP"
|
||||
for DOMAIN in "$@";do
|
||||
dokku_log_info1 "Added $DOMAIN to $APP"
|
||||
done
|
||||
|
||||
;;
|
||||
|
||||
@@ -108,16 +113,21 @@ case "$1" in
|
||||
verify_app_name "$2"
|
||||
APP="$2"
|
||||
|
||||
if [[ -z $3 ]]; then
|
||||
echo "Usage: dokku $1 $2 DOMAIN"
|
||||
if [[ -z "${*:3}" ]]; then
|
||||
echo "Usage: dokku $1 $APP DOMAIN [DOMAIN ...]"
|
||||
echo "Must specify DOMAIN."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shift 2
|
||||
dokku domains:setup $APP
|
||||
sed -i "/^$3$/d" "$DOKKU_ROOT/$APP/VHOST"
|
||||
for DOMAIN in "$@";do
|
||||
sed -i "/^$DOMAIN$/d" "$DOKKU_ROOT/$APP/VHOST"
|
||||
done
|
||||
pluginhook post-domains-update $APP
|
||||
dokku_log_info1 "Removed $3 from $APP"
|
||||
for DOMAIN in "$@";do
|
||||
dokku_log_info1 "Removed $DOMAIN from $APP"
|
||||
done
|
||||
|
||||
;;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ case "$1" in
|
||||
;;
|
||||
|
||||
git-*)
|
||||
APP="$(echo $2 | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g')"
|
||||
APP="$(echo $2 | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g' | sed 's/^\///g')"
|
||||
APP_PATH=$DOKKU_ROOT/$APP
|
||||
|
||||
if [[ $1 == "git-receive-pack" && ! -d "$APP_PATH/refs" ]]; then
|
||||
@@ -87,7 +87,11 @@ EOF
|
||||
chmod +x $PRERECEIVE_HOOK
|
||||
fi
|
||||
|
||||
args=$*
|
||||
if [[ $1 == "git-receive-pack" ]]; then
|
||||
args="$1 '$APP_PATH'"
|
||||
else
|
||||
args=$*
|
||||
fi
|
||||
git-shell -c "$args"
|
||||
;;
|
||||
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
validate_nginx () {
|
||||
set +e
|
||||
sudo /usr/sbin/nginx -t > /dev/null 2>&1
|
||||
exit_code=$?
|
||||
set -e
|
||||
if [[ "$exit_code" -ne "0" ]]; then
|
||||
sudo /usr/sbin/nginx -t
|
||||
exit "$exit_code"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_nginx () {
|
||||
case "$DOKKU_DISTRO" in
|
||||
ubuntu)
|
||||
@@ -17,20 +28,30 @@ restart_nginx () {
|
||||
case "$1" in
|
||||
nginx:build-config)
|
||||
APP="$2"; DOKKU_APP_LISTEN_PORT="$3"; DOKKU_APP_LISTEN_IP="${4}"
|
||||
verify_app_name "$APP"
|
||||
VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||
URLS_PATH="$DOKKU_ROOT/$APP/URLS"
|
||||
WILDCARD_SSL="$DOKKU_ROOT/tls"
|
||||
SSL="$DOKKU_ROOT/$APP/tls"
|
||||
APP_NGINX_TEMPLATE="$DOKKU_ROOT/$APP/nginx.conf.template"
|
||||
|
||||
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT" ]]; then
|
||||
DOKKU_APP_LISTEN_PORT=$(< "$DOKKU_ROOT/$APP/PORT")
|
||||
fi
|
||||
if [[ -z "$DOKKU_APP_LISTEN_IP" ]] && [[ -f "$DOKKU_ROOT/$APP/IP" ]]; then
|
||||
DOKKU_APP_LISTEN_IP=$(< "$DOKKU_ROOT/$APP/IP")
|
||||
if [[ -z "$DOKKU_APP_LISTEN_PORT" ]] && [[ -z "$DOKKU_APP_LISTEN_IP" ]]; then
|
||||
shopt -s nullglob
|
||||
for DOKKU_APP_IP_FILE in $DOKKU_ROOT/$APP/IP.web.*;do
|
||||
DOKKU_APP_PORT_FILE=$(echo $DOKKU_APP_IP_FILE | sed -e "s:IP:PORT:g")
|
||||
DOKKU_APP_LISTENER_IP=$(< $DOKKU_APP_IP_FILE)
|
||||
DOKKU_APP_LISTENER_PORT=$(< $DOKKU_APP_PORT_FILE)
|
||||
|
||||
DOKKU_APP_LISTENERS+=" "
|
||||
DOKKU_APP_LISTENERS+="$DOKKU_APP_LISTENER_IP:$DOKKU_APP_LISTENER_PORT"
|
||||
DOKKU_APP_LISTENERS+=" "
|
||||
done
|
||||
shopt -u nullglob
|
||||
fi
|
||||
|
||||
[[ -f "$DOKKU_ROOT/ENV" ]] && source $DOKKU_ROOT/ENV
|
||||
[[ -f "$DOKKU_ROOT/$APP/ENV" ]] && source $DOKKU_ROOT/$APP/ENV
|
||||
[[ -f "$APP_NGINX_TEMPLATE" ]] && NGINX_TEMPLATE="$APP_NGINX_TEMPLATE" && NGINX_CUSTOM_TEMPLATE="true" && dokku_log_info1 'Overriding default nginx.conf with detected nginx.conf.template'
|
||||
|
||||
if [[ ! -n "$NO_VHOST" ]] && [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||
NONSSL_VHOSTS=$(cat $VHOST_PATH)
|
||||
@@ -51,23 +72,24 @@ EOF
|
||||
if [[ -n "$SSL_INUSE" ]]; then
|
||||
SCHEME="https"
|
||||
|
||||
[[ -z "$NGINX_TEMPLATE" ]] && NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf.template"
|
||||
SSL_HOSTNAME=$(openssl x509 -in $SSL_INUSE/server.crt -noout -subject | tr '/' '\n' | grep CN= | cut -c4-)
|
||||
if [[ -n "$SSL_HOSTNAME" ]]; then
|
||||
SSL_HOSTNAME_REGEX=$(echo "$SSL_HOSTNAME" | sed 's|\.|\\.|g' | sed 's/\*/\[^\.\]\*/g')
|
||||
[[ -z "$(egrep "^${SSL_HOSTNAME_REGEX}$" $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME" >> $VHOST_PATH
|
||||
[[ -z "$(egrep "^${SSL_HOSTNAME_REGEX}$" $VHOST_PATH)" ]] && [[ ! "$SSL_HOSTNAME" =~ ^\*.* ]] && echo "$SSL_HOSTNAME" >> $VHOST_PATH
|
||||
fi
|
||||
|
||||
SSL_HOSTNAME_ALT=$(openssl x509 -in $SSL_INUSE/server.crt -noout -text | grep --after-context=1 '509v3 Subject Alternative Name:' | tail -n 1 | sed -e "s/[[:space:]]*DNS://g" | tr ',' '\n' || true)
|
||||
if [[ -n "$SSL_HOSTNAME_ALT" ]]; then
|
||||
SSL_HOSTNAME_ALT_REGEX=$(echo "$SSL_HOSTNAME_ALT" | sed 's|\.|\\.|g' | sed 's/\*/\[^\.\]\*/g')
|
||||
[[ -z "$(egrep "^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH)" ]] && echo "$SSL_HOSTNAME_ALT" >> $VHOST_PATH
|
||||
[[ -z "$(egrep "^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH)" ]] && [[ ! "$SSL_HOSTNAME_ALT" =~ ^\*.* ]] && echo "$SSL_HOSTNAME_ALT" >> $VHOST_PATH
|
||||
fi
|
||||
|
||||
SSL_VHOSTS=$(egrep "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0)
|
||||
NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0)
|
||||
NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME_REGEX}$|^${SSL_HOSTNAME_ALT_REGEX}$" $VHOST_PATH || exit 0)
|
||||
|
||||
NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.ssl.conf.template"
|
||||
while read line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
dokku_log_info1 "Configuring SSL for $line..."
|
||||
SSL_SERVER_NAME=$line
|
||||
NOSSL_SERVER_NAME=$line
|
||||
@@ -75,30 +97,32 @@ EOF
|
||||
done <<< "$SSL_VHOSTS"
|
||||
fi
|
||||
|
||||
NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS | tr '\n' ' ')
|
||||
APP_NGINX_TEMPLATE="$DOKKU_ROOT/$APP/nginx.conf.template"
|
||||
if [[ -f $APP_NGINX_TEMPLATE ]]; then
|
||||
dokku_log_info1 "Overriding default nginx.conf with detected nginx.conf.template"
|
||||
eval "cat <<< \"$(< $APP_NGINX_TEMPLATE)\" > $NGINX_CONF"
|
||||
elif [[ -n "$NONSSL_VHOSTS" ]]; then
|
||||
if [[ -n "$NONSSL_VHOSTS" ]]; then
|
||||
NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS | tr '\n' ' ')
|
||||
xargs -i echo "-----> Configuring {}..." <<< "$NONSSL_VHOSTS"
|
||||
NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.conf.template"
|
||||
[[ -z "$NGINX_CUSTOM_TEMPLATE" ]] && NGINX_TEMPLATE="$PLUGIN_PATH/nginx-vhosts/templates/nginx.conf.template"
|
||||
eval "cat <<< \"$(< $NGINX_TEMPLATE)\" >> $NGINX_CONF"
|
||||
fi
|
||||
|
||||
if [[ -n "$DOKKU_APP_LISTEN_PORT" ]] && [[ -n "$DOKKU_APP_LISTEN_IP" ]]; then
|
||||
echo "upstream $APP { server $DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT; }" >> $NGINX_CONF
|
||||
elif [[ -n "$DOKKU_APP_LISTENERS" ]]; then
|
||||
echo "upstream $APP { " >> $NGINX_CONF
|
||||
for listener in $DOKKU_APP_LISTENERS;do
|
||||
echo " server $listener;" >> $NGINX_CONF
|
||||
done
|
||||
echo "}" >> $NGINX_CONF
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Creating $SCHEME nginx.conf"
|
||||
mv $NGINX_CONF "$DOKKU_ROOT/$APP/nginx.conf"
|
||||
|
||||
if [[ -n "$DOKKU_APP_LISTEN_PORT" ]] && [[ -n "$DOKKU_APP_LISTEN_IP" ]]; then
|
||||
if is_deployed "$APP"; then
|
||||
dokku_log_info1 "Running nginx-pre-reload"
|
||||
pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP
|
||||
|
||||
echo " Reloading nginx"
|
||||
restart_nginx
|
||||
dokku_log_verbose "Reloading nginx"
|
||||
validate_nginx && restart_nginx
|
||||
fi
|
||||
|
||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" > $URLS_PATH
|
||||
@@ -113,8 +137,10 @@ EOF
|
||||
dokku_log_info1 "VHOST support disabled, deleting nginx.conf"
|
||||
rm "$DOKKU_ROOT/$APP/nginx.conf"
|
||||
|
||||
dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
|
||||
restart_nginx
|
||||
if is_deployed "$APP"; then
|
||||
dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
|
||||
validate_nginx && restart_nginx
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
if [[ ! -f /etc/sudoers.d/dokku-nginx ]]; then
|
||||
case "$DOKKU_DISTRO" in
|
||||
ubuntu)
|
||||
echo "%dokku ALL=(ALL) NOPASSWD:/etc/init.d/nginx reload" >> /etc/sudoers.d/dokku-nginx
|
||||
;;
|
||||
case "$DOKKU_DISTRO" in
|
||||
ubuntu)
|
||||
echo "%dokku ALL=(ALL) NOPASSWD:/etc/init.d/nginx reload, /usr/sbin/nginx -t" > /etc/sudoers.d/dokku-nginx
|
||||
;;
|
||||
|
||||
opensuse)
|
||||
echo "%dokku ALL=(ALL) NOPASSWD:/sbin/service nginx reload" >> /etc/sudoers.d/dokku-nginx
|
||||
;;
|
||||
esac
|
||||
opensuse)
|
||||
echo "%dokku ALL=(ALL) NOPASSWD:/sbin/service nginx reload, /usr/sbin/nginx -t" > /etc/sudoers.d/dokku-nginx
|
||||
;;
|
||||
esac
|
||||
|
||||
chmod 0440 /etc/sudoers.d/dokku-nginx
|
||||
fi
|
||||
chmod 0440 /etc/sudoers.d/dokku-nginx
|
||||
|
||||
# if dokku.conf has not been created, create it
|
||||
if [[ ! -f /etc/nginx/conf.d/dokku.conf ]]; then
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
APP="$1"; PORT="$2"; IP="$3"
|
||||
APP="$1"
|
||||
NO_VHOST=$(dokku config:get $APP NO_VHOST || true)
|
||||
|
||||
if [[ -n "$NO_VHOST" ]]; then
|
||||
@@ -11,4 +11,4 @@ elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||
dokku domains:setup $APP
|
||||
fi
|
||||
|
||||
dokku nginx:build-config $APP $PORT $IP
|
||||
dokku nginx:build-config $APP
|
||||
|
||||
@@ -2,6 +2,9 @@ server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
server_name $NOSSL_SERVER_NAME;
|
||||
access_log /var/log/nginx/${APP}-access.log;
|
||||
error_log /var/log/nginx/${APP}-error.log;
|
||||
|
||||
location / {
|
||||
proxy_pass http://$APP;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
@@ -2,13 +2,17 @@ server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
server_name $NOSSL_SERVER_NAME;
|
||||
return 301 https://$SSL_SERVER_NAME\$request_uri;
|
||||
access_log /var/log/nginx/${APP}-access.log;
|
||||
error_log /var/log/nginx/${APP}-error.log;
|
||||
return 301 https://\$host\$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen [::]:443 ssl spdy;
|
||||
listen 443 ssl spdy;
|
||||
server_name $SSL_SERVER_NAME;
|
||||
access_log /var/log/nginx/${APP}-access.log;
|
||||
error_log /var/log/nginx/${APP}-error.log;
|
||||
$SSL_DIRECTIVES
|
||||
|
||||
keepalive_timeout 70;
|
||||
|
||||
@@ -1,47 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
release_and_deploy() {
|
||||
source "$(dirname $0)/../common/functions"
|
||||
local APP="$1"; local IMAGE="dokku/$APP"
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
|
||||
if is_image_buildstep_based "$IMAGE"; then
|
||||
IMAGE_SOURCE_TYPE="buildstep"
|
||||
else
|
||||
IMAGE_SOURCE_TYPE="dockerfile"
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Releasing $APP ..."
|
||||
dokku release "$APP" "$IMAGE_SOURCE_TYPE"
|
||||
dokku_log_info1 "Deploying $APP ..."
|
||||
dokku deploy "$APP"
|
||||
dokku_log_info2 "Application deployed:"
|
||||
dokku urls $APP | sed "s/^/ /"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
source "$(dirname $0)/functions"
|
||||
|
||||
case "$1" in
|
||||
ps)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
|
||||
APP="$2"; [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] && CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||
[[ -z "$CONTAINER_ID" ]] && echo "App $APP has not been deployed" && exit 0
|
||||
APP="$2"; CONTAINER_IDS=$(get_container_ids $APP)
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
docker exec -ti "$CONTAINER_ID" /bin/bash -c "ps auxwww"
|
||||
for CID in $CONTAINER_IDS; do
|
||||
docker exec -ti "$CID" /bin/bash -c "ps auxwww"
|
||||
done
|
||||
;;
|
||||
|
||||
ps:start)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
|
||||
APP="$2"; [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] && CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||
[[ -z "$CONTAINER_ID" ]] && echo "App $APP has not been deployed" && exit 0
|
||||
APP="$2"; CONTAINER_IDS=( $(get_container_ids $APP) )
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
if [[ "$(docker ps -q --no-trunc| grep -q $CONTAINER_ID; echo $?)" != "0" ]]; then
|
||||
if [[ "$(docker ps -q --no-trunc| grep -q ${CONTAINER_IDS[0]}; echo $?)" != "0" ]]; then
|
||||
release_and_deploy $APP
|
||||
else
|
||||
echo "App $APP already running"
|
||||
@@ -52,12 +34,15 @@ case "$1" in
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
|
||||
APP="$2"; [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] && CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||
[[ -z "$CONTAINER_ID" ]] && echo "App $APP has not been deployed" && exit 0
|
||||
APP="$2"; CONTAINER_IDS=$(get_container_ids $APP)
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
if [[ "$(docker ps -q --no-trunc| grep -q $CONTAINER_ID; echo $?)" = "0" ]]; then
|
||||
CONTAINER_IDS_EGREP_PATTERN=$(echo $CONTAINER_IDS | xargs | sed -e "s: :|:g")
|
||||
if [[ "$(docker ps -q --no-trunc| egrep -q $CONTAINER_IDS_EGREP_PATTERN; echo $?)" = "0" ]]; then
|
||||
echo "Stopping $APP ..."
|
||||
docker stop $CONTAINER_ID > /dev/null
|
||||
for CID in $CONTAINER_IDS;do
|
||||
docker stop $CID > /dev/null
|
||||
done
|
||||
else
|
||||
echo "App $APP already stopped"
|
||||
fi
|
||||
@@ -73,33 +58,55 @@ case "$1" in
|
||||
|
||||
ps:rebuildall)
|
||||
shopt -s nullglob
|
||||
for app in $DOKKU_ROOT/*/CONTAINER; do
|
||||
APP=$(basename "$(dirname $app)");
|
||||
dokku ps:rebuild $APP
|
||||
for app in $DOKKU_ROOT/*; do
|
||||
[[ ! -d $app ]] && continue
|
||||
APP=$(basename $app)
|
||||
is_deployed $APP && dokku ps:rebuild $APP
|
||||
done
|
||||
shopt -u nullglob
|
||||
;;
|
||||
|
||||
ps:restart)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
|
||||
APP="$2"; [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]] && CONTAINER_ID=$(< "$DOKKU_ROOT/$APP/CONTAINER")
|
||||
[[ -z "$CONTAINER_ID" ]] && echo "App $APP has not been deployed" && exit 0
|
||||
APP="$2"
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
release_and_deploy $APP
|
||||
;;
|
||||
|
||||
ps:restartall)
|
||||
shopt -s nullglob
|
||||
for app in $DOKKU_ROOT/*/CONTAINER; do
|
||||
APP=$(basename "$(dirname $app)");
|
||||
for app in $DOKKU_ROOT/*; do
|
||||
[[ ! -d $app ]] && continue
|
||||
APP=$(basename $app)
|
||||
dokku ps:restart $APP
|
||||
done
|
||||
shopt -u nullglob
|
||||
;;
|
||||
|
||||
ps:scale)
|
||||
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
|
||||
verify_app_name "$2"
|
||||
|
||||
APP="$2"; DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
shift 2
|
||||
|
||||
generate_scale_file "$APP"
|
||||
if [[ -z "$@" ]];then
|
||||
dokku_log_info1 "Scaling for $APP"
|
||||
dokku_log_info2 "$(< $DOKKU_SCALE_FILE)"
|
||||
else
|
||||
set_scale "$APP" "$@"
|
||||
release_and_deploy "$APP"
|
||||
fi
|
||||
;;
|
||||
|
||||
help | ps:help)
|
||||
cat && cat<<EOF
|
||||
ps <app> List processes running in app container(s)
|
||||
ps:scale <app> <proc>=<count> [<proc>=<count>] Set how many processes of a given process to run
|
||||
ps:start <app> Start app container(s)
|
||||
ps:stop <app> Stop app container(s)
|
||||
ps:rebuild <app> Rebuild an app
|
||||
|
||||
57
plugins/ps/functions
Executable file
57
plugins/ps/functions
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
release_and_deploy() {
|
||||
source "$(dirname $0)/../common/functions"
|
||||
local APP="$1"; local IMAGE="dokku/$APP"
|
||||
|
||||
if verify_image "$IMAGE"; then
|
||||
if is_image_buildstep_based "$IMAGE"; then
|
||||
IMAGE_SOURCE_TYPE="buildstep"
|
||||
else
|
||||
IMAGE_SOURCE_TYPE="dockerfile"
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Releasing $APP ..."
|
||||
dokku release "$APP" "$IMAGE_SOURCE_TYPE"
|
||||
dokku_log_info1 "Deploying $APP ..."
|
||||
dokku deploy "$APP"
|
||||
dokku_log_info2 "Application deployed:"
|
||||
dokku urls $APP | sed "s/^/ /"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
generate_scale_file() {
|
||||
local APP="$1"; local IMAGE="dokku/$APP"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
copy_from_image "$IMAGE" "/app/DOKKU_SCALE" "$DOKKU_ROOT/$APP" 2>/dev/null || true
|
||||
if [[ ! -f $DOKKU_SCALE_FILE ]]; then
|
||||
dokku_log_info1_quiet "DOKKU_SCALE not found in app image. Defaulting to a single web process"
|
||||
echo "web=1" >> $DOKKU_SCALE_FILE
|
||||
|
||||
dokku_log_info1_quiet "New DOKKU_SCALE file generated"
|
||||
while read line || [ -n "$line" ]
|
||||
do
|
||||
dokku_log_info2_quiet "$line"
|
||||
done < "$DOKKU_SCALE_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
set_scale() {
|
||||
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
shift 1
|
||||
local SCALE_SETTINGS=("$@")
|
||||
for procscale in "${SCALE_SETTINGS[@]}"; do
|
||||
PROC_NAME=${procscale%%=*}
|
||||
PROC_COUNT=${procscale#*=}
|
||||
is_number $PROC_COUNT || dokku_log_fail "ps:scale $PROC_COUNT is not a number"
|
||||
dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT"
|
||||
if (egrep -q ^${PROC_NAME}= $DOKKU_SCALE_FILE > /dev/null 2>&1);then
|
||||
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" $DOKKU_SCALE_FILE
|
||||
else
|
||||
echo "$PROC_NAME=$PROC_COUNT" >> $DOKKU_SCALE_FILE
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
8
plugins/ps/pre-deploy
Executable file
8
plugins/ps/pre-deploy
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
source "$(dirname $0)/functions"
|
||||
|
||||
APP="$1"
|
||||
|
||||
generate_scale_file $APP
|
||||
13
tests.mk
13
tests.mk
@@ -28,8 +28,15 @@ endif
|
||||
@echo "-----> Setting up ssh config..."
|
||||
ifneq ($(shell ls /root/.ssh/config > /dev/null 2>&1 ; echo $$?),0)
|
||||
echo "Host dokku.me \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
|
||||
echo "Host 127.0.0.1 \\r\\n Port 22333 \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
|
||||
else ifeq ($(shell grep dokku.me /root/.ssh/config),)
|
||||
echo "Host dokku.me \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
|
||||
echo "Host 127.0.0.1 \\r\\n Port 22333 \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
|
||||
endif
|
||||
|
||||
ifeq ($(shell grep 22333 /etc/ssh/sshd_config),)
|
||||
sed --in-place "s:^Port 22:Port 22 \\nPort 22333:g" /etc/ssh/sshd_config
|
||||
restart ssh
|
||||
endif
|
||||
|
||||
@echo "-----> Installing SSH public key..."
|
||||
@@ -38,6 +45,7 @@ endif
|
||||
|
||||
@echo "-----> Intitial SSH connection to populate known_hosts..."
|
||||
ssh -o StrictHostKeyChecking=no dokku@dokku.me help > /dev/null
|
||||
ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help > /dev/null
|
||||
|
||||
ifeq ($(shell grep dokku.me /home/dokku/VHOST 2>/dev/null),)
|
||||
@echo "-----> Setting default VHOST to dokku.me..."
|
||||
@@ -61,7 +69,11 @@ lint:
|
||||
|
||||
unit-tests:
|
||||
@echo running unit tests...
|
||||
ifndef UNIT_TEST_BATCH
|
||||
@$(QUIET) bats tests/unit
|
||||
else
|
||||
@$(QUIET) ./tests/ci/unit_test_runner.sh $$UNIT_TEST_BATCH
|
||||
endif
|
||||
|
||||
deploy-test-clojure:
|
||||
@echo deploying config app...
|
||||
@@ -125,7 +137,6 @@ deploy-test-static:
|
||||
|
||||
deploy-tests:
|
||||
@echo running deploy tests...
|
||||
# @$(QUIET) bats tests/deploy
|
||||
@$(QUIET) $(MAKE) deploy-test-config
|
||||
@$(QUIET) $(MAKE) deploy-test-clojure
|
||||
@$(QUIET) $(MAKE) deploy-test-dockerfile
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
cron: node worker.js
|
||||
web: node web.js
|
||||
worker: node worker.js
|
||||
|
||||
@@ -9,4 +9,4 @@ app.get('/', function(request, response) {
|
||||
var port = process.env.PORT || 5000;
|
||||
app.listen(port, function() {
|
||||
console.log("Listening on " + port);
|
||||
});
|
||||
});
|
||||
|
||||
6
tests/apps/nodejs-express/worker.js
Normal file
6
tests/apps/nodejs-express/worker.js
Normal file
@@ -0,0 +1,6 @@
|
||||
function worker() {
|
||||
console.log('sleeping for 60 seconds');
|
||||
setTimeout(worker, 60 * 1000);
|
||||
}
|
||||
|
||||
worker();
|
||||
@@ -1,20 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
MODE="$1"; MODE=${MODE:="testing"}
|
||||
|
||||
setup_circle() {
|
||||
MAKE_ENV="CI=true"
|
||||
[[ "$1" == "buildstack" ]] && MAKE_ENV+=" BUILD_STACK=true "
|
||||
echo "setting up with MAKE_ENV: $MAKE_ENV"
|
||||
sudo -E CI=true make -e sshcommand
|
||||
# need to add the dokku user to the docker group
|
||||
sudo usermod -G docker dokku
|
||||
#### circle does some weird *expletive* with regards to root and gh auth (needed for gitsubmodules test)
|
||||
sudo rsync -a ~ubuntu/.ssh/ ~root/.ssh/
|
||||
sudo chown -R root:root ~root/.ssh/
|
||||
sudo sed --in-place 's:/home/ubuntu:/root:g' ~root/.ssh/config
|
||||
####
|
||||
sudo -E $MAKE_ENV make -e install
|
||||
sudo -E make -e setup-deploy-tests
|
||||
make -e ci-dependencies
|
||||
}
|
||||
|
||||
case "$CIRCLE_NODE_INDEX" in
|
||||
0)
|
||||
echo "=====> make unit-tests"
|
||||
sudo -E make -e unit-tests
|
||||
echo "=====> make unit-tests (1/2) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
|
||||
[[ "$MODE" == "setup" ]] && setup_circle && exit 0
|
||||
sudo -E UNIT_TEST_BATCH=1 make -e unit-tests
|
||||
;;
|
||||
|
||||
1)
|
||||
echo "=====> make deploy-tests (buildstep release)"
|
||||
sudo -E make -e deploy-tests
|
||||
echo "=====> make unit-tests (2/2) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
|
||||
[[ "$MODE" == "setup" ]] && setup_circle && exit 0
|
||||
sudo -E UNIT_TEST_BATCH=2 make -e unit-tests
|
||||
;;
|
||||
|
||||
2)
|
||||
echo "=====> make deploy-tests (buildstep master)"
|
||||
docker rmi -f progrium/buildstep && \
|
||||
sudo -E BUILD_STACK=true make -e stack && \
|
||||
echo "=====> make deploy-tests (buildstep release) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
|
||||
[[ "$MODE" == "setup" ]] && setup_circle && exit 0
|
||||
sudo -E make -e deploy-tests
|
||||
;;
|
||||
|
||||
3)
|
||||
echo "=====> make deploy-tests (buildstep master) on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX"
|
||||
[[ "$MODE" == "setup" ]] && setup_circle buildstack && exit 0
|
||||
sudo -E make -e deploy-tests
|
||||
;;
|
||||
esac
|
||||
|
||||
37
tests/ci/unit_test_runner.sh
Executable file
37
tests/ci/unit_test_runner.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
is_number() {
|
||||
local NUMBER=$1; local NUM_RE='^[0-9]+$'
|
||||
if [[ $NUMBER =~ $NUM_RE ]];then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 1|2"
|
||||
exit 0
|
||||
}
|
||||
|
||||
BATCH_NUM="$1"
|
||||
is_number $BATCH_NUM || usage
|
||||
|
||||
TESTS=($(find "$(dirname $0)"/../unit -maxdepth 1 -name "*.bats"))
|
||||
HALF_TESTS=$(( ${#TESTS[@]} / 2 ))
|
||||
FIRST_HALF=("${TESTS[@]:0:${HALF_TESTS}}")
|
||||
LAST_HALF=("${TESTS[@]:${HALF_TESTS}:${#TESTS[@]}}")
|
||||
|
||||
case "$BATCH_NUM" in
|
||||
1)
|
||||
bats "${FIRST_HALF[@]}"
|
||||
;;
|
||||
|
||||
2)
|
||||
bats "${LAST_HALF[@]}"
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy config app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/config dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy gitsubmodules app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/gitsubmodules dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy go app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/go dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy java app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/java dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy multi app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/multi dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy nodejs-express app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/nodejs-express dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy php app" {
|
||||
skip "fails. ref: https://github.com/progrium/buildstep/issues/126"
|
||||
run bash -c "cd tests && ./test_deploy ./apps/php dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy python-flask app" {
|
||||
run bash -c "cd tests && ./test_deploy ./apps/python-flask dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load ../unit/test_helper
|
||||
|
||||
@test "deploy static app" {
|
||||
skip "fails on apt-get update..."
|
||||
run bash -c "cd tests && ./test_deploy ./apps/static dokku.me"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
@@ -131,10 +131,12 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
}
|
||||
|
||||
@test "(client) ps:stop" {
|
||||
@@ -143,10 +145,12 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
done
|
||||
}
|
||||
|
||||
@test "(client) ps:restart" {
|
||||
@@ -155,8 +159,10 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "(config) config:get" {
|
||||
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
|
||||
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\" test_var3=\"with\\nnewline\"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
@@ -28,6 +28,10 @@ teardown() {
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output 'hello world'
|
||||
run dokku config:get $TEST_APP test_var3
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_output 'with\nnewline'
|
||||
}
|
||||
|
||||
@test "(config) config:unset" {
|
||||
|
||||
@@ -115,3 +115,9 @@ build_nginx_config() {
|
||||
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://dokku.example.com"
|
||||
}
|
||||
|
||||
@test "(core) git-remote (off-port)" {
|
||||
run deploy_app nodejs-express ssh://dokku@127.0.0.1:22333/$TEST_APP
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ teardown() {
|
||||
@test "(core) port exposure (with NO_VHOST set)" {
|
||||
deploy_app
|
||||
dokku config:set $TEST_APP NO_VHOST=1
|
||||
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }')
|
||||
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }' | head -1)
|
||||
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
@@ -97,7 +97,12 @@ teardown() {
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }')
|
||||
run dokku ps:restart $TEST_APP
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }' | head -1)
|
||||
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
@@ -111,7 +116,7 @@ teardown() {
|
||||
|
||||
@test "(core) dockerfile port exposure" {
|
||||
deploy_app dockerfile
|
||||
run bash -c "grep upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep 3000"
|
||||
run bash -c "grep -A1 upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep 3000"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
@@ -149,3 +149,14 @@ teardown() {
|
||||
assert_success
|
||||
deploy_app
|
||||
}
|
||||
|
||||
@test "docker-options:add (all phases over SSH)" {
|
||||
run ssh dokku@dokku.me docker-options:add $TEST_APP build,deploy,run "-v /tmp"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 3"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -28,6 +28,13 @@ teardown() {
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(domains) domains:add (multiple)" {
|
||||
run dokku domains:add $TEST_APP www.test.app.dokku.me test.app.dokku.me
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(domains) domains:remove" {
|
||||
run dokku domains:add $TEST_APP test.app.dokku.me
|
||||
echo "output: "$output
|
||||
|
||||
@@ -9,7 +9,7 @@ setup() {
|
||||
}
|
||||
|
||||
teardown() {
|
||||
destroy_app
|
||||
destroy_app 0 $TEST_APP
|
||||
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST"
|
||||
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME"
|
||||
disable_tls_wildcard
|
||||
@@ -53,6 +53,18 @@ assert_http_success() {
|
||||
assert_output "200"
|
||||
}
|
||||
|
||||
assert_access_log() {
|
||||
local prefix=$1
|
||||
run [ -a /var/log/nginx/$prefix-access.log ]
|
||||
assert_success
|
||||
}
|
||||
|
||||
assert_error_log() {
|
||||
local prefix=$1
|
||||
run [ -a /var/log/nginx/$prefix-error.log ]
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx (no server tokens)" {
|
||||
deploy_app
|
||||
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | egrep '^Server' | egrep '[0-9]+'"
|
||||
@@ -61,6 +73,12 @@ assert_http_success() {
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) logging" {
|
||||
deploy_app
|
||||
assert_access_log ${TEST_APP}
|
||||
assert_error_log ${TEST_APP}
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
|
||||
setup_test_tls_wildcard
|
||||
add_domain "wildcard1.dokku.me"
|
||||
@@ -72,12 +90,38 @@ assert_http_success() {
|
||||
assert_nonssl_domain "www.test.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL & custom nginx template)" {
|
||||
setup_test_tls_wildcard
|
||||
add_domain "wildcard1.dokku.me"
|
||||
add_domain "wildcard2.dokku.me"
|
||||
custom_ssl_nginx_template
|
||||
deploy_app
|
||||
assert_ssl_domain "wildcard1.dokku.me"
|
||||
assert_ssl_domain "wildcard2.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL & unrelated domain)" {
|
||||
destroy_app
|
||||
TEST_APP="${TEST_APP}.example.com"
|
||||
setup_test_tls_wildcard
|
||||
deploy_app nodejs-express dokku@dokku.me:$TEST_APP
|
||||
run /bin/bash -c "egrep '*.dokku.me' $DOKKU_ROOT/${TEST_APP}/nginx.conf | wc -l"
|
||||
assert_output "0"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (with SSL CN mismatch)" {
|
||||
setup_test_tls
|
||||
deploy_app
|
||||
assert_ssl_domain "node-js-app.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (with SSL CN mismatch & custom nginx template)" {
|
||||
setup_test_tls
|
||||
custom_ssl_nginx_template
|
||||
deploy_app
|
||||
assert_ssl_domain "node-js-app.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (with SSL and Multiple SANs)" {
|
||||
setup_test_tls_with_sans
|
||||
deploy_app
|
||||
@@ -86,6 +130,13 @@ assert_http_success() {
|
||||
assert_ssl_domain "www.test.app.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (custom nginx template)" {
|
||||
add_domain "www.test.app.dokku.me"
|
||||
custom_nginx_template
|
||||
deploy_app
|
||||
assert_nonssl_domain "www.test.app.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (no global VHOST and domains:add)" {
|
||||
destroy_app
|
||||
rm "$DOKKU_ROOT/VHOST"
|
||||
@@ -94,3 +145,12 @@ assert_http_success() {
|
||||
deploy_app
|
||||
assert_nonssl_domain "www.test.app.dokku.me"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:build-config (validate_nginx)" {
|
||||
deploy_app
|
||||
echo "some lame nginx config" > "$DOKKU_ROOT/$TEST_APP/nginx.conf.template"
|
||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
deploy_app
|
||||
create_app
|
||||
}
|
||||
|
||||
teardown() {
|
||||
@@ -22,39 +22,104 @@ teardown() {
|
||||
# }
|
||||
|
||||
@test "(ps) buildstep" {
|
||||
deploy_app
|
||||
run bash -c "dokku ps:stop $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:start $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:restart $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:rebuild $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
}
|
||||
|
||||
@test "(ps:scale) buildstep" {
|
||||
run bash -c "dokku ps:scale $TEST_APP web=2 worker=2"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
deploy_app
|
||||
for PROC_TYPE in web worker; do
|
||||
CIDS=""
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "
|
||||
done
|
||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||
run bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 2"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:scale $TEST_APP web=1 worker=1"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for PROC_TYPE in web worker; do
|
||||
CIDS=""
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "
|
||||
done
|
||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||
run bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:scale $TEST_APP web=0 worker=0"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for PROC_TYPE in web worker; do
|
||||
CIDS=""
|
||||
shopt -s nullglob
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "1
|
||||
done
|
||||
shopt -u nullglob
|
||||
run bash -c "[[ -z \"$CIDS\" ]]"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
deploy_app dockerfile
|
||||
create_app
|
||||
}
|
||||
|
||||
teardown() {
|
||||
@@ -22,38 +22,96 @@ teardown() {
|
||||
# }
|
||||
|
||||
@test "(ps) dockerfile" {
|
||||
deploy_app dockerfile
|
||||
run bash -c "dokku ps:stop $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:start $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:restart $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
|
||||
run bash -c "dokku ps:rebuild $TEST_APP"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||
run bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
done
|
||||
}
|
||||
|
||||
@test "(ps:scale) dockerfile" {
|
||||
run bash -c "dokku ps:scale $TEST_APP web=2"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
deploy_app dockerfile
|
||||
CIDS=""
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "
|
||||
done
|
||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||
run bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 2"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku ps:scale $TEST_APP web=1"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
CIDS=""
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "
|
||||
done
|
||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||
run bash -c "docker ps -q --no-trunc | egrep \"$CIDS_PATTERN\" | wc -l | grep 1"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
run bash -c "dokku ps:scale $TEST_APP web=0"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
CIDS=""
|
||||
shopt -s nullglob
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||
CIDS+=$(< $CID_FILE)
|
||||
CIDS+=" "
|
||||
done
|
||||
run bash -c "[[ -z \"$CIDS\" ]]"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_success
|
||||
|
||||
@@ -89,7 +89,10 @@ create_app() {
|
||||
}
|
||||
|
||||
destroy_app() {
|
||||
local RC="$1"; local RC=${RC:=0}
|
||||
local TEST_APP="$2"; local TEST_APP=${TEST_APP:=my-cool-guy-test-app}
|
||||
echo $TEST_APP | dokku apps:destroy $TEST_APP
|
||||
return $RC
|
||||
}
|
||||
|
||||
add_domain() {
|
||||
@@ -98,22 +101,24 @@ add_domain() {
|
||||
|
||||
deploy_app() {
|
||||
APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"}
|
||||
TMP=$(mktemp -d -t "$TARGET.XXXXX")
|
||||
GIT_REMOTE="$2"; GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"}
|
||||
TMP=$(mktemp -d -t "dokku.me.XXXXX")
|
||||
rmdir $TMP && cp -r ./tests/apps/$APP_TYPE $TMP
|
||||
cd $TMP
|
||||
git init
|
||||
git config user.email "robot@example.com"
|
||||
git config user.name "Test Robot"
|
||||
git remote add target dokku@dokku.me:$TEST_APP
|
||||
echo "setting up remote: $GIT_REMOTE"
|
||||
git remote add target $GIT_REMOTE
|
||||
|
||||
[[ -f gitignore ]] && mv gitignore .gitignore
|
||||
git add .
|
||||
git commit -m 'initial commit'
|
||||
git push target master || destroy_app
|
||||
git push target master || destroy_app $?
|
||||
}
|
||||
|
||||
setup_client_repo() {
|
||||
TMP=$(mktemp -d -t "$TARGET.XXXXX")
|
||||
TMP=$(mktemp -d -t "dokku.me.XXXXX")
|
||||
rmdir $TMP && cp -r ./tests/apps/nodejs-express $TMP
|
||||
cd $TMP
|
||||
git init
|
||||
@@ -156,3 +161,63 @@ disable_tls_wildcard() {
|
||||
-e "s:^ssl_certificate_key $DOKKU_ROOT/tls/server.key;:# ssl_certificate_key $DOKKU_ROOT/tls/server.key;:g" /etc/nginx/conf.d/dokku.conf
|
||||
kill -HUP "$(< /var/run/nginx.pid)"; sleep 5
|
||||
}
|
||||
|
||||
custom_ssl_nginx_template() {
|
||||
APP="$1"
|
||||
[[ -z "$APP" ]] && APP="$TEST_APP"
|
||||
cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf.template
|
||||
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;
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
custom_nginx_template() {
|
||||
APP="$1"
|
||||
[[ -z "$APP" ]] && APP="$TEST_APP"
|
||||
cat<<EOF > $DOKKU_ROOT/$APP/nginx.conf.template
|
||||
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;
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user