diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..0ef019adc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +*Dockerfile +.dockerignore +.git +.vagrant +contrib +docs +tests +!contrib/dokku-installer.py diff --git a/.gitignore b/.gitignore index 033d317f2..2794757ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.deb +*.rpm .DS_Store .ruby-version .vagrant diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1599d2c3d..4e8a25fde 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ doesn't already include that problem or suggestion before submitting an issue. If you find a match, add a quick "+1" or "I have this problem too." Doing this helps prioritize the most common problems and requests. -When reporting issues, please include your host OS (Ubuntu 14.04, Fedora 19, +When reporting issues, please include your host OS (Ubuntu 14.04, CentOS 7, etc). Please include: * The output of `uname -a`. diff --git a/HISTORY.md b/HISTORY.md index 601a8ac7f..e49a57fe3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,67 @@ # History +## 0.8.0 + +The big kahuna. Lots of documentation changes, and a few bug fixes to make Dokku development a bit easier. + +CentOS 7 users will be happy to see that we now have experimental support for your operating system. Huge thanks to @ebeigarts for working on that feature :) + +Thanks to all the contributors who helped with this release! + +### Bug Fixes + +- #2407: @josegonzalez Move core post-deploy triggers to core-post-deploy +- #2442: @znz Fix `is_tag_force_available` bug when docker major version up +- #2452: @mbtamuli Solves SSH Key problem when admin user already exists +- #2454: @onbjerg Return exit 1 in config:get if no ENV file exists +- #2464: @sseemayer Remove duplicate SSL hostnames +- #2465: @polettix Fix issue when importing ssh-keys +- #2477: @ebeigarts Fix dokku-redeploy systemd script to start only after docker +- #2485: @znz Fix bug when VHOST file is missing newline +- #2492: @josegonzalez Fix iteration on all apps for `dokku proxy` command +- #2495: @josegonzalez Create the user's `authorized_keys` file if it does not exist +- #2496: @josegonzalez Detect nginx versions that support HTTP/2 well +- #2518: @josegonzalez Use same check for dockerfile apps during a tar build +- #2526: @michaelshobbs Actually fail deploy when app.json script fails +- #2539: @ebeigarts Fix dokku-installer.service removal + +### New Features + +- #2378: @knjcode Skip container finish processing when zero downtime is disabled +- #2406: @josegonzalez Use apps_create method when renaming an application +- #2419: @ebeigarts Support for CentOS 7 +- #2489: @joshmanders Add plugin uninstall trigger +- #2510: @IlyaSemenov Add domains:set and domains:set-global commands +- #2544: @michaelshobbs Update herokuish to 0.3.24 +- #2552: @josegonzalez Allow package building on OSX +- #2553: @josegonzalez Add release-related Dockerfiles + +### Documentation + +- #2432: @josegonzalez Clarify DOKKU_SCALE docs +- #2433: @alexgleason Add robots.txt plugin to community docs +- #2437: @vishnubhagwan Fix warning in installation docs +- #2451: @mbtamuli Document the logs plugin +- #2470: @fteychene Add build-hook to plugins doc +- #2472: @mainto Add dokku-access to plugins doc +- #2484: @nahtnam Document build issues when a `Killed` message is displayed +- #2486: @OmarShehata Fixing typo & broken link in docs +- #2488: @joshmanders Bump font size in documentation +- #2493: @josegonzalez Clarify checks documentation +- #2497: @joshmanders Make features heading more clear +- #2503: @mlebkowski Update dokku-acl plugin link +- #2505: @kjschulz Add Dokku Wordpress plugin to docs +- #2506: @simonkotwicz Fix typos in deployment docs +- #2507: @josegonzalez Update upgrade docs to point out sshcommand and plugn upgrading as well +- #2509: @kjschulz Map dokku-community user in plugins +- #2511: @IlyaSemenov Clarify instructions for arranging default nginx site +- #2515: @sgloutnikov Update DreamHost Cloud install instructions +- #2517: @josegonzalez Update docs regarding if the ssh-keys plugin should be in use +- #2522: @joshmanders Ensure install documentation can be run via copy-paste +- #2525: @OmarShehata Plugin-triggers typo: dokkku -> dokku +- #2531: @slava-vishnyakov Document rebuilding app after mounting storage +- #2533: @facundomedica Document potential firewall problem on Ubuntu 16.04 + ## 0.7.2 This minor release contains mostly documentation changes, and should be fully backwards compatible with previous 0.7.x releases. diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 0917e8bcc..c83340e33 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -3,6 +3,8 @@ Description of problem: Output of the following commands + + - `uname -a`: - `free -m`: - `docker version`: diff --git a/Makefile b/Makefile index fb4beee80..64c86a5f3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -DOKKU_VERSION = master +DOKKU_VERSION ?= master SSHCOMMAND_URL ?= https://raw.githubusercontent.com/dokku/sshcommand/v0.6.0/sshcommand PLUGN_URL ?= https://github.com/dokku/plugn/releases/download/v0.2.2/plugn_0.2.2_linux_x86_64.tgz @@ -27,6 +27,7 @@ endif include tests.mk include deb.mk +include rpm.mk include arch.mk all: @@ -34,13 +35,17 @@ all: install: dependencies version copyfiles plugin-dependencies plugins -release: deb-all package_cloud packer +release: deb-all rpm-all package_cloud packer package_cloud: package_cloud push dokku/dokku/ubuntu/trusty herokuish*.deb package_cloud push dokku/dokku/ubuntu/trusty sshcommand*.deb package_cloud push dokku/dokku/ubuntu/trusty plugn*.deb package_cloud push dokku/dokku/ubuntu/trusty dokku*.deb + package_cloud push dokku/dokku/el/7 herokuish*.rpm + package_cloud push dokku/dokku/el/7 sshcommand*.rpm + package_cloud push dokku/dokku/el/7 plugn*.rpm + package_cloud push dokku/dokku/el/7 dokku*.rpm packer: packer build contrib/packer.json @@ -65,13 +70,17 @@ copyfiles: chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} || true $(MAKE) addman -addman: help2man +addman: help2man man-db mkdir -p /usr/local/share/man/man1 help2man -Nh help -v version -n "configure and get information from your dokku installation" -o /usr/local/share/man/man1/dokku.1 dokku mandb version: +ifeq ($(DOKKU_VERSION),master) git describe --tags > ~dokku/VERSION 2> /dev/null || echo '~${DOKKU_VERSION} ($(shell date -uIminutes))' > ~dokku/VERSION +else + echo $(DOKKU_VERSION) > ~dokku/VERSION +endif plugin-dependencies: plugn sudo -E dokku plugin:install-dependencies --core diff --git a/README.md b/README.md index 1d09d0e46..c2b73d82c 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,26 @@ Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. ## Requirements -A fresh VM running any one of -- `Debian 8.2 x64` -- `Ubuntu 14.04 x64` -- `Ubuntu 16.04 x64` +A fresh VM running any of the following operating systems: + +- Ubuntu 16.04 x64 +- Ubuntu 14.04 x64 +- Debian 8.2 x64 +- CentOS 7 x64 *(experimental)* +- Arch Linux x64 *(experimental)* ## Installation To install the latest stable release, run the following commands as a user who has access to `sudo`: -``` -wget https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh -sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh +```shell +wget https://raw.githubusercontent.com/dokku/dokku/v0.8.0/bootstrap.sh +sudo DOKKU_TAG=v0.8.0 bash bootstrap.sh ``` You can then proceed to the ip address or domain name associated with your server to complete the web-based installation. -If you wish for a more unattended installation method, you can see [these](http://dokku.viewdocs.io/dokku/getting-started/install/debian/#unattended-installation) docs. +If you wish for a more unattended installation method, see [these](http://dokku.viewdocs.io/dokku/getting-started/install/debian/#unattended-installation) docs. ### Upgrade diff --git a/Vagrantfile b/Vagrantfile index 4f3fc6c60..53f578c8d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -76,13 +76,22 @@ Vagrant::configure("2") do |config| vm.vm.provision :shell, :inline => "cd /root/dokku && make install-from-deb" end + config.vm.define "dokku-rpm", autostart: false do |vm| + vm.vm.box = "centos/7" + vm.vm.synced_folder File.dirname(__FILE__), "/root/dokku" + 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 && bash bootstrap.sh" + end + config.vm.define "build", autostart: false do |vm| vm.vm.synced_folder File.dirname(__FILE__), "/root/dokku" 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 => "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 => "export IS_RELEASE=true && cd /root/dokku && make deb-all" + vm.vm.provision :shell, :inline => "export IS_RELEASE=true && cd /root/dokku && make deb-all rpm-all" end config.vm.define "build-arch", autostart: false do |vm| diff --git a/arch.mk b/arch.mk index c9b9159a5..c10f17186 100644 --- a/arch.mk +++ b/arch.mk @@ -22,7 +22,11 @@ arch-setup: arch-dokku: arch-setup echo "-> Update package sums, create metadata file and test the build of the package" +ifeq ($(DOKKU_VERSION),master) git describe --tags > /tmp/VERSION +else + echo $(DOKKU_VERSION) > /tmp/VERSION +endif cat /tmp/VERSION | cut -d '-' -f 1 | cut -d 'v' -f 2 > /tmp/STABLE_VERSION sed -i -e "s/pkgver=.*/pkgver=`cat /tmp/STABLE_VERSION`/" /dokku-arch/PKGBUILD cd /dokku-arch; updpkgsums; mksrcinfo; makepkg -fd diff --git a/bootstrap.sh b/bootstrap.sh index b5aacb6ff..b787f47d0 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -14,10 +14,6 @@ set -eo pipefail; [[ $TRACE ]] && set -x ensure-environment() { local FREE_MEMORY echo "Preparing to install $DOKKU_TAG from $DOKKU_REPO..." - if ! command -v apt-get &>/dev/null; then - echo "This installation script requires apt-get. For manual installation instructions, consult http://dokku.viewdocs.io/dokku/advanced-installation/" - exit 1 - fi hostname -f > /dev/null 2>&1 || { echo "This installation script requires that you have a hostname set for the instance. Please set a hostname for 127.0.0.1 in your /etc/hosts" @@ -33,10 +29,15 @@ ensure-environment() { install-requirements() { echo "--> Ensuring we have the proper dependencies" - apt-get update -qq > /dev/null - if [[ $(lsb_release -sr) == "12.04" ]]; then - apt-get -qq -y install python-software-properties - fi + + case "$DOKKU_DISTRO" in + debian|ubuntu) + apt-get update -qq > /dev/null + if [[ "$DOKKU_DISTRO_VERSION" == "12.04" ]]; then + apt-get -qq -y install python-software-properties + fi + ;; + esac } install-dokku() { @@ -68,9 +69,14 @@ install-dokku() { fi } - install-dokku-from-source() { local DOKKU_CHECKOUT="$1" + + if ! command -v apt-get &>/dev/null; then + echo "This installation script requires apt-get. For manual installation instructions, consult http://dokku.viewdocs.io/dokku/advanced-installation/" + exit 1 + fi + apt-get -qq -y install git make software-properties-common cd /root if [[ ! -d /root/dokku ]]; then @@ -84,6 +90,21 @@ install-dokku-from-source() { } install-dokku-from-package() { + case "$DOKKU_DISTRO" in + debian|ubuntu) + install-dokku-from-deb-package "$@" + ;; + centos) + install-dokku-from-rpm-package "$@" + ;; + *) + echo "Unsupported Linux distribution. For manual installation instructions, consult http://dokku.viewdocs.io/dokku/advanced-installation/" + exit 1 + ;; + esac +} + +install-dokku-from-deb-package() { local DOKKU_CHECKOUT="$1" local NO_INSTALL_RECOMMENDS=${DOKKU_NO_INSTALL_RECOMMENDS:=""} @@ -124,7 +145,39 @@ install-dokku-from-package() { fi } +install-dokku-from-rpm-package() { + local DOKKU_CHECKOUT="$1" + + if [[ "$DOKKU_DISTRO_VERSION" != "7" ]]; then + echo "Only CentOS version 7 is supported." + exit 1 + fi + + echo "--> Installing docker" + curl -fsSL https://get.docker.com/ | sh + + echo "--> Installing epel for nginx packages to be available" + yum install -y epel-release + + echo "--> Installing herokuish and dokku" + curl -s https://packagecloud.io/install/repositories/dokku/dokku/script.rpm.sh | bash + if [[ -n $DOKKU_CHECKOUT ]]; then + yum -y install herokuish "dokku-$DOKKU_CHECKOUT" + else + yum -y install herokuish dokku + fi + + echo "--> Starting nginx" + systemctl start nginx +} + main() { + export DOKKU_DISTRO DOKKU_DISTRO_VERSION + # shellcheck disable=SC1091 + DOKKU_DISTRO=$(. /etc/os-release && echo "$ID") + # shellcheck disable=SC1091 + DOKKU_DISTRO_VERSION=$(. /etc/os-release && echo "$VERSION_ID") + export DEBIAN_FRONTEND=noninteractive export DOKKU_REPO=${DOKKU_REPO:-"https://github.com/dokku/dokku.git"} diff --git a/contrib/build-centos.Dockerfile b/contrib/build-centos.Dockerfile new file mode 100644 index 000000000..95473c10d --- /dev/null +++ b/contrib/build-centos.Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +RUN apt-get -qq -y install gcc git build-essential wget ruby-dev ruby1.9.1 lintian rpm help2man man-db + +RUN command -v fpm > /dev/null || sudo gem install fpm --no-ri --no-rdoc + +WORKDIR /dokku + +COPY Makefile /dokku/ + +COPY *.mk /dokku/ + +RUN make deb-setup rpm-setup + +COPY . /dokku + +RUN make sshcommand plugn version copyfiles + +ARG DOKKU_VERSION=master +ENV DOKKU_VERSION ${DOKKU_VERSION} + +ARG DOKKU_GIT_REV +ENV DOKKU_GIT_REV ${DOKKU_GIT_REV} + +ARG IS_RELEASE=false +ENV IS_RELEASE ${IS_RELEASE} + +RUN make rpm-herokuish rpm-dokku rpm-plugn rpm-sshcommand rpm-sigil + +RUN mkdir -p /data && cp /tmp/*.rpm /data && ls /data/ diff --git a/contrib/build-ubuntu.Dockerfile b/contrib/build-ubuntu.Dockerfile new file mode 100644 index 000000000..a5c9892cb --- /dev/null +++ b/contrib/build-ubuntu.Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +RUN apt-get -qq -y install gcc git build-essential wget ruby-dev ruby1.9.1 lintian rpm help2man man-db + +RUN command -v fpm > /dev/null || sudo gem install fpm --no-ri --no-rdoc + +WORKDIR /dokku + +COPY Makefile /dokku/ + +COPY *.mk /dokku/ + +RUN make deb-setup rpm-setup + +COPY . /dokku + +RUN make sshcommand plugn version copyfiles + +ARG DOKKU_VERSION=master +ENV DOKKU_VERSION ${DOKKU_VERSION} + +ARG DOKKU_GIT_REV +ENV DOKKU_GIT_REV ${DOKKU_GIT_REV} + +ARG IS_RELEASE=false +ENV IS_RELEASE ${IS_RELEASE} + +RUN make deb-herokuish deb-dokku deb-plugn deb-sshcommand deb-sigil + +RUN mkdir -p /data && cp /tmp/*.deb /data && ls /data/ diff --git a/contrib/dokku-installer.py b/contrib/dokku-installer.py index b57cf3b63..67380722f 100755 --- a/contrib/dokku-installer.py +++ b/contrib/dokku-installer.py @@ -3,13 +3,14 @@ import cgi import json import os +import re import SimpleHTTPServer import SocketServer import subprocess import sys import threading -VERSION = 'v0.7.2' +VERSION = 'v0.8.0' hostname = '' try: @@ -100,8 +101,20 @@ class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): with open('{0}/HOSTNAME'.format(dokku_root), 'w') as f: f.write(params['hostname'].value) - command = ['sshcommand', 'acl-add', 'dokku', 'admin'] - for key in params['keys'].value.split("\n"): + for (index, key) in enumerate(params['keys'].value.splitlines(), 1): + user = 'admin' + if self.admin_user_exists() is not None: + user = 'web-admin' + if self.web_admin_user_exists() is not None: + index = int(self.web_admin_user_exists()) + 1 + elif self.web_admin_user_exists() is None: + index = 1 + elif self.admin_user_exists() is None: + pass + else: + index = int(self.admin_user_exists()) + 1 + user = user + str(index) + command = ['sshcommand', 'acl-add', 'dokku', user] proc = subprocess.Popen(command, stdin=subprocess.PIPE) proc.stdin.write(key) proc.stdin.close() @@ -119,6 +132,29 @@ class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.end_headers() self.wfile.write(json.dumps({'status': 'ok'})) + def web_admin_user_exists(self): + return self.user_exists('web-admin(\d+)') + + def admin_user_exists(self): + return self.user_exists('admin(\d+)') + + def user_exists(self, name): + command = 'dokku ssh-keys:list' + pattern = re.compile(r'NAME="' + name + '"') + proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) + max_num = 0 + exists = False + for line in proc.stdout: + m = pattern.search(line) + if m: + # User of the form `user` or `user#` exists + exists = True + max_num = max(max_num, m.group(1)) + if exists: + return max_num + else: + return None + def set_debconf_selection(debconf_type, key, value): found = False diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index 6ed95a804..45267ae12 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +export DOKKU_PORT=${DOKKU_PORT:=22} +export DOKKU_HOST=${DOKKU_HOST:=} -MOVES=(ABLE ABNORMA AGAIN AIREXPL ANG ANGER ASAIL ATTACK AURORA AWL BAN BAND BARE BEAT BEATED BELLY BIND BITE BLOC BLOOD BODY BOOK BREATH BUMP CAST CHAM CLAMP CLAP CLAW CLEAR CLI CLIP CLOUD CONTRO CONVY COOLHIT CRASH CRY CUT DESCRI D-FIGHT DIG DITCH DIV DOZ DRE DUL DU-PIN DYE EARTH EDU EG-BOMB EGG ELEGY ELE-HIT EMBODY EMPLI ENGL ERUPT EVENS EXPLOR EYES FALL FAST F-CAR F-DANCE FEARS F-FIGHT FIGHT FIR FIRE FIREHIT FLAME FLAP FLASH FLEW FORCE FRA FREEZE FROG G-BIRD GENKISS GIFT G-KISS G-MOUSE GRADE GROW HAMMER HARD HAT HATE H-BOMB HELL-R HEMP HINT HIT HU HUNT HYPNOSI INHA IRO IRONBAR IR-WING J-GUN KEE KICK KNIF KNIFE KNOCK LEVEL LIGH LIGHHIT LIGHT LIVE L-WALL MAD MAJUS MEL MELO MESS MILK MIMI MISS MIXING MOVE MUD NI-BED NOISY NOONLI NULL N-WAVE PAT PEACE PIN PLAN PLANE POIS POL POWDE POWE POWER PRIZE PROTECT PROUD RAGE RECOR REFLAC REFREC REGR RELIV RENEW R-FIGHT RING RKICK ROCK ROUND RUS RUSH SAND SAW SCISSOR SCRA SCRIPT SEEN SERVER SHADOW SHELL SHINE SHO SIGHT SIN SMALL SMELT SMOK SNAKE SNO SNOW SOU SO-WAVE SPAR SPEC SPID S-PIN SPRA STAM STARE STEA STONE STORM STRU STRUG STUDEN SUBS SUCID SUN-LIG SUNRIS SUPLY S-WAVE TAILS TANGL TASTE TELLI THANK TONKICK TOOTH TORL TRAIN TRIKICK TUNGE VOLT WA-GUN WATCH WAVE W-BOMB WFALL WFING WHIP WHIRL WIND WOLF WOOD WOR YUJA) -NAMES=(SEED GRASS FLOWE SHAD CABR SNAKE GOLD COW GUIKI PEDAL DELAN B-FLY BIDE KEYU FORK LAP PIGE PIJIA CAML LAT BIRD BABOO VIV ABOKE PIKAQ RYE SAN BREAD LIDEL LIDE PIP PIKEX ROK JUGEN PUD BUDE ZHIB GELU GRAS FLOW LAFUL ATH BALA CORN MOLUF DESP DAKED MIMI BOLUX KODA GELUD MONK SUMOY GEDI WENDI NILEM NILE NILEC KEZI YONGL HUDE WANLI GELI GUAIL MADAQ WUCI WUCI MUJEF JELLY SICIB GELU NELUO BOLI JIALE YED YEDE CLO SCARE AOCO DEDE DEDEI BAWU JIUG BADEB BADEB HOLE BALUX GES FANT QUAR YIHE SWAB SLIPP CLU DEPOS BILIY YUANO SOME NO YELA EMPT ZECUN XIAHE BOLEL DEJI MACID XIHON XITO LUCK MENJI GELU DECI XIDE DASAJ DONGN RICUL MINXI BALIY ZENDA LUZEL HELE5 0FENB KAIL JIAND CARP JINDE LAPU MUDE YIFU LINLI SANDI HUSI JINC OUMU OUMUX CAP KUIZA PUD TIAO FRMAN CLAU SPARK DRAGO BOLIU GUAIL MIYOU MIY QIAOK BEIL MUKEI RIDED MADAM BAGEP CROC ALIGE OUDAL OUD DADA HEHE YEDEA NUXI NUXIN ROUY ALIAD STICK QIANG LAAND PIQI PI PUPI DEKE DEKEJ NADI NADIO MALI PEA ELECT FLOWE MAL MALI HUSHU NILEE YUZI POPOZ DUZI HEBA XIAN SHAN YEYEA WUY LUO KEFE HULA CROW YADEH MOW ANNAN SUONI KYLI HULU HUDEL YEHE GULAE YEHE BLU GELAN BOAT NIP POIT HELAK XINL BEAR LINB MAGEH MAGEJ WULI YIDE RIVE FISH AOGU DELIE MANTE KONMU DELU HELU HUAN HUMA DONGF JINCA HEDE DEFU LIBY JIAPA MEJI HELE BUHU MILK HABI THUN GARD DON YANGQ SANAQ BANQ LUJ PHIX SIEI EGG) - -random_number() { +fn-random-number() { [[ -n "$1" ]] && RANGE="$1" if [[ -n "$RANGE" ]]; then number=$RANDOM @@ -15,94 +14,141 @@ random_number() { echo $number } -random_name() { - NUM1=$(random_number ${#MOVES[@]}) - NUM2=$(random_number ${#MOVES[@]}) - NUM3=$(random_number ${#NAMES[@]}) +fn-random-name() { + local NUM1 NUM2 NUM3 UPPER_APPNAME lower_appname + local MOVES=(ABLE ABNORMA AGAIN AIREXPL ANG ANGER ASAIL ATTACK AURORA AWL BAN BAND BARE BEAT BEATED BELLY BIND BITE BLOC BLOOD BODY BOOK BREATH BUMP CAST CHAM CLAMP CLAP CLAW CLEAR CLI CLIP CLOUD CONTRO CONVY COOLHIT CRASH CRY CUT DESCRI D-FIGHT DIG DITCH DIV DOZ DRE DUL DU-PIN DYE EARTH EDU EG-BOMB EGG ELEGY ELE-HIT EMBODY EMPLI ENGL ERUPT EVENS EXPLOR EYES FALL FAST F-CAR F-DANCE FEARS F-FIGHT FIGHT FIR FIRE FIREHIT FLAME FLAP FLASH FLEW FORCE FRA FREEZE FROG G-BIRD GENKISS GIFT G-KISS G-MOUSE GRADE GROW HAMMER HARD HAT HATE H-BOMB HELL-R HEMP HINT HIT HU HUNT HYPNOSI INHA IRO IRONBAR IR-WING J-GUN KEE KICK KNIF KNIFE KNOCK LEVEL LIGH LIGHHIT LIGHT LIVE L-WALL MAD MAJUS MEL MELO MESS MILK MIMI MISS MIXING MOVE MUD NI-BED NOISY NOONLI NULL N-WAVE PAT PEACE PIN PLAN PLANE POIS POL POWDE POWE POWER PRIZE PROTECT PROUD RAGE RECOR REFLAC REFREC REGR RELIV RENEW R-FIGHT RING RKICK ROCK ROUND RUS RUSH SAND SAW SCISSOR SCRA SCRIPT SEEN SERVER SHADOW SHELL SHINE SHO SIGHT SIN SMALL SMELT SMOK SNAKE SNO SNOW SOU SO-WAVE SPAR SPEC SPID S-PIN SPRA STAM STARE STEA STONE STORM STRU STRUG STUDEN SUBS SUCID SUN-LIG SUNRIS SUPLY S-WAVE TAILS TANGL TASTE TELLI THANK TONKICK TOOTH TORL TRAIN TRIKICK TUNGE VOLT WA-GUN WATCH WAVE W-BOMB WFALL WFING WHIP WHIRL WIND WOLF WOOD WOR YUJA) + local NAMES=(SEED GRASS FLOWE SHAD CABR SNAKE GOLD COW GUIKI PEDAL DELAN B-FLY BIDE KEYU FORK LAP PIGE PIJIA CAML LAT BIRD BABOO VIV ABOKE PIKAQ RYE SAN BREAD LIDEL LIDE PIP PIKEX ROK JUGEN PUD BUDE ZHIB GELU GRAS FLOW LAFUL ATH BALA CORN MOLUF DESP DAKED MIMI BOLUX KODA GELUD MONK SUMOY GEDI WENDI NILEM NILE NILEC KEZI YONGL HUDE WANLI GELI GUAIL MADAQ WUCI WUCI MUJEF JELLY SICIB GELU NELUO BOLI JIALE YED YEDE CLO SCARE AOCO DEDE DEDEI BAWU JIUG BADEB BADEB HOLE BALUX GES FANT QUAR YIHE SWAB SLIPP CLU DEPOS BILIY YUANO SOME NO YELA EMPT ZECUN XIAHE BOLEL DEJI MACID XIHON XITO LUCK MENJI GELU DECI XIDE DASAJ DONGN RICUL MINXI BALIY ZENDA LUZEL HELE5 0FENB KAIL JIAND CARP JINDE LAPU MUDE YIFU LINLI SANDI HUSI JINC OUMU OUMUX CAP KUIZA PUD TIAO FRMAN CLAU SPARK DRAGO BOLIU GUAIL MIYOU MIY QIAOK BEIL MUKEI RIDED MADAM BAGEP CROC ALIGE OUDAL OUD DADA HEHE YEDEA NUXI NUXIN ROUY ALIAD STICK QIANG LAAND PIQI PI PUPI DEKE DEKEJ NADI NADIO MALI PEA ELECT FLOWE MAL MALI HUSHU NILEE YUZI POPOZ DUZI HEBA XIAN SHAN YEYEA WUY LUO KEFE HULA CROW YADEH MOW ANNAN SUONI KYLI HULU HUDEL YEHE GULAE YEHE BLU GELAN BOAT NIP POIT HELAK XINL BEAR LINB MAGEH MAGEJ WULI YIDE RIVE FISH AOGU DELIE MANTE KONMU DELU HELU HUAN HUMA DONGF JINCA HEDE DEFU LIBY JIAPA MEJI HELE BUHU MILK HABI THUN GARD DON YANGQ SANAQ BANQ LUJ PHIX SIEI EGG) - UPPER_APPNAME="${MOVES[${NUM1}]}-${MOVES[${NUM2}]}-${NAMES[${NUM3}]}" + NUM1=$(fn-random-number ${#MOVES[@]}) + NUM2=$(fn-random-number ${#MOVES[@]}) + NUM3=$(fn-random-number ${#NAMES[@]}) - [[ "$BASH_VERSION" =~ 4.* ]] && lower_appname=${UPPER_APPNAME,,} - [[ -z "$lower_appname" ]] && lower_appname=$(echo "$UPPER_APPNAME" | tr '[:upper:]' '[:lower:]') - echo "$lower_appname" + UPPER_APPNAME="${MOVES[${NUM1}]}-${MOVES[${NUM2}]}-${NAMES[${NUM3}]}" + + [[ "$BASH_VERSION" =~ 4.* ]] && lower_appname=${UPPER_APPNAME,,} + [[ -z "$lower_appname" ]] && lower_appname=$(echo "$UPPER_APPNAME" | tr '[:upper:]' '[:lower:]') + echo "$lower_appname" } -client_help_msg() { - echo "==> Configure the DOKKU_HOST environment variable or run $0 from a repository with a git remote named dokku" - echo "--> i.e. git remote add dokku dokku@:" +fn-client-help-msg() { + echo "==> Configure the DOKKU_HOST environment variable or run $0 from a repository with a git remote named dokku" 1>&2 + echo "--> i.e. git remote add dokku dokku@:" 1>&2 exit 20 # exit with specific status. only used in units tests for now } -is_git_repo() { - git rev-parse &>/dev/null +fn-is-git-repo() { + git rev-parse &>/dev/null } -has_dokku_remote() { - git remote show | grep dokku +fn-has-dokku-remote() { + git remote show | grep -E "^${DOKKU_GIT_REMOTE}\s" } -if [[ -z $DOKKU_HOST ]]; then - if [[ -d .git ]] || git rev-parse --git-dir > /dev/null 2>&1; then - DOKKU_HOST=$(git remote -v 2>/dev/null | grep -Ei "^dokku" | head -n 1 | cut -f1 -d' ' | cut -f2 -d '@' | cut -f1 -d':' 2>/dev/null || true) - else - client_help_msg +fn-dokku-host() { + declare DOKKU_GIT_REMOTE="$1" DOKKU_HOST="$2" + + if [[ -z "$DOKKU_HOST" ]]; then + if [[ -d .git ]] || git rev-parse --git-dir > /dev/null 2>&1; then + DOKKU_HOST=$(git remote -v 2>/dev/null | grep -Ei "^${DOKKU_GIT_REMOTE}\s" | head -n 1 | cut -f1 -d' ' | cut -f2 -d '@' | cut -f1 -d':' 2>/dev/null || true) + fi fi -fi -export DOKKU_PORT=${DOKKU_PORT:=22} + if [[ -z "$DOKKU_HOST" ]]; then + fn-client-help-msg + fi + + echo "$DOKKU_HOST" +} -if [[ ! -z $DOKKU_HOST ]]; then - _dokku() { - appname="" +main() { + declare CMD="$1" APP_ARG="$2" + local APP="" DOKKU_GIT_REMOTE="dokku" DOKKU_REMOTE_HOST="" + local cmd_set=false arg_set="$2" next_index=1 skip=false args=("$@") + + for arg in "$@"; do + if [[ "$skip" == "true" ]]; then + next_index=$(( next_index + 1 )) + skip=false + continue + fi + + if [[ "$arg" == "--app" ]]; then + APP=${args[$next_index]} + skip=true + shift 2 + elif [[ "$arg" == "--remote" ]]; then + DOKKU_GIT_REMOTE=${args[$next_index]} + skip=true + shift 2 + elif [[ "$arg" =~ ^--.* ]]; then + [[ "$cmd_set" == "true" ]] && APP_ARG="$arg" && break + [[ "$arg" == "--trace" ]] && export DOKKU_TRACE=1 && set -x + else + if [[ "$cmd_set" == "true" ]]; then + APP_ARG="$arg" + break + else + CMD="$arg" + cmd_set=true + fi + fi + next_index=$(( next_index + 1 )) + done + + DOKKU_REMOTE_HOST="$(fn-dokku-host "$DOKKU_GIT_REMOTE" "$DOKKU_HOST")" + + if [[ -z "$APP" ]]; then if [[ -d .git ]] || git rev-parse --git-dir > /dev/null 2>&1; then set +e - appname=$(git remote -v 2>/dev/null | grep -Ei "dokku@$DOKKU_HOST" | head -n 1 | cut -f2 -d'@' | cut -f1 -d' ' | cut -f2 -d':' 2>/dev/null) + APP=$(git remote -v 2>/dev/null | grep -Ei "dokku@$DOKKU_REMOTE_HOST" | head -n 1 | cut -f2 -d'@' | cut -f1 -d' ' | cut -f2 -d':' 2>/dev/null) set -e else echo "This is not a git repository" fi - - case "$1" in - apps:create) - if [[ -z "$2" ]]; then - appname=$(random_name) - counter=0 - while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do - if [[ $counter -ge 100 ]]; then - echo "Error: could not reasonably generate a new app name. try cleaning up some apps..." - ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps - exit 1 - else - appname=$(random_name) - counter=$((counter+1)) - fi - done - else - appname="$2" - fi - if git remote add dokku "dokku@$DOKKU_HOST:$appname"; then - echo "-----> Dokku remote added at $DOKKU_HOST" - echo "-----> Application name is $appname" - else - echo "! Dokku remote not added! Do you already have a dokku remote?" - return - fi - ;; - apps:destroy) - is_git_repo && has_dokku_remote && git remote remove dokku - ;; - esac - - [[ -n "$@" ]] && [[ -n "$appname" ]] && app_arg="--app $appname" - # echo "ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_HOST -- $app_arg $@" - # shellcheck disable=SC2068,SC2086 - ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_HOST -- $app_arg $@ - } - - if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then - _dokku "$@" - exit $? fi -else - client_help_msg + + case "$CMD" in + apps:create) + if [[ -z "$APP_ARG" ]]; then + APP=$(fn-random-name) + counter=0 + while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_REMOTE_HOST" apps 2>/dev/null| grep -q "$APP"; do + if [[ $counter -ge 100 ]]; then + echo "Error: could not reasonably generate a new app name. try cleaning up some apps..." + ssh -p "$DOKKU_PORT" "dokku@$DOKKU_REMOTE_HOST" apps + exit 1 + else + APP=$(random_name) + counter=$((counter+1)) + fi + done + else + APP="$APP_ARG" + fi + if git remote add dokku "dokku@$DOKKU_REMOTE_HOST:$APP"; then + echo "-----> Dokku remote added at ${DOKKU_REMOTE_HOST} called ${DOKKU_GIT_REMOTE}" + echo "-----> Application name is ${APP}" + else + echo "! Dokku remote not added! Do you already have a dokku remote?" + return + fi + ;; + apps:destroy) + fn-is-git-repo && fn-has-dokku-remote && git remote remove "$DOKKU_GIT_REMOTE" + ;; + esac + + [[ " apps certs help ls nginx shell storage trace version " == *" $CMD "* ]] && unset APP + [[ " certs:chain domains:add-global domains:remove-global domains:set-global ps:rebuildall ps:restartall ps:restore " == *" $CMD "* ]] && unset APP + [[ "$CMD" =~ events*|plugin*|ssh-keys* ]] && unset APP + [[ -n "$APP_ARG" ]] && [[ "$APP_ARG" == "--global" ]] && unset APP + [[ -n "$@" ]] && [[ -n "$APP" ]] && app_arg="--app $APP" + # echo "ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_REMOTE_HOST -- $app_arg $@" + # shellcheck disable=SC2068,SC2086 + ssh -o LogLevel=QUIET -p $DOKKU_PORT -t dokku@$DOKKU_REMOTE_HOST -- $app_arg $@ +} + +if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then + main "$@" + exit $? fi diff --git a/deb.mk b/deb.mk index f9f9c52ac..eac9a9ced 100644 --- a/deb.mk +++ b/deb.mk @@ -1,6 +1,6 @@ HEROKUISH_DESCRIPTION = 'Herokuish uses Docker and Buildpacks to build applications like Heroku' HEROKUISH_REPO_NAME ?= gliderlabs/herokuish -HEROKUISH_VERSION ?= 0.3.19 +HEROKUISH_VERSION ?= 0.3.24 HEROKUISH_ARCHITECTURE = amd64 HEROKUISH_PACKAGE_NAME = herokuish_$(HEROKUISH_VERSION)_$(HEROKUISH_ARCHITECTURE).deb @@ -128,14 +128,22 @@ deb-dokku: cp /usr/local/share/man/man1/dokku.1 /tmp/build/usr/share/man/man1/dokku.1 gzip -9 /tmp/build/usr/share/man/man1/dokku.1 cp contrib/dokku-installer.py /tmp/build/usr/share/dokku/contrib +ifeq ($(DOKKU_VERSION),master) git describe --tags > /tmp/build/var/lib/dokku/VERSION +else + echo $(DOKKU_VERSION) > /tmp/build/var/lib/dokku/VERSION +endif cat /tmp/build/var/lib/dokku/VERSION | cut -d '-' -f 1 | cut -d 'v' -f 2 > /tmp/build/var/lib/dokku/STABLE_VERSION ifneq (,$(findstring false,$(IS_RELEASE))) sed -i.bak -e "s/^/`date +%s`:/" /tmp/build/var/lib/dokku/STABLE_VERSION && rm /tmp/build/var/lib/dokku/STABLE_VERSION.bak endif rm /tmp/build/DEBIAN/lintian-overrides mv debian/lintian-overrides /tmp/build/usr/share/lintian/overrides/dokku +ifdef DOKKU_GIT_REV + echo "$(DOKKU_GIT_REV)" > /tmp/build/var/lib/dokku/GIT_REV +else git rev-parse HEAD > /tmp/build/var/lib/dokku/GIT_REV +endif sed -i "s/^Version: .*/Version: `cat /tmp/build/var/lib/dokku/STABLE_VERSION`/g" /tmp/build/DEBIAN/control dpkg-deb --build /tmp/build "/tmp/dokku_`cat /tmp/build/var/lib/dokku/STABLE_VERSION`_$(DOKKU_ARCHITECTURE).deb" lintian "/tmp/dokku_`cat /tmp/build/var/lib/dokku/STABLE_VERSION`_$(DOKKU_ARCHITECTURE).deb" diff --git a/debian/control b/debian/control index f8c628bb2..d88270c1a 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: dokku -Version: 0.7.2 +Version: 0.8.0 Section: web Priority: optional Architecture: amd64 diff --git a/debian/postrm b/debian/postrm index 859fec170..2ddc84de9 100755 --- a/debian/postrm +++ b/debian/postrm @@ -11,13 +11,13 @@ readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" readonly DOKKU_LOGS_DIR="${DOKKU_LOGS_DIR:="/var/log/dokku"}" main() { - if [[ -f /etc/systemd/system/dokku-installer.conf ]] || [[ -f /etc/init/dokku-installer.conf ]]; then + if [[ -f /etc/systemd/system/dokku-installer.service ]] || [[ -f /etc/init/dokku-installer.conf ]]; then service dokku-installer stop || true fi rm -f /etc/init/dokku-installer.conf rm -f /etc/init/dokku-redeploy.conf - rm -f /etc/systemd/system/dokku-installer.conf + rm -f /etc/systemd/system/dokku-installer.service rm -f /etc/systemd/system/dokku-redeploy.service rm -f /etc/update-motd.d/99-dokku diff --git a/docs/advanced-usage/deployment-tasks.md b/docs/advanced-usage/deployment-tasks.md index 0a42f4edf..64ee09625 100644 --- a/docs/advanced-usage/deployment-tasks.md +++ b/docs/advanced-usage/deployment-tasks.md @@ -15,7 +15,8 @@ Dokku accomplishes this by using an `app.json` file. The format in use is simila However, Dokku currently only supports the nodes `scripts.dokku.predeploy` and `scripts.dokku.postdeploy`. For buildpack apps, simply place an `app.json` file in the root of your repository. For dockerfile apps, place `app.json` in the configured `WORKDIR` directory; otherwise Dokku defaults to the buildpack app behavior of looking in `/app`. ->NOTE: postdeploy changes are *NOT* committed to the app image. + +> NOTE: postdeploy changes are *NOT* committed to the app image. ### Example app.json diff --git a/docs/advanced-usage/docker-options.md b/docs/advanced-usage/docker-options.md index cd6261ae8..d66650fee 100644 --- a/docs/advanced-usage/docker-options.md +++ b/docs/advanced-usage/docker-options.md @@ -77,4 +77,4 @@ The above example will result in the following options being passed to Docker du You may also include comments (lines beginning with a #) and blank lines in the DOCKER_OPTIONS file. -Move information on Docker options can be found here: http://docs.docker.io/en/latest/reference/run/ . +More information on Docker options can be found here: https://docs.docker.com/engine/reference/commandline/run/. diff --git a/docs/advanced-usage/persistent-storage.md b/docs/advanced-usage/persistent-storage.md index 88348290f..4cf00aafe 100644 --- a/docs/advanced-usage/persistent-storage.md +++ b/docs/advanced-usage/persistent-storage.md @@ -11,34 +11,44 @@ storage:mount # Create a new bind mount storage:unmount # Remove an existing bind mount ``` +> The storage plugin is compatible with storage mounts created with the docker-options. The storage plugin will only list mounts from the deploy/run phase. + ## Ideology and Background The storage plugin requires explicit paths on the host side. This is intentional to ensure that new users avoid running into unexpected results with implicit paths that may not exist (a feature deprecate in [Docker 1.9.0](https://github.com/docker/docker/releases/tag/v1.9.0])). The container directory is created for the mount point in the container. Any existing directory contents are not accessible after a mount is added to the container. Dokku creates a new directory `/var/lib/dokku/data/storage` during installation, it's the general consensus that new users should use this directory. Mounts are only available at run and deploy times, you must redeploy (restart) an app to mount or unmount to an existing app's container. ## Usage -This example demonstrates how to mount the recommended directory to `/storage` inside the container: +This example demonstrates how to mount the recommended directory to `/storage` inside an application called `node-js-app`: ```shell -dokku storage:mount app-name /var/lib/dokku/data/storage:/storage +# we use a subdirectory inside of the host directory to scope it to just the app +dokku storage:mount node-js-app /var/lib/dokku/data/storage/node-js-app:/storage ``` Dokku will then mount the shared contents of `/var/lib/dokku/data/storage` to `/storage` inside the container. +Once you have mounted persistent storage, you will also need to restart the application. See the +[process scaling documentation](/dokku/deployment/process-management) for more information. + +```shell +dokku ps:rebuild app-name +``` + A more complete workflow may require making a custom directory for your application and mounting it within your `/app/storage` directory instead. The mount point is *not* relative to your application's working directory, and is instead relative to the root of the container. ```shell -# creating storage for the app 'ruby-rails-sample' -mkdir -p /var/lib/dokku/data/storage/ruby-rails-sample +# creating storage for the app 'node-js-app' +mkdir -p /var/lib/dokku/data/storage/node-js-app # ensure the proper user has access to this directory -chown -R dokku:dokku /var/lib/dokku/data/storage/ruby-rails-sample +chown -R dokku:dokku /var/lib/dokku/data/storage/node-js-app # as of 0.7.x, you should chown using the `32767` user and group id -chown -R 32767:32767 /var/lib/dokku/data/storage/ruby-rails-sample +chown -R 32767:32767 /var/lib/dokku/data/storage/node-js-app # mount the directory into your container's /app/storage directory, relative to root -dokku storage:mount app-name /var/lib/dokku/data/storage/app-name:/app/storage +dokku storage:mount app-name /var/lib/dokku/data/storage/node-js-app:/app/storage ``` You can mount one or more directories as desired by following the above pattern. @@ -73,15 +83,10 @@ You cannot use mounted volumes during the build phase of a Dockerfile deploy. Th > Note: **This can cause data loss** if you bind a mount under `/app` in buildpack apps as herokuish will attempt to remove the original app path during the build phase. -## Docker-Options Note - -The storage plugin is compatible with storage mounts created with the docker-options. The storage plugin will only list mounts from the deploy phase. - +## Application User and Persistent Storage file ownership (buildpack apps only) > New as of 0.7.1 -## Application User and Persistent Storage file ownership (buildpack apps only) - By default, Dokku will execute your buildpack application processes as the `herokuishuser` user. You may override this by setting the `DOKKU_APP_USER` config variable. > NOTE: this user must exist in your herokuish image. diff --git a/docs/advanced-usage/plugin-management.md b/docs/advanced-usage/plugin-management.md index 985b386ae..3ac658310 100644 --- a/docs/advanced-usage/plugin-management.md +++ b/docs/advanced-usage/plugin-management.md @@ -31,30 +31,30 @@ dokku plugin ``` plugn: dev - 00_dokku-standard 0.7.2 enabled dokku core standard plugin - 20_events 0.7.2 enabled dokku core events logging plugin - apps 0.7.2 enabled dokku core apps plugin - build-env 0.7.2 enabled dokku core build-env plugin - certs 0.7.2 enabled dokku core certificate management plugin - checks 0.7.2 enabled dokku core checks plugin - common 0.7.2 enabled dokku core common plugin - config 0.7.2 enabled dokku core config plugin - docker-options 0.7.2 enabled dokku core docker-options plugin - domains 0.7.2 enabled dokku core domains plugin - enter 0.7.2 enabled dokku core enter plugin - git 0.7.2 enabled dokku core git plugin - logs 0.7.2 enabled dokku core logs plugin - named-containers 0.7.2 enabled dokku core named containers plugin - nginx-vhosts 0.7.2 enabled dokku core nginx-vhosts plugin - plugin 0.7.2 enabled dokku core plugin plugin - proxy 0.7.2 enabled dokku core proxy plugin - ps 0.7.2 enabled dokku core ps plugin - repo 0.7.2 enabled dokku core repo plugin - shell 0.7.2 enabled dokku core shell plugin - ssh-keys 0.7.2 enabled dokku core ssh-keys plugin - storage 0.7.2 enabled dokku core storage plugin - tags 0.7.2 enabled dokku core tags plugin - tar 0.7.2 enabled dokku core tar plugin + 00_dokku-standard 0.8.0 enabled dokku core standard plugin + 20_events 0.8.0 enabled dokku core events logging plugin + apps 0.8.0 enabled dokku core apps plugin + build-env 0.8.0 enabled dokku core build-env plugin + certs 0.8.0 enabled dokku core certificate management plugin + checks 0.8.0 enabled dokku core checks plugin + common 0.8.0 enabled dokku core common plugin + config 0.8.0 enabled dokku core config plugin + docker-options 0.8.0 enabled dokku core docker-options plugin + domains 0.8.0 enabled dokku core domains plugin + enter 0.8.0 enabled dokku core enter plugin + git 0.8.0 enabled dokku core git plugin + logs 0.8.0 enabled dokku core logs plugin + named-containers 0.8.0 enabled dokku core named containers plugin + nginx-vhosts 0.8.0 enabled dokku core nginx-vhosts plugin + plugin 0.8.0 enabled dokku core plugin plugin + proxy 0.8.0 enabled dokku core proxy plugin + ps 0.8.0 enabled dokku core ps plugin + repo 0.8.0 enabled dokku core repo plugin + shell 0.8.0 enabled dokku core shell plugin + ssh-keys 0.8.0 enabled dokku core ssh-keys plugin + storage 0.8.0 enabled dokku core storage plugin + tags 0.8.0 enabled dokku core tags plugin + tar 0.8.0 enabled dokku core tar plugin ``` Installing a plugin is easy as well using the `plugin:install` command. This command will also trigger the `install` pluginhook on all existing plugins. @@ -72,17 +72,6 @@ Receiving objects: 100% (646/646), 134.24 KiB | 0 bytes/s, done. Resolving deltas: 100% (406/406), done. Checking connectivity... done. -----> Plugin postgres enabled ------> Migrating zero downtime env variables to 0.5.x. The following variables have been deprecated -=====> DOKKU_SKIP_ALL_CHECKS DOKKU_SKIP_DEFAULT_CHECKS -=====> Please use dokku checks:[disable|enable] to control zero downtime functionality -=====> Migration complete -=====> ------> Migrating zero downtime env variables to 0.6.x. The following variables will be migrated -=====> DOKKU_CHECKS_ENABLED -> DOKKU_CHECKS_SKIPPED -=====> Migration complete -=====> -Adding user dokku to group adm -Starting nginx (via systemctl): nginx.service. ``` You can also uninstall a third-party plugin using the `plugin:uninstall` command: diff --git a/docs/advanced-usage/repository-management.md b/docs/advanced-usage/repository-management.md index 9cee535aa..e8235f863 100644 --- a/docs/advanced-usage/repository-management.md +++ b/docs/advanced-usage/repository-management.md @@ -3,7 +3,7 @@ > New as of 0.6.0 ``` -repo:gc # Runs 'git gc --agressive' against the application's repo +repo:gc # Runs 'git gc --aggressive' against the application's repo repo:purge-cache # Deletes the contents of the build cache stored in the repository ``` @@ -13,7 +13,7 @@ The repository plugin is meant to allow users to perform management commands aga ### Git Garbage Collection -This will run a git gc --agressive against the applications repo. This is performed on the Dokku host, and not within an application container. +This will run a git gc --aggressive against the applications repo. This is performed on the Dokku host, and not within an application container. ```shell dokku repo:gc node-js-app diff --git a/docs/assets/favicons/browserconfig.xml b/docs/assets/favicons/browserconfig.xml index 1881ad8c8..14e9c8e67 100644 --- a/docs/assets/favicons/browserconfig.xml +++ b/docs/assets/favicons/browserconfig.xml @@ -2,10 +2,10 @@ - - - - + + + + #da532c diff --git a/docs/assets/favicons/manifest.json b/docs/assets/favicons/manifest.json index a3d6a7458..1bc480147 100644 --- a/docs/assets/favicons/manifest.json +++ b/docs/assets/favicons/manifest.json @@ -2,37 +2,37 @@ "name": "Dokku", "icons": [ { - "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.7.2\/docs\/assets\/favicons\/android-chrome-36x36.png", + "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.8.0\/docs\/assets\/favicons\/android-chrome-36x36.png", "sizes": "36x36", "type": "image\/png", "density": "0.75" }, { - "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.7.2\/docs\/assets\/favicons\/android-chrome-48x48.png", + "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.8.0\/docs\/assets\/favicons\/android-chrome-48x48.png", "sizes": "48x48", "type": "image\/png", "density": "1.0" }, { - "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.7.2\/docs\/assets\/favicons\/android-chrome-72x72.png", + "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.8.0\/docs\/assets\/favicons\/android-chrome-72x72.png", "sizes": "72x72", "type": "image\/png", "density": "1.5" }, { - "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.7.2\/docs\/assets\/favicons\/android-chrome-96x96.png", + "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.8.0\/docs\/assets\/favicons\/android-chrome-96x96.png", "sizes": "96x96", "type": "image\/png", "density": "2.0" }, { - "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.7.2\/docs\/assets\/favicons\/android-chrome-144x144.png", + "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.8.0\/docs\/assets\/favicons\/android-chrome-144x144.png", "sizes": "144x144", "type": "image\/png", "density": "3.0" }, { - "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.7.2\/docs\/assets\/favicons\/android-chrome-192x192.png", + "src": "https:\/\/cdn.rawgit.com\/progrium\/dokku\/v0.8.0\/docs\/assets\/favicons\/android-chrome-192x192.png", "sizes": "192x192", "type": "image\/png", "density": "4.0" diff --git a/docs/assets/style.css b/docs/assets/style.css index 34d6acc43..5f2c2763d 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -1,7 +1,6 @@ body { - font-family: 'Open Sans', sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-weight: 400; - font-size: 12px; padding-bottom: 40px; color: #5a5a5a; -webkit-font-smoothing: antialiased; @@ -21,7 +20,7 @@ h1 { .header .heading { color: #fff; font-size: 23px; - margin: 0; + margin: 7px 0 0 0; padding: 0 0 0 1em; } .header a { @@ -36,13 +35,13 @@ h1 { background-repeat: no-repeat; } .header .navbar-brand a { - background-image: url(https://cdn.rawgit.com/dokku/dokku/v0.7.2/docs/assets/dokku.png); + background-image: url(https://cdn.rawgit.com/dokku/dokku/v0.8.0/docs/assets/dokku.png); text-indent: 40px; } .blurb { color: #424242; background-color: #ededed; - background-image: url(https://cdn.rawgit.com/dokku/dokku/v0.7.2/docs/assets/gplaypattern.png); + background-image: url(https://cdn.rawgit.com/dokku/dokku/v0.8.0/docs/assets/gplaypattern.png); padding: 45px 0; text-align: center; } @@ -67,7 +66,6 @@ h1 { color: #444; display: block; font-weight: 400; - font-size: 14px; margin: 0 20px; padding: 3px 0; text-align: center; @@ -211,6 +209,7 @@ h1 { .list-group-item { border: none; + font-size: 14px; font-weight: normal; padding: .2rem .5rem; color: #157577; @@ -246,10 +245,9 @@ a.list-group-item { -webkit-font-smoothing: antialiased; box-sizing: border-box; color: rgb(71, 74, 84); - font-size: 14px; font-weight: normal; height: 20px; - line-height: 20px; + line-height: 1.5; text-align: left; } .markdown-body h1 { diff --git a/docs/assets/versions.json b/docs/assets/versions.json index 32140569b..eb62acaf0 100644 --- a/docs/assets/versions.json +++ b/docs/assets/versions.json @@ -1 +1,10 @@ -{ "max-versions": [ "0.3.26", "0.4.14", "0.5.8", "0.6.5", "0.7.2" ] } +{ + "max-versions": [ + "0.3.26", + "0.4.14", + "0.5.8", + "0.6.5", + "0.7.2", + "0.8.0" + ] +} diff --git a/docs/community/plugins.md b/docs/community/plugins.md index 12f507fc9..b1b5c0a1f 100644 --- a/docs/community/plugins.md +++ b/docs/community/plugins.md @@ -69,6 +69,7 @@ Note: The following plugins have been supplied by our community and may not have [cu12]: https://github.com/cu12 [darkpixel]: https://github.com/darkpixel [dokku]: https://github.com/dokku +[dokku-community]: https://github.com/dokku-community [dyson]: https://github.com/dyson [F4-Group]: https://github.com/F4-Group [fermuch]: https://github.com/fermuch @@ -119,6 +120,7 @@ Note: The following plugins have been supplied by our community and may not have [thrashr888]: https://github.com/thrashr888 [wmluke]: https://github.com/wmluke [Zenedith]: https://github.com/Zenedith +[fteychene]: https://github.com/fteychene ### Datastores @@ -162,7 +164,7 @@ Note: The following plugins have been supplied by our community and may not have [c77cbf1]: https://github.com/dokku/dokku/commit/c77cbf1d3ae07f0eafb85082ed7edcae9e836147 [28de3ec]: https://github.com/dokku/dokku/commit/28de3ecaa3231a223f83fd8d03f373308673bc40 -### Dokku Features +### Plugins Implementing New Dokku Functionality | Plugin | Author | Compatibility | | ------------------------------------------------------------------------------------------------- | --------------------- | --------------------- | @@ -184,6 +186,7 @@ Note: The following plugins have been supplied by our community and may not have | [robots.txt](https://notabug.org/candlewaster/dokku-robots.txt) | [candlewaster][] | 0.4.x | | [SSH Deployment Keys](https://github.com/cedricziel/dokku-deployment-keys)3 | [cedricziel][] | 0.4.0+ | | [SSH Hostkeys](https://github.com/cedricziel/dokku-hostkeys-plugin)4 | [cedricziel][] | 0.3.x | +| [Application build hook](https://github.com/fteychene/dokku-build-hook) | [fteychene][] | 0.4.0+ | [217d00a]: https://github.com/dokku/dokku/commit/217d00a1bc47a7e24d8847617bb08a1633025fc7 @@ -218,10 +221,10 @@ Note: The following plugins have been supplied by our community and may not have | [Rollbar](https://github.com/iloveitaly/dokku-rollbar) | [iloveitaly][] | 0.5.0+ | | [Slack Notifications](https://github.com/ribot/dokku-slack) | [ribot][] | 0.4.0+ | | [Tor](https://github.com/michaelshobbs/dokku-tor) | [michaelshobbs][] | 0.4.0+ | -| [User ACL](https://github.com/mlebkowski/dokku-acl) | [Maciej Łebkowski][] | 0.4.0+ | +| [User ACL](https://github.com/dokku-community/dokku-acl) | [Maciej Łebkowski][] | 0.4.0+ | | [Webhooks](https://github.com/nickstenning/dokku-webhooks) | [nickstenning][] | 0.3.x | | [Wkhtmltopdf](https://github.com/mbriskar/dokku-wkhtmltopdf) | [mbriskar][] | 0.4.0+ | -| [Wordpress Setup](https://github.com/dudagroup/dokku-wordpress-template) | [abossard][] | | +| [Dokku Wordpress](https://github.com/dokku-community/dokku-wordpress) | [dokku-community][] | 0.4.0+ | | [Access](https://github.com/mainto/dokku-access) | [mainto](https://github.com/mainto) | 0.4.0+ | ### Deprecated Plugins diff --git a/docs/configuration/domains.md b/docs/configuration/domains.md index fdda6a71f..048a495ef 100644 --- a/docs/configuration/domains.md +++ b/docs/configuration/domains.md @@ -3,14 +3,16 @@ > New as of 0.3.10 ``` +domains [|--global] # List domains domains:add [ ...] # Add domains to app domains:add-global [ ...] # Add global domain names -domains [] # List domains domains:clear # Clear all domains for app domains:disable # Disable VHOST support domains:enable # Enable VHOST support domains:remove [ ...] # Remove domains from app domains:remove-global [ ...] # Remove global domain names +domains:set [ ...] # Set domains for app +domains:set-global [ ...] # Set global domain names ``` > Adding a domain before deploying an application will result in port mappings being set. This may cause issues for applications that use non-standard ports, as those will not be automatically detected. Please refer to the [proxy documentation](/dokku/advanced-usage/proxy-management/) for information as to how to reconfigure the mappings. @@ -68,11 +70,16 @@ dokku domains:clear myapp # remove a custom domain from app dokku domains:remove myapp example.com + +# set all custom domains for app +dokku domains:set myapp example.com example.org ``` ## 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 the global nginx configuration. 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). +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 the global nginx configuration. + +Create the file at `/etc/nginx/conf.d/00-default-vhost.conf`: ```nginx server { @@ -85,17 +92,10 @@ server { } ``` -You may also wish to use a separate vhost in your `/etc/nginx/sites-enabled` directory. To do so, create the vhost in that directory as `/etc/nginx/sites-enabled/00-default.conf`. You will also need to change two lines in the main `nginx.conf`: +Make sure to reload nginx after creating this file by running `service nginx reload`. -```nginx -# Swap both conf.d include line and the sites-enabled include line. From: -include /etc/nginx/conf.d/*.conf; -include /etc/nginx/sites-enabled/*; +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). -# to the following - -include /etc/nginx/sites-enabled/*; -include /etc/nginx/conf.d/*.conf; -``` +The configuration file must be loaded before `/etc/nginx/conf.d/dokku.conf`, so it can not be arranged as a vhost in `/etc/nginx/sites-enabled` that is only processed afterwards. Alternatively, you may push an app to your Dokku host with a name like "00-default". As long as it lists first in `ls /home/dokku/*/nginx.conf | head`, it will be used as the default nginx vhost. diff --git a/docs/configuration/ssl.md b/docs/configuration/ssl.md index 7a1a397d8..31d8a080f 100644 --- a/docs/configuration/ssl.md +++ b/docs/configuration/ssl.md @@ -29,8 +29,7 @@ The `certs:add` command can be used to push a `tar` containing a certificate `.c ```shell tar cvf cert-key.tar server.crt server.key -# replace APP with the name of your application -dokku certs:add < cert-key.tar +dokku certs:add node-js-app < cert-key.tar ``` > Note: If your `.crt` file came alongside a `.ca-bundle`, you'll want to concatenate those into a single `.crt` file before adding it to the `.tar`. @@ -51,7 +50,7 @@ Note that with the default nginx template, requests will be redirected to the `h The `certs:generate` command will walk you through the correct `openssl` commands to create a key, csr and a self-signed cert for a given app/domain. We automatically put the self-signed cert in place as well as add the specified domain to the application configuration. -If you decide to obtain a CA signed certficate, you can import that certificate using the aformentioned `dokku certs:add` command. +If you decide to obtain a CA signed certificate, you can import that certificate using the aforementioned `dokku certs:add` command. ### Certificate information diff --git a/docs/deployment/application-deployment.md b/docs/deployment/application-deployment.md index e96df35ba..903add341 100644 --- a/docs/deployment/application-deployment.md +++ b/docs/deployment/application-deployment.md @@ -101,6 +101,17 @@ If you only want to rebuild and tag a container, you can skip the deployment pha dokku config:set ruby-rails-sample DOKKU_SKIP_DEPLOY=true ``` +### Re-Deploying / restarting + +If you need to re-deploy (or restart) your app: + +```shell +# on your Dokku host +dokku ps:rebuild ruby-rails-sample +``` + +See the [process scaling documentation](/dokku/deployment/process-management) for more information. + ### 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 `/home/dokku/.ssh/` and potentially add github.com (or your VCS host key) into `/home/dokku/.ssh/known_hosts`. The following test should help confirm you've done it correctly. diff --git a/docs/deployment/logs.md b/docs/deployment/logs.md index 9be0352f8..eefb5983c 100644 --- a/docs/deployment/logs.md +++ b/docs/deployment/logs.md @@ -24,13 +24,8 @@ Dokku also supports certain command-line arguments that augment the `log` comman -q, --quiet # display raw logs without colors, time and names ``` -You can use these modifiers as +You can use these modifiers as follows: -```shell -dokku logs -``` - -For example, ```shell dokku logs node-js-app -t -p web diff --git a/docs/deployment/methods/buildpacks.md b/docs/deployment/methods/buildpacks.md index 897d9ef41..79f1bc2d4 100644 --- a/docs/deployment/methods/buildpacks.md +++ b/docs/deployment/methods/buildpacks.md @@ -14,12 +14,11 @@ In certain cases you may want to specify a custom buildpack. While Dokku uses he To use a specific buildpack, you can run the following Dokku command: ```shell -# replace APP with the name of your application # replace REPOSITORY_URL with your buildpack's url -dokku config:set APP BUILDPACK_URL=REPOSITORY_URL +dokku config:set node-js-app BUILDPACK_URL=REPOSITORY_URL # example: using a specific ruby buildpack version -dokku config:set APP BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby.git#v142 +dokku config:set node-js-app BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby.git#v142 ``` Please check the documentation for your particular buildpack as you may need to include configuration files (such as a Procfile) in your project root. @@ -45,16 +44,14 @@ As Dokku pins all buildpacks via herokuish releases, there may be occasions wher ```shell # using the latest nodejs buildpack -# replace APP with the name of your application -dokku config:set APP BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs +dokku config:set node-js-app BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs ``` You may also wish to use a **specific** version of a buildpack, which is also simple ```shell # using v87 of the nodejs buildpack -# replace APP with the name of your application -dokku config:set APP BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#v87 +dokku config:set node-js-app BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#v87 ``` ## Specifying commands via Procfile diff --git a/docs/deployment/methods/dockerfiles.md b/docs/deployment/methods/dockerfiles.md index a51b427da..ebc91f65b 100644 --- a/docs/deployment/methods/dockerfiles.md +++ b/docs/deployment/methods/dockerfiles.md @@ -34,7 +34,7 @@ ENTRYPOINT ["node"] You can do: ```shell -dokku config:set APP DOKKU_DOCKERFILE_START_CMD="--harmony server.js" +dokku config:set node-js-app DOKKU_DOCKERFILE_START_CMD="--harmony server.js" ``` To tell docker what to run. diff --git a/docs/deployment/one-off-processes.md b/docs/deployment/one-off-processes.md index b40dc7bf4..3210a6f7c 100644 --- a/docs/deployment/one-off-processes.md +++ b/docs/deployment/one-off-processes.md @@ -29,7 +29,7 @@ dokku run my-app console If you want to remove the container after a command has started, you can run the following command: ```shell -# keep `run` containers around +# don't keep `run` containers around dokku config:set --global DOKKU_RM_CONTAINER=1 # revert the above setting and keep containers around diff --git a/docs/deployment/process-management.md b/docs/deployment/process-management.md index bd924e4e4..997dcd240 100644 --- a/docs/deployment/process-management.md +++ b/docs/deployment/process-management.md @@ -31,7 +31,7 @@ dokku ps node-js-app ### Rebuilding applications -There are some Dokku commands which will not automatically rebuild an application's environment, or which can be told to skip a rebuild. For instance, you may wish to run mulitple `config:set` commands without a restart so as to speed up configuration. In these cases, you can ultimately trigger an application rebuild using `ps:rebuild` +There are some Dokku commands which will not automatically rebuild an application's environment, or which can be told to skip a rebuild. For instance, you may wish to run multiple `config:set` commands without a restart so as to speed up configuration. In these cases, you can ultimately trigger an application rebuild using `ps:rebuild` ```shell dokku ps:rebuild node-js-app @@ -92,7 +92,7 @@ dokku ps:scale node-js-app ### Stopping applications -Deployed applications can be stopped using the `ps:stop` command. This turns all running containers for an application, and will result in a `502 Bad Gateway` reponse for the default nginx proxy implementation. +Deployed applications can be stopped using the `ps:stop` command. This turns all running containers for an application, and will result in a `502 Bad Gateway` response for the default nginx proxy implementation. ```shell dokku ps:stop node-js-app diff --git a/docs/deployment/user-management.md b/docs/deployment/user-management.md index b8a4c4b70..17e8f924b 100644 --- a/docs/deployment/user-management.md +++ b/docs/deployment/user-management.md @@ -12,7 +12,7 @@ When pushing to Dokku, ssh key based authorization is the preferred authenticati Users in Dokku are managed via the `~/dokku/.ssh/authorized_keys` file. It is **highly** recommended that you follow the steps below to manage users on a Dokku server. -> Users of older versions of Dokku should use the `sshcommand` binary to manage keys. Please refer to the Dokku documentation for your version for more details. +> Users of older versions of Dokku may use the `sshcommand` binary to manage keys instead of the `ssh-keys` plugin. Please refer to the Dokku documentation for your version for more details. ## Usage diff --git a/docs/deployment/zero-downtime-deploys.md b/docs/deployment/zero-downtime-deploys.md index 2ef6bd89e..c1b24c9d5 100644 --- a/docs/deployment/zero-downtime-deploys.md +++ b/docs/deployment/zero-downtime-deploys.md @@ -10,18 +10,32 @@ checks:run [process-type(s)] Runs zero-downtime checks for all proce checks:skip [process-type(s)] Skip zero-downtime checks for all processes (or comma-separated process-type list) ``` -Following a deploy, Dokku will wait `10` seconds before routing traffic to the new container to give your application time to boot up. If the application is not running after this time, then the deploy is failed and your old container will continue serving traffic. You can modify this value globally or on a per-application basis: - -```shell -dokku config:set --global DOKKU_DEFAULT_CHECKS_WAIT=30 -dokku config:set node-js-app DOKKU_DEFAULT_CHECKS_WAIT=30 -``` - -You can also choose to skip checks or disable zero-downtime completely on a per-application/per-process basis - -> Note that `checks:disable` will now (as of 0.6.0) cause downtime for that process-type during deployments. +By default, Dokku will wait `10` seconds after starting each container before assuming it is up and proceeding with the deploy. Once this has occurred for all containers started by for an application, traffic will be switched to point to your new containers. Dokku will also wait a further `60` seconds _after_ the deploy is complete before terminating old containers in order to give time for long running connections to terminate. In either case, you may have more than one container running for a given application. + +You may both create user-defined checks for web processes using a `CHECKS` file, as well as customize any and all parts of this experience using the checks plugin. + +## Configuring Check Settings using the `config` plugin + +There are certain settings that can be configured via environment variables: + +- `DOKKU_DEFAULT_CHECKS_WAIT`: (default: `10`) If no user-defined checks are specified - or if the process being checked is not a `web` process - this is the period of time Dokku will wait before checking that a container is still running. +- `DOKKU_DOCKER_STOP_TIMEOUT`: (default: `10`) Configurable grace period given to the `docker stop` command. If a container has not stopped by this time, a `kill -9` signal or equivalent is sent in order to force-terminate the container. Both the `ps:stop` and `apps:destroy` commands _also_ respect this value. If not specified, the docker defaults for the [docker stop command](https://docs.docker.com/engine/reference/commandline/stop/) will be used. +- `DOKKU_WAIT_TO_RETIRE`: (default: `60`) After a successful deploy, the grace period given to old containers before they are stopped/terminated. This is useful for ensuring completion of long-running http connections. + +The following settings may also be specified in the `CHECKS` file, though are available as environment variables in order to ease application reuse. + +- `DOKKU_CHECKS_WAIT`: (default: `5`) Wait this many seconds for the container to start before running checks. +- `DOKKU_CHECKS_TIMEOUT`: (default: `30`) Wait this many seconds for each response before marking it as a failure. +- `DOKKU_CHECKS_ATTEMPTS`: (default: `5`) Number of retries for to run for a specific check before marking it as a failure + +## Skipping and Disabling Checks + +> Note that `checks:disable` will now (as of 0.6.0) cause downtime for that process-type during deployments. Previously, it acted as `checks:skip` currently does. + +You can choose to skip checks completely on a per-application/per-process basis. Skipping checks will avoid the default 10 second waiting period entirely, as well as any other user-defined checks. ```shell +# process type specification is optional dokku checks:skip node-js-app worker,web ``` @@ -33,8 +47,7 @@ dokku checks:skip node-js-app worker,web DOKKU_CHECKS_SKIPPED: worker,web ``` -Additionally, any given process can only be configured to disable zero-downtime. example: - +Zero-downtime checks can also be disabled completely. This will stop old containers **before** new ones start, which may result in broken connections and downtime if your application fails to boot properly. ```shell dokku checks:disable node-js-app worker @@ -48,14 +61,67 @@ dokku checks:disable node-js-app worker DOKKU_CHECKS_SKIPPED: web ``` -Dokku will wait `60` seconds before stopping the old container so that existing connections are given a chance to complete. You can modify this value globally or on a per-application basis: +## Customizing Checks -```shell -dokku config:set --global DOKKU_WAIT_TO_RETIRE=120 -dokku config:set DOKKU_WAIT_TO_RETIRE=120 +If your application needs a longer period to boot up - perhaps to load data into memory, or because of slow boot time - you may also use dokku's `checks` functionality to more precisely check whether an application can serve traffic or not. + +Checks are run against the detected `web` process from your application's `Procfile`. For non-web processes, Dokku will fallback to the aforementioned process uptime check. + +To specify checks, add a `CHECKS` file to the root of your project directory. The `CHECKS` file should be plain text and may contain: + +- Check instructions +- Settings (NAME=VALUE) +- Comments (lines starting with #) +- Empty lines + +> For dockerfile-based deploys, the file *must* be in `/app/CHECKS` within the container. `/app` is used by default as the root container directory for buildpack-based deploys. + +### Check Instructions + +The format of a check instruction is a path or relative URL, optionally followed by the expected content: + +``` +/about Our Amazing Team ``` -> Note that during this time, multiple containers may be running on your server, which can be an issue for memory-hungry applications on memory-constrained servers. +The `CHECKS` file can contain multiple checks: + +``` +/ My Amazing App +/stylesheets/index.css .body +/scripts/index.js $(function() +/images/logo.png +``` + +To check an application that supports multiple hostnames, use relative URLs that include the hostname: + +``` +//admin.example.com Admin Dashboard +//static.example.com/logo.png +``` + +You can also specify the protocol to explicitly check HTTPS requests: + +``` +https://admin.example.com Admin Dashboard +https://static.example.com/logo.png +``` + +While a full url may be used in order to invoke checks, if you are using relative urls, the port *must* be omitted. + +### Check Settings + +The default behavior is to wait for `5` seconds before running the checks, to timeout the checks after `30` seconds, and to attempt the checks `5` times. If the checks fail `5` times, the deployment is considered failed and the old container will continue serving traffic. + +You can change the default behavior by setting `WAIT`, `TIMEOUT`, and `ATTEMPTS` to different values in the `CHECKS` file: + +``` +WAIT=30 # Wait 1/2 minute +TIMEOUT=60 # Timeout after a minute +ATTEMPTS=10 # Attempt checks 10 times + +/ My Amazing App +``` ## Manually Invoking Checks @@ -92,7 +158,7 @@ dokku checks:run APP Checks can be scoped to a particular process type: ```shell -dokku checks:run APP worker +dokku checks:run node-js-app worker ``` ``` @@ -108,7 +174,7 @@ dokku checks:run APP worker An app process id may also be specified: ```shell -dokku checks:run APP web.2 +dokku checks:run node-js-app web.2 ``` ``` @@ -124,7 +190,7 @@ dokku checks:run APP web.2 Non-existent process types will result in an error: ```shell -dokku checks:run APP non-existent +dokku checks:run node-js-app non-existent ``` ``` @@ -135,7 +201,7 @@ Invalid process type specified (APP.non-existent) Non-existent process ids will *also* result in an error ```shell -dokku checks:run APP web.3 +dokku checks:run node-js-app web.3 ``` ``` @@ -143,88 +209,6 @@ dokku checks:run APP web.3 Invalid container id specified (APP.web.3) ``` -## Customizing Checks - -If your application needs a longer period to boot up - perhaps to load data into memory, or because of slow boot time - you may also use dokku's `checks` functionality to more precisely check whether an application can serve traffic or not. - -Checks are run against the detected `web` process from your application's `Procfile`. For non-web processes, Dokku will fallback to the aforementioned process uptime check. - -To specify checks, add a `CHECKS` file to the root of your project directory. The `CHECKS` file should be plain text and may contain: - -* Check instructions -* Settings (NAME=VALUE) -* Comments (lines starting with #) -* Empty lines - -> For dockerfile-based deploys, the file *must* be in `/app/CHECKS` within the container. `/app` is used by default as the root container directory for buildpack-based deploys. - -### Check Instructions - -The format of a check instruction is a path or relative URL, optionally followed by the expected content: - -``` -/about Our Amazing Team -``` - -The `CHECKS` file can contain multiple checks: - -``` -/ My Amazing App -/stylesheets/index.css .body -/scripts/index.js $(function() -/images/logo.png -``` - -To check an application that supports multiple hostnames, use relative URLs that include the hostname: - -``` -//admin.example.com Admin Dashboard -//static.example.com/logo.png -``` - -You can also specify the protocol to explicitly check HTTPS requests: - -``` -https://admin.example.com Admin Dashboard -https://static.example.com/logo.png -``` - -### Check Settings - -The default behavior is to wait for `5` seconds before running the checks, to timeout the checks after `30` seconds, and to attempt the checks `5` times. If the checks fail `5` times, the deployment is considered failed and the old container will continue serving traffic. - -You can change the default behavior by setting `WAIT`, `TIMEOUT`, and `ATTEMPTS` to different values in the `CHECKS` file: - -``` -WAIT=30 # Wait 1/2 minute -TIMEOUT=60 # Timeout after a minute -ATTEMPTS=10 # Attempt checks 10 times - -/ My Amazing App -``` - -You can also override the default `WAIT`, `TIMEOUT`, and `ATTEMPTS` variables for the global Dokku installation: - -```shell -dokku config:set --global DOKKU_CHECKS_WAIT=30 -dokku config:set --global DOKKU_CHECKS_TIMEOUT=60 -dokku config:set --global DOKKU_CHECKS_ATTEMPTS=10 -``` - -If your application runs multiple processes (a background worker configured in your `Procfile`, for example) and you have checks to ensure that your web application has booted up, you may want to disable the default check wait time for that application to avoid the `10` second wait per non-web process: - -```shell -dokku config:set DOKKU_DEFAULT_CHECKS_WAIT=0 -``` - -### Configuring docker stop timeout - -[By default](https://docs.docker.com/engine/reference/commandline/stop/), docker will wait 10 seconds from the time the `stop` command is passed to a container before it attempts to kill said container. This timeout can be configured on a per-app basis in Dokku by setting the `DOKKU_DOCKER_STOP_TIMEOUT` configuration variable. This timeout applies to normal zero-downtime deployments as well as the `ps:stop` and `apps:destroy` commands. - -```shell -dokku config:set $APP DOKKU_DOCKER_STOP_TIMEOUT=20 -``` - ## Example: Successful Rails Deployment In this example, a Rails application is successfully deployed to dokku. The initial round of checks fails while the server is starting, but once it starts they succeed and the deployment is successful. `WAIT` is set to `10` because our application takes a while to boot up. `ATTEMPTS` is set to `6`, but the third attempt succeeds. diff --git a/docs/development/plugin-creation.md b/docs/development/plugin-creation.md index 3c7bff94a..2a2134082 100644 --- a/docs/development/plugin-creation.md +++ b/docs/development/plugin-creation.md @@ -150,8 +150,8 @@ A few notes: - As some plugins require access to set app config settings and do not want/require the default Heroku-style behavior of a restart, we have the following "internal" commands that provide this functionality : ```shell - dokku config:set --no-restart APP KEY1=VALUE1 [KEY2=VALUE2 ...] - dokku config:unset --no-restart APP KEY1 [KEY2 ...] + dokku config:set --no-restart node-js-app KEY1=VALUE1 [KEY2=VALUE2 ...] + dokku config:unset --no-restart node-js-app KEY1 [KEY2 ...] ``` - From time to time you may want to allow other plugins access to (some of) your plugin's functionality. You can expose this by including a `functions` file in your plugin for others to source. Consider all functions in that file to be publicly accessible by other plugins. Any functions not wished to be made "public" should reside within your plugin trigger or commands files. - As of 0.4.0, we allow image tagging and deployment of said tagged images. Therefore, hard-coding of `$IMAGE` as `dokku/$APP` is no longer sufficient. Instead, for non `pre/post-build-*` plugins, use `get_running_image_tag()` & `get_app_image_name()` as sourced from common/functions. See the [plugin triggers](/dokku/development/plugin-triggers) doc for examples. diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 7ca54dc06..d1431a5d4 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -27,7 +27,7 @@ There are a number of plugin-related triggers. These can be optionally implement The following plugin triggers describe those available to a Dokku installation. As well, there is an example for each trigger that you can use as templates for your own plugin development. -> The example plugin trigger code is not guaranteed to be implemented as in within dokkku, and are merely simplified examples. Please look at the Dokku source for larger, more in-depth examples. +> The example plugin trigger code is not guaranteed to be implemented as in within dokku, and are merely simplified examples. Please look at the Dokku source for larger, more in-depth examples. ### `post-config-update` @@ -134,6 +134,24 @@ help_content esac ``` +### `core-post-deploy` + +> To avoid issues with community plugins, this plugin trigger should be used *only* for core plugins. Please avoid using this trigger in your own plugins. + +- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx. +- Invoked by: `dokku deploy` +- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG` +- Example: + +```shell +#!/usr/bin/env bash +# Notify an external service that a successful deploy has occurred. + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +curl "http://httpstat.us/200" +``` + ### `dependencies` - Description: Used to install system-level dependencies. Invoked by `plugin:install-dependencies`. @@ -430,7 +448,9 @@ dokku postgres:destroy $APP ### `post-deploy` -- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx. +> Please see [core-post-deploy](#core-post-deploy) if contributing a core plugin with the `post-deploy` hook. + +- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku calls this _after_ `core-post-deploy`. Deployment Tasks are also invoked by this plugin trigger. - Invoked by: `dokku deploy` - Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG` - Example: @@ -447,7 +467,7 @@ curl "http://httpstat.us/200" ### `post-domains-update` - Description: Allows you to run commands once the domain for an application has been updated. It also sends in the command that has been used. This can be "add", "clear" or "remove". The third argument will be the optional list of domains -- Invoked by: `dokku domains:add`, `dokku domains:clear`, `dokku domains:remove` +- Invoked by: `dokku domains:add`, `dokku domains:clear`, `dokku domains:remove`, `dokku domains:set` - Arguments: `$APP` `action name` `domains` - Example: @@ -846,6 +866,26 @@ APP="$1"; IMAGE_TAG="$2" some code to remove a docker hub tag because it's not implemented in the CLI.... ``` +### `uninstall` + + - Description: Used to cleanup after itself. + - Invoked by: `dokku plugin:uninstall` + - Arguments: `$PLUGIN` + - Example: + + ```shell + #!/usr/bin/env bash + # Cleanup up extra containers created + + set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + + PLUGIN="$1" + + [[ "$PLUGIN" = "my-plugin" ]] && docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}" + ``` + + > To avoid uninstalling other plugins make sure to check the plugin name like shown in the example. + ### `update` - Description: Can be used to run plugin updates on a regular interval. You can schedule the invoker in a cron-task to ensure your system gets regular updates. diff --git a/docs/development/release-process.md b/docs/development/release-process.md index f69948dd0..52a81cb8b 100644 --- a/docs/development/release-process.md +++ b/docs/development/release-process.md @@ -20,7 +20,7 @@ To propose a release, the following tasks need to be performed: - The versioned links should be updated or added to the `docs/assets/versions.json` file. - A list of changes must be made in the `HISTORY.md`. - A tag must be created locally with your release version -- Debian packages *must* be created via `vagrant up build` +- Debian and RPM packages *must* be created via `vagrant up build` - The packages should be uploaded to packagecloud.io - All changes are pushed to master and the tag should be turned into a release which will contain the changelog. - ArchLinux package description *must* be updated via `vagrant up build-arch` (needs to be done after the tag is pushed to GitHub, because it is based on that) @@ -37,9 +37,9 @@ git tag v0.9.9 At the moment, tags need not be signed, though that may change in the future. -## Debian Packages +## Debian and RPM packages -The `build` target in the Dokku `Vagrantfile` creates debian packages for Dokku at a point in time. The version will be based upon the latest local tag - you may create your own, internal tags/releases if that is so desired. +The `build` target in the Dokku `Vagrantfile` creates debian and rpm packages for Dokku at a point in time. The version will be based upon the latest local tag - you may create your own, internal tags/releases if that is so desired. Debian package information is held in the `debian` directory of the Dokku project. @@ -51,6 +51,7 @@ git tag v0.9.9 vagrant up build export PACKAGECLOUD_TOKEN=SOME_TOKEN package_cloud push dokku/dokku/ubuntu/trusty dokku_0.9.9_amd64.deb +package_cloud push dokku/dokku/el/7 dokku-0.9.9-1.x86_64.rpm ``` If new versions of other packages were created, these should also be pushed at this time. @@ -66,7 +67,7 @@ The workflow looks like this: ```shell # having dokku-arch in ../dokku-arch vagrant up build-arch -# wait for "==> build-arch: ==> Finished making: dokku 0.7.2-2 (Mon Feb 22 23:20:37 CET 2016)" +# wait for "==> build-arch: ==> Finished making: dokku 0.8.0-2 (Mon Feb 22 23:20:37 CET 2016)" cd ../dokku-arch git add PKGBUILD .SRCINFO git commit -m 'Update to dokku 0.9.9' diff --git a/docs/getting-started/advanced-installation.md b/docs/getting-started/advanced-installation.md index 975ea7129..100ee7f2e 100644 --- a/docs/getting-started/advanced-installation.md +++ b/docs/getting-started/advanced-installation.md @@ -4,7 +4,7 @@ You can always install Dokku straight from the latest - potentially unstable - m ```shell # using a branch results in installing from source -wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh +wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh; sudo DOKKU_BRANCH=master bash bootstrap.sh ``` @@ -29,7 +29,7 @@ sudo SSHCOMMAND_URL=https://raw.githubusercontent.com/yourusername/sshcommand/ma The bootstrap script allows the Dokku repository URL to be overridden to bootstrap a host from your own clone of Dokku using the `DOKKU_REPO` environment variable. Example: ```shell -wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh +wget https://raw.githubusercontent.com/dokku/dokku/master/bootstrap.sh; chmod +x bootstrap.sh sudo DOKKU_REPO=https://github.com/yourusername/dokku.git DOKKU_BRANCH=master ./bootstrap.sh ``` diff --git a/docs/getting-started/install/dreamhost.md b/docs/getting-started/install/dreamhost.md index 296f6cc87..8fa721a05 100644 --- a/docs/getting-started/install/dreamhost.md +++ b/docs/getting-started/install/dreamhost.md @@ -4,7 +4,7 @@ Cloud-init script can be used to automate installation of Dokku on Dreamhost (or any other OpenStack-compatible cloud with minimal changes). -A new server can be created on DreamHost Cloud from the command line +A new server instance can be created on DreamHost Cloud from the command line using openstack client or from the web UI and with the same command use a cloud-init script to install Dokku. Install the [openstack cli](https://help.dreamhost.com/hc/en-us/articles/216185658-How-to-Install-the-OpenStack-command-line-clients), @@ -18,18 +18,18 @@ source openrc.sh # Set the environment variables for DreamHost Cloud ``` This allows openstack client to connect to DreamHost API endpoints. -The command below creates a new server named `my-dokku-instance` based -on Ubuntu 14.04, with 2GB RAM and 1CPU (the flavor called -`semisonic`), opening network port access to http and ssh (the +The command below creates a new server instance named `my-dokku-instance` +based on Ubuntu 14.04, with 2GB RAM and 1CPU (the flavor called +`supersonic`), opening network port access to http and ssh (the `default` security group), and the name of the chosen SSH key. This key will be automatically added to the new server in the -`authorized_keys` for the default SSH user (`dhc-user`), and it will +`authorized_keys` for the default SSH user (`ubuntu`), and it will be reused by Dokku. ```sh openstack server create \ --image Ubuntu-14.04 \ - --flavor gp1.semisonic \ + --flavor gp1.supersonic \ --security-group default \ --key-name $YOUR_SSH_KEYNAME \ --user-data dokku-cloudinit.sh \ @@ -178,8 +178,20 @@ debconf_selections: | # set the domain name of the new Dokku server dokku dokku/hostname string $YOUR_FULL_QUALIFIED_DOMAIN # this copies over the public SSH key assigned to the server - dokku dokku/key_file string /home/dhc-user/.ssh/authorized_keys + dokku dokku/key_file string /home/ubuntu/.ssh/authorized_keys packages: - dokku ``` + +Shortly after running the create command you will get a confirmation that the +instance has been created, and after about a minute it should be ready to login. +Check the IP of the instance through the web UI or by running: + +```sh +nova list +``` + +SSH with the `ubuntu` username and the public key previously added. +Keep in mind that if you logged in quick enough dokku might still be installing +in the background, and not be ready. The installation takes a few minutes. diff --git a/docs/getting-started/install/rpm.md b/docs/getting-started/install/rpm.md new file mode 100644 index 000000000..f51e9283f --- /dev/null +++ b/docs/getting-started/install/rpm.md @@ -0,0 +1,22 @@ +# RPM Package Installation Notes + +> New as of 0.8.0 *(experimental)* + +>**Warning:** Web installer is not available on CentOS. You will need to configure [SSH keys](/dokku/deployment/user-management/#adding-ssh-keys) and [virtual hosts](/dokku/configuration/domains/#customizing-hostnames) using dokku command line interface. + +Dokku defaults to being installed via RPM package on CentOS 7. 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 +# install docker +curl -fsSL https://get.docker.com/ | sh + +# install epel for nginx packages to be available +sudo yum install -y epel-release + +# install dokku +curl -s https://packagecloud.io/install/repositories/dokku/dokku/script.rpm.sh | sudo bash +sudo yum install -y herokuish dokku +sudo dokku plugin:install-dependencies --core +``` + +The [devicemapper](https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/) is the default Docker storage driver on CentOS 7 and defaults to a configuration mode known as `loop-lvm`. This mode is designed to work out-of-the-box with no additional configuration. However, production deployments should not run under `loop-lvm` mode. The preferred configuration for production deployments is [`direct-lvm`](https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/#/configure-direct-lvm-mode-for-production). diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index ba8b6ee44..e2c5ddb1e 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -6,12 +6,12 @@ Dokku is an extensible, open source Platform as a Service that runs on a single To start using Dokku, you'll need a system that meets the following minimum requirements: -- A fresh installation of [Ubuntu 14.04 x64](http://www.ubuntu.com/download/) with the FQDN set [1] +- A fresh installation of [Ubuntu 16.04 x64](https://www.ubuntu.com/download), [Ubuntu 14.04 x64](https://www.ubuntu.com/download), [Debian 8.2 x64](https://www.debian.org/distrib/) or [CentOS 7 x64](https://www.centos.org/download/) *(experimental)* with the FQDN set [1] - At least `1GB` of system memory [2] You can *optionally* have a domain name pointed at the host's IP, though this is not necessary. -Dokku is designed for usage on a fresh installation of Ubuntu, and should install all necessary dependencies if installing via the bootstrap method. +Dokku is designed for usage on a fresh VM installation, and should install all necessary dependencies if installing via the bootstrap method. ### Installing the latest stable version @@ -21,8 +21,8 @@ To install the latest stable version of dokku, you can run the following shell c ```shell # for debian systems, installs Dokku via apt-get -wget https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh -sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh +wget https://raw.githubusercontent.com/dokku/dokku/v0.8.0/bootstrap.sh; +sudo DOKKU_TAG=v0.8.0 bash bootstrap.sh ``` The installation process takes about 5-10 minutes, depending upon internet connection speed. @@ -33,6 +33,8 @@ Once the installation is complete, you can open a browser to setup your SSH key >**Warning:** If you don't complete setup via the web installer (even if you set up SSH keys and virtual hosts otherwise) your Dokku installation will remain vulnerable to anyone finding the setup page and inserting their key. +>**Warning:** Web installer is not available on CentOS and Arch Linux. You will need to configure [SSH keys](/dokku/deployment/user-management/#adding-ssh-keys) and [virtual hosts](/dokku/configuration/domains/#customizing-hostnames) using dokku command line interface. + #### 3. Deploy your first application Once you save your settings, the web admin will self-terminate and you should be able to run or deploy to the Dokku installation. @@ -48,6 +50,7 @@ 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](/dokku/getting-started/install/debian/) +- [RPM Package Installation Notes](/dokku/getting-started/install/rpm/) - [Vagrant Installation Notes](/dokku/getting-started/install/vagrant/) - [Advanced Install Customization](/dokku/getting-started/advanced-installation/) diff --git a/docs/getting-started/troubleshooting.md b/docs/getting-started/troubleshooting.md index ef6b35ead..5933ea97a 100644 --- a/docs/getting-started/troubleshooting.md +++ b/docs/getting-started/troubleshooting.md @@ -154,3 +154,42 @@ dokku config:set --global CURL_CONNECT_TIMEOUT=30 ``` Please see https://github.com/dokku/dokku/issues/509 + +*** + +__Symptom:__ Build fails with `Killed` message. + +__Solution:__ + +This generally occurs when the server runs out of memory. You can either add more ram to your server or setup swap space. The follow script will create 2gb of swap space. + +```shell +sudo install -o root -g root -m 0600 /dev/null /swapfile +dd if=/dev/zero of=/swapfile bs=1k count=2048k +mkswap /swapfile +swapon /swapfile +echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab +sudo sysctl -w vm.swappiness=10 +echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf +``` + +*** + +__Symptom:__ I successfully deployed my application with no deployment errors but I'm receiving Connection Timeout when attempting to access the application. + +__Solution:__ + +This can occur if Dokku is running on a system with a firewall like ufw enabled (some OS versions like Ubuntu 16.04 have this enabled by default). You can check if this is your case by running the following script: + +```shell +sudo ufw status +``` + +If the previous script returned `Status: active` and a list of ports, ufw is enabled and is probably the cause of the symptom described above. To disable it, run: + +```shell +sudo ufw disable +``` + +*** + diff --git a/docs/getting-started/upgrading.md b/docs/getting-started/upgrading.md index 42cfa36a6..8adc671db 100644 --- a/docs/getting-started/upgrading.md +++ b/docs/getting-started/upgrading.md @@ -25,8 +25,8 @@ If Dokku was installed via `apt-get install dokku` or `bootstrap.sh` (most commo ```shell sudo apt-get update dokku apps -dokku ps:stop # repeat to shut down each running app -sudo apt-get install -qq -y dokku herokuish +dokku ps:stop APP # repeat to shut down each running app +sudo apt-get install -qq -y dokku herokuish sshcommand plugn dokku ps:rebuildall # rebuilds all applications ``` @@ -46,7 +46,7 @@ If you installed Dokku from source (less common), upgrade with: ```shell dokku apps -dokku ps:stop # repeat to shut down each running app +dokku ps:stop APP # repeat to shut down each running app cd ~/dokku git pull --tags origin master diff --git a/docs/home.html b/docs/home.html index 402a9e9b8..f8f0c65f9 100644 --- a/docs/home.html +++ b/docs/home.html @@ -7,33 +7,33 @@ - + Dokku - The smallest PaaS implementation you've ever seen - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - + @@ -98,12 +98,12 @@

$ - wget https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh + wget https://raw.githubusercontent.com/dokku/dokku/v0.8.0/bootstrap.sh

$ - sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh + sudo DOKKU_TAG=v0.8.0 bash bootstrap.sh

 # go to your server's IP and follow the web installer diff --git a/docs/template.html b/docs/template.html index 7c69c23c8..1fd721650 100644 --- a/docs/template.html +++ b/docs/template.html @@ -7,29 +7,28 @@ - Dokku - The smallest PaaS implementation you've ever seen - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - + diff --git a/dokku b/dokku index 15a65e353..978d617f4 100755 --- a/dokku +++ b/dokku @@ -7,17 +7,9 @@ export DOKKU_ROOT=${DOKKU_ROOT:=~dokku} [[ -d $DOKKU_ROOT/.dokkurc ]] && for f in $DOKKU_ROOT/.dokkurc/*; do source "$f"; done [[ $DOKKU_TRACE ]] && set -x -case "$(lsb_release -si)" in - Arch) - export DOKKU_DISTRO=${DOKKU_DISTRO:="arch"} - ;; - Debian) - export DOKKU_DISTRO=${DOKKU_DISTRO:="debian"} - ;; - *) - export DOKKU_DISTRO=${DOKKU_DISTRO:="ubuntu"} - ;; -esac +export DOKKU_DISTRO +# shellcheck disable=SC1091 +DOKKU_DISTRO=$(. /etc/os-release > /dev/null 2>&1 || true ; echo "$ID") export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish"} export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"} @@ -43,10 +35,12 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" parse_args "$@" args=("$@") +skip_arg=false if [[ "${args[0]}" =~ ^--.* ]]; then for arg in "$@"; do + $skip_arg && skip_arg=false && continue if [[ "$arg" == "--app" ]]; then - shift 2 + shift 2 && skip_arg=true elif [[ "$arg" =~ ^--.* ]]; then shift 1 else diff --git a/plugins/00_dokku-standard/core-post-deploy b/plugins/00_dokku-standard/core-post-deploy new file mode 100755 index 000000000..7b21978cb --- /dev/null +++ b/plugins/00_dokku-standard/core-post-deploy @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + +cleanup_container_state() { + declare desc="core post-deploy state cleanup" + local trigger="core-post-deploy cleanup_container_state" + local APP="$1"; local PROCTYPES="$(egrep -v "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)" + local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 3 -n | xargs)" + + local CONTAINER_FILE + for CONTAINER_FILE in $CONTAINER_FILES; do + local CONTAINER_TYPE="$(awk -F '.' '{ print $2 }' <<< "$CONTAINER_FILE")" + if [[ "$(is_val_in_list "$CONTAINER_TYPE" "$PROCTYPES" " ")" == "false" ]]; then + dokku_log_info1 "Container type ($CONTAINER_TYPE) is no longer defined. Removing state" + local IP_FILE="${CONTAINER_FILE//CONTAINER/IP}" + local PORT_FILE="${CONTAINER_FILE//CONTAINER/PORT}" + rm -f "$DOKKU_ROOT/$APP/$CONTAINER_FILE" "$DOKKU_ROOT/$APP/$IP_FILE" "$DOKKU_ROOT/$APP/$PORT_FILE" + fi + done +} + +cleanup_container_state "$@" diff --git a/plugins/00_dokku-standard/exec-app-json-scripts b/plugins/00_dokku-standard/exec-app-json-scripts index b6a6870de..7bb3e5809 100755 --- a/plugins/00_dokku-standard/exec-app-json-scripts +++ b/plugins/00_dokku-standard/exec-app-json-scripts @@ -42,7 +42,7 @@ execute_script() { COMMAND+=" rm -rf /tmp/cache ; " COMMAND+=" ln -sf /cache /tmp/cache ; " COMMAND+=" fi ; " - COMMAND+=" $SCRIPT_CMD ;" + COMMAND+=" $SCRIPT_CMD || exit 1;" COMMAND+=" if [[ -d '/cache' ]]; then " COMMAND+=" echo removing installation cache... ; " COMMAND+=" rm -f /tmp/cache ; " diff --git a/plugins/00_dokku-standard/install b/plugins/00_dokku-standard/install index 9ef25cf45..b129367b7 100755 --- a/plugins/00_dokku-standard/install +++ b/plugins/00_dokku-standard/install @@ -30,7 +30,8 @@ if [[ $(systemctl 2> /dev/null) =~ -\.mount ]]; then cat< /etc/systemd/system/dokku-redeploy.service [Unit] Description=Dokku app redeploy service -After=docker.target +Requires=docker.service +After=docker.service [Service] Type=simple diff --git a/plugins/00_dokku-standard/plugin.toml b/plugins/00_dokku-standard/plugin.toml index b0a1b8939..21e999806 100644 --- a/plugins/00_dokku-standard/plugin.toml +++ b/plugins/00_dokku-standard/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core standard plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/00_dokku-standard/post-deploy b/plugins/00_dokku-standard/post-deploy index 7c765c3b3..50603555e 100755 --- a/plugins/00_dokku-standard/post-deploy +++ b/plugins/00_dokku-standard/post-deploy @@ -5,30 +5,11 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/00_dokku-standard/exec-app-json-scripts" exec_app_json_scripts() { declare desc="core app.json scripts execution" - local trigger="pre-deploy app_json_scripts" + local trigger="post-deploy app_json_scripts" local APP="$1"; local IMAGE_TAG="$4"; local PHASE_SCRIPT_KEY="postdeploy" dokku_log_info1 "Attempting to run scripts.dokku.$PHASE_SCRIPT_KEY from app.json (if defined)" execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY" } -cleanup_container_state() { - declare desc="core post-deploy state cleanup" - local trigger="post-deploy cleanup_container_state" - local APP="$1"; local PROCTYPES="$(egrep -v "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)" - local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 3 -n | xargs)" - - local CONTAINER_FILE - for CONTAINER_FILE in $CONTAINER_FILES; do - local CONTAINER_TYPE="$(awk -F '.' '{ print $2 }' <<< "$CONTAINER_FILE")" - if [[ "$(is_val_in_list "$CONTAINER_TYPE" "$PROCTYPES" " ")" == "false" ]]; then - dokku_log_info1 "Container type ($CONTAINER_TYPE) is no longer defined. Removing state" - local IP_FILE="${CONTAINER_FILE//CONTAINER/IP}" - local PORT_FILE="${CONTAINER_FILE//CONTAINER/PORT}" - rm -f "$DOKKU_ROOT/$APP/$CONTAINER_FILE" "$DOKKU_ROOT/$APP/$IP_FILE" "$DOKKU_ROOT/$APP/$PORT_FILE" - fi - done -} - exec_app_json_scripts "$@" -cleanup_container_state "$@" diff --git a/plugins/20_events/core-post-deploy b/plugins/20_events/core-post-deploy new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/core-post-deploy @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/20_events/install b/plugins/20_events/install index 99be9dc24..6d070eb8f 100755 --- a/plugins/20_events/install +++ b/plugins/20_events/install @@ -12,7 +12,7 @@ flag_rsyslog_needs_restart=n # exits gracefully if the path already exists mkdir -m 775 -p "$DOKKU_LOGS_DIR" case "$DOKKU_DISTRO" in - arch|debian) + arch|debian|centos) chgrp dokku "$DOKKU_LOGS_DIR" ;; *) @@ -23,7 +23,7 @@ esac if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then touch "$DOKKU_EVENTS_LOGFILE" case "$DOKKU_DISTRO" in - arch|debian) + arch|debian|centos) chgrp dokku "$DOKKU_EVENTS_LOGFILE" ;; *) diff --git a/plugins/20_events/plugin.toml b/plugins/20_events/plugin.toml index 8221c20a6..4e15db2c6 100644 --- a/plugins/20_events/plugin.toml +++ b/plugins/20_events/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core events logging plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/apps/plugin.toml b/plugins/apps/plugin.toml index abda804a0..e79c48f60 100644 --- a/plugins/apps/plugin.toml +++ b/plugins/apps/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core apps plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/apps/subcommands/rename b/plugins/apps/subcommands/rename index 7ad59b08d..34da3df31 100755 --- a/plugins/apps/subcommands/rename +++ b/plugins/apps/subcommands/rename @@ -13,11 +13,11 @@ apps_rename_cmd() { local NEW_APP="$3" local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache" - mkdir -p "$DOKKU_ROOT/$NEW_APP" if [[ -d "$OLD_CACHE_DIR" ]] && ! rmdir "$OLD_CACHE_DIR"; then docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$OLD_CACHE_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache fi rm -rf "$OLD_CACHE_DIR" + apps_create "$NEW_APP" cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP" DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP" [[ -f "$DOKKU_ROOT/$NEW_APP/URLS" ]] && sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/URLS" diff --git a/plugins/build-env/plugin.toml b/plugins/build-env/plugin.toml index ade77a4a7..92ce826fe 100644 --- a/plugins/build-env/plugin.toml +++ b/plugins/build-env/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core build-env plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/certs/functions b/plugins/certs/functions index b64a14a56..55c0ea953 100755 --- a/plugins/certs/functions +++ b/plugins/certs/functions @@ -2,6 +2,39 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +certs_info_cmd() { + # This is here because it's used in both the info and the default + declare desc="prints SSL certificate info for app" + local cmd="certs:info" + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" + verify_app_name "$2" + local APP="$2"; local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" + + if [[ -n "$APP_SSL_PATH" ]]; then + dokku_log_info1 "Fetching SSL Endpoint info for $APP..." + dokku_log_info1 "Certificate details:" + dokku_log_info2 "Common Name(s): " + + for domain in $(get_ssl_hostnames "$APP" | xargs); do + dokku_log_info2 " $domain" + done + + dokku_log_info2 "Expires At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not After :" | awk -F " : " '{ print $2 }')" + dokku_log_info2 "Issuer: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g")" + dokku_log_info2 "Starts At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not Before:" | awk -F ": " '{ print $2 }')" + dokku_log_info2 "Subject: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -subject | sed -e "s:subject= ::g"| sed -e "s:^/::g" | sed -e "s:/:; :g")" + local SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" + if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then + local SSL_SELF_SIGNED="verified by a certificate authority." + else + local SSL_SELF_SIGNED="self signed." + fi + dokku_log_info2 "SSL certificate is $SSL_SELF_SIGNED" + else + dokku_log_info1 "$APP does not have an SSL endpoint" + fi +} + is_ssl_enabled() { declare desc="returns 0 if ssl is enabled for given app" local APP=$1; verify_app_name "$APP" @@ -26,6 +59,6 @@ get_ssl_hostnames() { else local SSL_HOSTNAMES=$SSL_HOSTNAME fi - echo -e "$SSL_HOSTNAMES" + echo -e "$SSL_HOSTNAMES" | sort -u return 0 } diff --git a/plugins/certs/plugin.toml b/plugins/certs/plugin.toml index cc275d6b9..b0caec7f9 100644 --- a/plugins/certs/plugin.toml +++ b/plugins/certs/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core certificate management plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/certs/subcommands/add b/plugins/certs/subcommands/add index 07601378c..c705d1cde 100755 --- a/plugins/certs/subcommands/add +++ b/plugins/certs/subcommands/add @@ -72,7 +72,6 @@ certs_set() { cp "$KEY_FILE" "$APP_SSL_PATH/server.key" chmod 750 "$APP_SSL_PATH" chmod 640 "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.key" - cd "$DOKKU_ROOT" plugn trigger post-certs-update "$APP" plugn trigger post-domains-update "$APP" } diff --git a/plugins/certs/subcommands/default b/plugins/certs/subcommands/default new file mode 100644 index 000000000..5eabd33b8 --- /dev/null +++ b/plugins/certs/subcommands/default @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/certs/functions" + +certs_main_cmd() { + declare desc="an alias for certs:info" + local cmd="certs" + certs_info_cmd "$@" +} + +certs_main_cmd "$@" diff --git a/plugins/certs/subcommands/generate b/plugins/certs/subcommands/generate index daa2caed8..10349e9f9 100755 --- a/plugins/certs/subcommands/generate +++ b/plugins/certs/subcommands/generate @@ -22,14 +22,15 @@ certs_generate_cmd() { mkdir -p "$APP_SSL_PATH" dokku_log_info1 "Installing certificate and key..." - mv -f "$CERTS_GENERATE_TMP_WORK_DIR/server.key" "$CERTS_GENERATE_TMP_WORK_DIR/server.crt" "$APP_SSL_PATH" + mv -f "$CERTS_GENERATE_TMP_WORK_DIR/server.crt" "$CERTS_GENERATE_TMP_WORK_DIR/server.csr" "$CERTS_GENERATE_TMP_WORK_DIR/server.key" "$APP_SSL_PATH" chmod 750 "$APP_SSL_PATH" - chmod 640 "$APP_SSL_PATH/server.key" "$APP_SSL_PATH/server.crt" + chmod 640 "$APP_SSL_PATH/server.crt" "$APP_SSL_PATH/server.csr" "$APP_SSL_PATH/server.key" + plugn trigger post-certs-update "$APP" [[ -n "$DOMAIN" ]] && (domains_add "$APP" "$DOMAIN" || plugn trigger post-domains-update "$APP") dokku_log_info1 "The following is a certificate signing request that can be used" dokku_log_info1 "to generate an 'officially' signed SSL certificate for $APP at $DOMAIN" dokku_log_info1 "by a CA of your choosing." - cat server.csr + cat "$APP_SSL_PATH/server.csr" else dokku_log_info1 "$APP has an SSL endpoint already defined" fi diff --git a/plugins/certs/subcommands/info b/plugins/certs/subcommands/info index cfda760d8..77fd90b7c 100755 --- a/plugins/certs/subcommands/info +++ b/plugins/certs/subcommands/info @@ -3,36 +3,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/certs/functions" -certs_info_cmd() { - declare desc="prints SSL certificate info for app" - local cmd="certs:info" - [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" - verify_app_name "$2" - local APP="$2"; local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls" - - if [[ -n "$APP_SSL_PATH" ]]; then - dokku_log_info1 "Fetching SSL Endpoint info for $APP..." - dokku_log_info1 "Certificate details:" - dokku_log_info2 "Common Name(s): " - - for domain in $(get_ssl_hostnames "$APP" | xargs); do - dokku_log_info2 " $domain" - done - - dokku_log_info2 "Expires At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not After :" | awk -F " : " '{ print $2 }')" - dokku_log_info2 "Issuer: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Issuer:" | xargs | sed -e "s/Issuer: //g")" - dokku_log_info2 "Starts At: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -text | grep "Not Before:" | awk -F ": " '{ print $2 }')" - dokku_log_info2 "Subject: $(openssl x509 -in "$APP_SSL_PATH/server.crt" -noout -subject | sed -e "s:subject= ::g"| sed -e "s:^/::g" | sed -e "s:/:; :g")" - local SSL_VERIFY_OUTPUT="$(openssl verify -verbose -purpose sslserver "$APP_SSL_PATH/server.crt" | awk -F ':' '{ print $2 }' | tail -1 | xargs || true)" - if [[ "$SSL_VERIFY_OUTPUT" == "OK" ]]; then - local SSL_SELF_SIGNED="verified by a certificate authority." - else - local SSL_SELF_SIGNED="self signed." - fi - dokku_log_info2 "SSL certificate is $SSL_SELF_SIGNED" - else - dokku_log_info1 "$APP does not have an SSL endpoint" - fi -} - certs_info_cmd "$@" diff --git a/plugins/checks/commands b/plugins/checks/commands index 2400b5ee0..5f27055ac 100755 --- a/plugins/checks/commands +++ b/plugins/checks/commands @@ -16,7 +16,7 @@ help_content } if [[ $1 = "checks:help" ]] ; then - echo -e 'Usage: dokku checks[:COMAND]' + echo -e 'Usage: dokku checks[:COMMAND]' echo '' echo 'Manage zero-downtime settings.' echo '' diff --git a/plugins/checks/plugin.toml b/plugins/checks/plugin.toml index 1b4d3b6b7..bf1d75246 100644 --- a/plugins/checks/plugin.toml +++ b/plugins/checks/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core checks plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/common/functions b/plugins/common/functions index facc6bc17..20cb21c46 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -251,7 +251,12 @@ parse_args() { declare desc="top-level cli arg parser" local next_index=1; local skip=false; local args=("$@") for arg in "$@"; do - $skip && skip=false && continue + if [[ "$skip" == "true" ]]; then + next_index=$(( next_index + 1 )) + skip=false + continue + fi + case "$arg" in --quiet) export DOKKU_QUIET_OUTPUT=1 @@ -272,7 +277,7 @@ parse_args() { export DOKKU_APP_NAME=${args[$next_index]}; skip=true ;; esac - local next_index=$(( next_index + 1 )) + next_index=$(( next_index + 1 )) done return 0 } @@ -554,6 +559,8 @@ dokku_deploy_cmd() { dokku_log_info2 "stopping $APP.$PROC_TYPE ($cid)" # shellcheck disable=SC2086 docker stop $DOCKER_STOP_TIME_ARG "$cid" &> /dev/null + # remove cid from oldids to skip the old container finish processing + oldids="$(remove_val_from_list "$cid" "$oldids" " ")" done fi @@ -651,6 +658,7 @@ dokku_deploy_cmd() { done < "$DOKKU_SCALE_FILE" dokku_log_info1 "Running post-deploy" + plugn trigger core-post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG" plugn trigger post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG" # kill the old container diff --git a/plugins/common/plugin.toml b/plugins/common/plugin.toml index 9a1675ca7..6aa57777e 100644 --- a/plugins/common/plugin.toml +++ b/plugins/common/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core common plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/config/functions b/plugins/config/functions index c97ff7c57..908f6a7af 100755 --- a/plugins/config/functions +++ b/plugins/config/functions @@ -150,7 +150,7 @@ config_get() { config_create "$ENV_FILE" if [[ ! -s $ENV_FILE ]]; then - return 0 + return 1 fi local KEY="${*: -1}" diff --git a/plugins/config/plugin.toml b/plugins/config/plugin.toml index 4f87dd4ea..d2e907e8b 100644 --- a/plugins/config/plugin.toml +++ b/plugins/config/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core config plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/docker-options/plugin.toml b/plugins/docker-options/plugin.toml index a802b0fc4..fb4500136 100644 --- a/plugins/docker-options/plugin.toml +++ b/plugins/docker-options/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core docker-options plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/domains/commands b/plugins/domains/commands index 7504678f7..5b2018369 100755 --- a/plugins/domains/commands +++ b/plugins/domains/commands @@ -15,6 +15,8 @@ case "$1" in domains:enable , Enable VHOST support domains:remove [ ...], Remove domains from app domains:remove-global [ ...], Remove global domain names + domains:set [ ...], Set domains for app + domains:set-global [ ...], Set global domain names help_content } diff --git a/plugins/domains/functions b/plugins/domains/functions index 2cc3a78a4..51abd1a16 100755 --- a/plugins/domains/functions +++ b/plugins/domains/functions @@ -85,7 +85,7 @@ domains_add() { fi done - if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then + if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then domains_enable "$APP" --no-restart fi @@ -105,12 +105,34 @@ domains_remove() { plugn trigger post-domains-update "$APP" "remove" "$@" } +domains_set() { + declare desc="set list of domains for app" + verify_app_name "$1" + local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" + + shift 1 + for DOMAIN in "$@"; do + if ! (is_valid_hostname "$DOMAIN"); then + dokku_log_fail "$DOMAIN is invalid. exiting..." + fi + done + + echo "$*" | tr " " "\n" > "$APP_VHOST_PATH" + dokku_log_info1 "Set $* for $APP" + + if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then + domains_enable "$APP" --no-restart + fi + + plugn trigger post-domains-update "$APP" "set" "$@" +} + domains_disable() { declare desc="disable domains/VHOST support" verify_app_name "$1" local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" - if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]];then + if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]]; then disable_app_vhost "$APP" else dokku_log_info1 "domains (VHOST) support is already disabled for app ($APP)" @@ -123,7 +145,7 @@ domains_enable() { local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST" local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")" - if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then + if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then if [[ -n "$DEFAULT_VHOSTS" ]]; then echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH" fi @@ -148,7 +170,7 @@ domains_add_global() { if [[ $(egrep -w "^$DOMAIN$" "$GLOBAL_VHOST_PATH" > /dev/null 2>&1; echo $?) -eq 0 ]]; then dokku_log_info1 "Skipping: $DOMAIN already added" else - echo "$DOMAIN" >> "$GLOBAL_VHOST_PATH" + sed -i -e "\$a\\$DOMAIN" "$GLOBAL_VHOST_PATH" dokku_log_info1 "Added $DOMAIN" fi done @@ -163,3 +185,17 @@ domains_remove_global() { dokku_log_info1 "Removed $DOMAIN" done } + +domains_set_global() { + declare desc="set list of global domains" + local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST" + + for DOMAIN in "$@"; do + if ! (is_valid_hostname "$DOMAIN"); then + dokku_log_fail "$DOMAIN is invalid. exiting..." + fi + done + + echo "$*" | tr " " "\n" > "$GLOBAL_VHOST_PATH" + dokku_log_info1 "Set $*" +} diff --git a/plugins/domains/plugin.toml b/plugins/domains/plugin.toml index a16a166ce..dc46154f6 100644 --- a/plugins/domains/plugin.toml +++ b/plugins/domains/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core domains plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/domains/subcommands/default b/plugins/domains/subcommands/default index 011a1c292..c046e7fac 100755 --- a/plugins/domains/subcommands/default +++ b/plugins/domains/subcommands/default @@ -12,6 +12,11 @@ domains_main_cmd() { dokku_log_info2_quiet "Global Domain Name" get_global_vhosts fi + + if [[ "$APP" == "--global" ]]; then + return + fi + if [[ -n "$APP" ]]; then verify_app_name "$APP" if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then diff --git a/plugins/domains/subcommands/set b/plugins/domains/subcommands/set new file mode 100755 index 000000000..6a7ba21e8 --- /dev/null +++ b/plugins/domains/subcommands/set @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/domains/functions" + +domains_set_cmd() { + declare desc="set domains for app via command line" + local cmd="domains:set" + [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" + [[ -z $3 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 [ ...]" + + shift 1 + domains_set "$@" +} + +domains_set_cmd "$@" diff --git a/plugins/domains/subcommands/set-global b/plugins/domains/subcommands/set-global new file mode 100755 index 000000000..665990104 --- /dev/null +++ b/plugins/domains/subcommands/set-global @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/domains/functions" + +domains_set_global_cmd() { + declare desc="set global domain names via command line" + local cmd="domains:set-global" + [[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 [ ...]" + + shift 1 + domains_set_global "$@" +} + +domains_set_global_cmd "$@" diff --git a/plugins/enter/plugin.toml b/plugins/enter/plugin.toml index 71417684a..c37818a91 100644 --- a/plugins/enter/plugin.toml +++ b/plugins/enter/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core enter plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/git/functions b/plugins/git/functions index 33158d646..96ce9b9aa 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -28,7 +28,7 @@ git_build_app_repo() { git remote add origin "$DOKKU_ROOT/$APP" &> /dev/null git fetch --depth=1 origin "refs/tags/$TMP_TAG" &> /dev/null git reset --hard FETCH_HEAD &> /dev/null - git submodule update --init --recursive &> /dev/null + suppress_output git submodule update --init --recursive GIT_DIR="$DOKKU_ROOT/$APP" git tag -d "$TMP_TAG" &> /dev/null || true find -name .git -prune -exec rm -rf {} \; > /dev/null @@ -41,6 +41,20 @@ git_build_app_repo() { fi } +suppress_output() { + declare desc="suppress all output from a given command unless there is an error" + local TMP_COMMAND_OUTPUT + TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX") + trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT + + "$@" > "$TMP_COMMAND_OUTPUT" 2>&1 || { + local exit_code="$?" + cat "$TMP_COMMAND_OUTPUT" + return "$exit_code" + } + return 0 +} + git_hook_cmd() { declare desc="kick off receive-app trigger from git prereceive hook" local cmd="git-hook" diff --git a/plugins/git/plugin.toml b/plugins/git/plugin.toml index e045d49d2..7a4d20407 100644 --- a/plugins/git/plugin.toml +++ b/plugins/git/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core git plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/logs/plugin.toml b/plugins/logs/plugin.toml index 8913ebada..f07495e97 100644 --- a/plugins/logs/plugin.toml +++ b/plugins/logs/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core logs plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/named-containers/post-deploy b/plugins/named-containers/core-post-deploy similarity index 92% rename from plugins/named-containers/post-deploy rename to plugins/named-containers/core-post-deploy index 2489b71ce..2d84b28c3 100755 --- a/plugins/named-containers/post-deploy +++ b/plugins/named-containers/core-post-deploy @@ -2,9 +2,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -named_containers_post_deploy() { +named_containers_core_post_deploy() { declare desc="names deployed app container is consistent manner" - local trigger="named_containers_post_deploy" + local trigger="named_containers_core_post_deploy" local APP="$1"; local APP_ROOT="$DOKKU_ROOT/$APP" local container @@ -38,4 +38,4 @@ named_containers_post_deploy() { shopt -u nullglob } -named_containers_post_deploy "$@" +named_containers_core_post_deploy "$@" diff --git a/plugins/named-containers/plugin.toml b/plugins/named-containers/plugin.toml index 6488244b6..7519949ea 100644 --- a/plugins/named-containers/plugin.toml +++ b/plugins/named-containers/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core named containers plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/nginx-vhosts/commands b/plugins/nginx-vhosts/commands index f7911fc25..2995231d7 100755 --- a/plugins/nginx-vhosts/commands +++ b/plugins/nginx-vhosts/commands @@ -1,26 +1,14 @@ #!/usr/bin/env bash [[ " help nginx:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" case "$1" in help | nginx:help) - help_content_func () { - declare desc="return nginx plugin help content" - cat<, (Re)builds nginx config for given app - nginx:access-logs [-t], Show the nginx access logs for an application (-t follows) - nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) -help_content - } + if [[ $1 = "nginx:help" ]] ; then - echo -e 'Usage: dokku nginx[:COMMAND]' - echo '' - echo 'Interact with Dokku'"'"'s Nginx proxy.' - echo '' - echo 'Additional commands:' - help_content_func | sort | column -c2 -t -s, + help_formatted else help_content_func fi diff --git a/plugins/nginx-vhosts/post-deploy b/plugins/nginx-vhosts/core-post-deploy similarity index 81% rename from plugins/nginx-vhosts/post-deploy rename to plugins/nginx-vhosts/core-post-deploy index f716b0715..7bb7db877 100755 --- a/plugins/nginx-vhosts/post-deploy +++ b/plugins/nginx-vhosts/core-post-deploy @@ -5,9 +5,9 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_post_deploy() { - declare desc="nginx-vhosts post-deploy plugin trigger" - local trigger="nginx_post_deploy" +nginx_core_post_deploy() { + declare desc="nginx-vhosts core-post-deploy plugin trigger" + local trigger="nginx_core_post_deploy" local APP="$1" if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then @@ -21,5 +21,5 @@ nginx_post_deploy() { } if [[ "$(get_app_proxy_type "$1")" == "nginx" ]]; then - nginx_post_deploy "$@" + nginx_core_post_deploy "$@" fi diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index 044c2d0dd..8f1af2c40 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -6,6 +6,25 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" +help_formatted (){ + echo -e 'Usage: dokku nginx[:COMMAND]' + echo '' + echo 'Interact with Dokku'"'"'s Nginx proxy.' + echo '' + echo 'Additional commands:' + help_content_func | sort | column -c2 -t -s, +} + +help_content_func () { + declare desc="return nginx plugin help content" + cat<, (Re)builds nginx config for given app + nginx:access-logs [-t], Show the nginx access logs for an application (-t follows) + nginx:error-logs [-t], Show the nginx error logs for an application (-t follows) +help_content + } + validate_nginx() { declare desc="validate entire nginx config" set +e @@ -39,9 +58,9 @@ restart_nginx() { sudo /sbin/service nginx reload > /dev/null ;; - arch) + arch|centos) sudo /usr/bin/systemctl reload nginx - ;; + ;; esac } @@ -148,7 +167,7 @@ get_custom_nginx_template() { } is_spdy_enabled() { - declare desc="detects whether the installed nginx version has spdy or http2 support" + declare desc="detects whether the installed nginx version has spdy support" local NGINX_VERSION="$1" local MAJOR_VERSION MINOR_VERSION PATCH_VERSION local HAS_SUPPORT=true @@ -174,6 +193,33 @@ is_spdy_enabled() { echo $HAS_SUPPORT } +is_http2_enabled() { + declare desc="detects whether the installed nginx version has http2 support" + local NGINX_VERSION="$1" + local MAJOR_VERSION MINOR_VERSION PATCH_VERSION + local HAS_SUPPORT=false + + if ! which nginx > /dev/null 2>&1; then + echo $HAS_SUPPORT + return + fi + + MAJOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[1]}') + MINOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[2]}') + PATCH_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[3]}') + if [[ "$MAJOR_VERSION" -ge "2" ]]; then + HAS_SUPPORT=true + elif [[ "$MAJOR_VERSION" -eq "1" ]]; then + if [[ "$MINOR_VERSION" -eq "11" ]] && [[ "$PATCH_VERSION" -ge "5" ]]; then + HAS_SUPPORT=true + elif [[ "$MINOR_VERSION" -ge "12" ]]; then + HAS_SUPPORT=true + fi + fi + + echo $HAS_SUPPORT +} + nginx_build_config() { declare desc="build nginx config to proxy app containers using sigil" local APP="$1"; verify_app_name "$APP" @@ -245,11 +291,19 @@ nginx_build_config() { else local SSL_VHOSTS=$(< "$DOKKU_ROOT/HOSTNAME") fi - local SSL_SERVER_NAME=$(echo "$SSL_VHOSTS" | xargs) + local SSL_SERVER_NAME + local host + for host in $SSL_VHOSTS; do + # SSL_SERVER_NAME should only contain items not in NOSSL_SERVER_NAME + if [[ ! $NOSSL_SERVER_NAME =~ (^|[[:space:]])$host($|[[:space:]]) ]]; then + SSL_SERVER_NAME="${host}${SSL_SERVER_NAME:+ $SSL_SERVER_NAME}" + fi + done fi local NGINX_VERSION="$(nginx -v 2>&1 | cut -d'/' -f 2)" local SPDY_SUPPORTED="$(is_spdy_enabled "$NGINX_VERSION")" + local HTTP2_SUPPORTED="$(is_http2_enabled "$NGINX_VERSION")" eval "$(config_export app "$APP")" local SIGIL_PARAMS=(-f $NGINX_TEMPLATE APP="$APP" DOKKU_ROOT="$DOKKU_ROOT" @@ -257,6 +311,7 @@ nginx_build_config() { DOKKU_APP_LISTENERS="$DOKKU_APP_LISTENERS" PASSED_LISTEN_IP_PORT="$PASSED_LISTEN_IP_PORT" SPDY_SUPPORTED="$SPDY_SUPPORTED" + HTTP2_SUPPORTED="$HTTP2_SUPPORTED" DOKKU_APP_LISTEN_PORT="$DOKKU_APP_LISTEN_PORT" DOKKU_APP_LISTEN_IP="$DOKKU_APP_LISTEN_IP" APP_SSL_PATH="$APP_SSL_PATH" SSL_INUSE="$SSL_INUSE" SSL_SERVER_NAME="$SSL_SERVER_NAME" NGINX_PORT="$NGINX_PORT" NGINX_SSL_PORT="$NGINX_SSL_PORT" RAW_TCP_PORTS="$RAW_TCP_PORTS" diff --git a/plugins/nginx-vhosts/install b/plugins/nginx-vhosts/install index e08840d2d..8b4d53217 100755 --- a/plugins/nginx-vhosts/install +++ b/plugins/nginx-vhosts/install @@ -17,6 +17,11 @@ case "$DOKKU_DISTRO" in arch) echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl reload nginx, /usr/sbin/nginx -t" > /etc/sudoers.d/dokku-nginx ;; + + centos) + echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl reload nginx, /usr/sbin/nginx -t" > /etc/sudoers.d/dokku-nginx + echo "Defaults:dokku !requiretty" >> /etc/sudoers.d/dokku-nginx + ;; esac chmod 0440 /etc/sudoers.d/dokku-nginx @@ -66,10 +71,8 @@ case "$DOKKU_DISTRO" in "$NGINX_INIT" nginx start || "$NGINX_INIT" nginx reload ;; - arch) + arch|centos) NGINX_INIT="/usr/bin/systemctl" "$NGINX_INIT" start nginx || "$NGINX_INIT" reload nginx ;; esac - - diff --git a/plugins/nginx-vhosts/plugin.toml b/plugins/nginx-vhosts/plugin.toml index b7beac324..a9d71618b 100644 --- a/plugins/nginx-vhosts/plugin.toml +++ b/plugins/nginx-vhosts/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core nginx-vhosts plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/nginx-vhosts/subcommands/default b/plugins/nginx-vhosts/subcommands/default new file mode 100644 index 000000000..30cb86061 --- /dev/null +++ b/plugins/nginx-vhosts/subcommands/default @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" + +nginx_main_cmd() { + declare desc="display nginx plugin help content" + local cmd="nginx" + help_formatted +} + +nginx_main_cmd "$@" diff --git a/plugins/nginx-vhosts/templates/nginx.conf.sigil b/plugins/nginx-vhosts/templates/nginx.conf.sigil index 1d00745b0..6638afe37 100644 --- a/plugins/nginx-vhosts/templates/nginx.conf.sigil +++ b/plugins/nginx-vhosts/templates/nginx.conf.sigil @@ -38,8 +38,8 @@ server { } {{ else if eq $scheme "https"}} server { - listen [::]:{{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else }}http2{{ end }}; - listen {{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else }}http2{{ end }}; + listen [::]:{{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else if eq $.HTTP2_SUPPORTED "true" }}http2{{ end }}; + listen {{ $listen_port }} ssl {{ if eq $.SPDY_SUPPORTED "true" }}spdy{{ else if eq $.HTTP2_SUPPORTED "true" }}http2{{ end }}; {{ if $.SSL_SERVER_NAME }}server_name {{ $.SSL_SERVER_NAME }}; {{ end }} {{ if $.NOSSL_SERVER_NAME }}server_name {{ $.NOSSL_SERVER_NAME }}; {{ end }} access_log /var/log/nginx/{{ $.APP }}-access.log; diff --git a/plugins/plugin/functions b/plugins/plugin/functions index be9bf6d16..3b814d7f8 100755 --- a/plugins/plugin/functions +++ b/plugins/plugin/functions @@ -70,6 +70,7 @@ uninstall_plugin() { local PLUGIN="$1" [[ -e $PLUGIN_CORE_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Cannot uninstall a core plugin" [[ ! -e $PLUGIN_AVAILABLE_PATH/$PLUGIN ]] && dokku_log_fail "Plugin ($PLUGIN) is not currently installed" + plugn trigger uninstall "$PLUGIN" plugn uninstall "$PLUGIN" dokku_log_info1_quiet "Plugin $PLUGIN uninstalled" } diff --git a/plugins/plugin/plugin.toml b/plugins/plugin/plugin.toml index 7e2660bd1..c51efc9f6 100644 --- a/plugins/plugin/plugin.toml +++ b/plugins/plugin/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core plugin plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/proxy/plugin.toml b/plugins/proxy/plugin.toml index c046c6ad6..9fac76603 100644 --- a/plugins/proxy/plugin.toml +++ b/plugins/proxy/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core proxy plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/proxy/subcommands/default b/plugins/proxy/subcommands/default index cd913904c..4e867c850 100755 --- a/plugins/proxy/subcommands/default +++ b/plugins/proxy/subcommands/default @@ -6,13 +6,14 @@ source "$PLUGIN_AVAILABLE_PATH/proxy/functions" proxy_main_cmd() { declare desc="displays app proxy implementation via command line" local cmd="proxy" - local ALL_APPS=$(dokku_apps) - if [[ -n "$2" ]]; then - local APP="$2" + [[ "$1" == "$cmd" ]] && shift 1 + local APPS=$(dokku_apps) + if [[ -n "$1" ]]; then + local APPS="$1" fi - local APPS=${APP:="$ALL_APPS"} dokku_col_log_info1_quiet "App Name" "Proxy Type" + local app for app in $APPS; do verify_app_name "$app" dokku_col_log_msg "$app" "$(get_app_proxy_type "$app")" diff --git a/plugins/ps/post-deploy b/plugins/ps/core-post-deploy similarity index 69% rename from plugins/ps/post-deploy rename to plugins/ps/core-post-deploy index f66170f6f..1fc2e2b6b 100755 --- a/plugins/ps/post-deploy +++ b/plugins/ps/core-post-deploy @@ -4,13 +4,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" -ps_post_deploy() { - declare desc="ps post-deploy plugin trigger" - local trigger="ps_post_deploy" +ps_core_post_deploy() { + declare desc="ps core-post-deploy plugin trigger" + local trigger="ps_core_post_deploy" local APP="$1" remove_procfile "$APP" config_set --no-restart "$APP" DOKKU_APP_RESTORE=1 } -ps_post_deploy "$@" +ps_core_post_deploy "$@" diff --git a/plugins/ps/plugin.toml b/plugins/ps/plugin.toml index f25ef3c61..d8f492ffe 100644 --- a/plugins/ps/plugin.toml +++ b/plugins/ps/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core ps plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/ps/subcommands/restore b/plugins/ps/subcommands/restore index 0b7b83729..818c3d980 100755 --- a/plugins/ps/subcommands/restore +++ b/plugins/ps/subcommands/restore @@ -7,11 +7,20 @@ source "$PLUGIN_AVAILABLE_PATH/ps/functions" ps_restore_cmd() { declare desc="starts all apps with DOKKU_APP_RESTORE not set to 0 via command line" local cmd="ps:restore" + + if which parallel > /dev/null 2>&1; then + dokku_apps | parallel dokku ps:start + return + fi + for app in $(dokku_apps); do local DOKKU_APP_RESTORE=$(config_get "$app" DOKKU_APP_RESTORE || true) if [[ $DOKKU_APP_RESTORE != 0 ]]; then echo "Restoring app $app ..." - ps_start "$app" + if ps_start "$app"; then + continue + fi + dokku_log_warn "dokku ps:restore ${app} failed" fi done } diff --git a/plugins/repo/commands b/plugins/repo/commands index 5025f89f5..816768bf3 100755 --- a/plugins/repo/commands +++ b/plugins/repo/commands @@ -7,7 +7,7 @@ case "$1" in help_content_func () { declare desc="return repo plugin help content" cat<, Runs 'git gc --agressive' against the application's repo + repo:gc , Runs 'git gc --aggressive' against the application's repo repo:purge-cache , Deletes the contents of the build cache stored in the repository help_content } diff --git a/plugins/repo/plugin.toml b/plugins/repo/plugin.toml index f354ceff0..2498cb82f 100644 --- a/plugins/repo/plugin.toml +++ b/plugins/repo/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core repo plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/repo/subcommands/gc b/plugins/repo/subcommands/gc index 0fd3f281e..fbeb9b153 100755 --- a/plugins/repo/subcommands/gc +++ b/plugins/repo/subcommands/gc @@ -3,7 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" repo_gc() { - declare desc="runs 'git gc --agressive' against the application's repo" + declare desc="runs 'git gc --aggressive' against the application's repo" local cmd="repo:gc" [[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on" local APP="$2"; local APP_DIR="$DOKKU_ROOT/$APP" diff --git a/plugins/shell/plugin.toml b/plugins/shell/plugin.toml index 3e96e7c2e..2cc88f6aa 100644 --- a/plugins/shell/plugin.toml +++ b/plugins/shell/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core shell plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/ssh-keys/functions b/plugins/ssh-keys/functions index 32e7e971e..f45dce1ff 100755 --- a/plugins/ssh-keys/functions +++ b/plugins/ssh-keys/functions @@ -2,13 +2,29 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +list_ssh_keys() { + declare desc="List ssh key hashes" + local cmd="ssh-keys:list" + verify_ssh_key_file + sshcommand list dokku +} + verify_ssh_key_file() { declare desc="Test that public key is valid" [[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found." - ssh-keygen -l -f "${DOKKU_ROOT}/.ssh/authorized_keys" &> /dev/null || dokku_log_fail "${DOKKU_ROOT}/.ssh/authorized_keys failed ssh-keygen check." + local key line=0 + while read key ; do + line=$((line + 1)) + ssh-keygen -l -f /dev/stdin <<< "$key" &> /dev/null || dokku_log_fail "${DOKKU_ROOT}/.ssh/authorized_keys line $line failed ssh-keygen check." + done <"${DOKKU_ROOT}/.ssh/authorized_keys" } verify_ssh_key_exists() { declare desc="Test that public key exists" [[ -e ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found." } + +create_ssh_key_file() { + declare desc="Ensure the public key file exists" + touch "${DOKKU_ROOT}/.ssh/authorized_keys" +} diff --git a/plugins/ssh-keys/plugin.toml b/plugins/ssh-keys/plugin.toml index f6c7db1c3..1bf62a150 100644 --- a/plugins/ssh-keys/plugin.toml +++ b/plugins/ssh-keys/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core ssh-keys plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/ssh-keys/subcommands/add b/plugins/ssh-keys/subcommands/add index 165993a25..4424c3004 100755 --- a/plugins/ssh-keys/subcommands/add +++ b/plugins/ssh-keys/subcommands/add @@ -14,10 +14,15 @@ add_keys() { key_contents="$key_from_pipe" elif [[ -n "$key_file" ]]; then key_contents="$(cat "$key_file")" + ssh-keygen -lf /dev/stdin <<< "$key_contents" &> /dev/null || dokku_log_fail "Key from file is not a valid ssh public key" fi [[ -n "$name" && -n "$key_contents" ]] || dokku_log_fail "Two arguments are required if not piping, ie: dokku ssh-keys:add " + local count="$(wc -l <<< "$key_contents")" + [ "$count" -eq 1 ] || dokku_log_fail 'Too many keys provided, set one per invocation of dokku ssh-keys:add ' + create_ssh_key_file verify_ssh_key_exists echo "$key_contents" | sshcommand acl-add dokku "$name" || dokku_log_fail "sshcommand returned an error: $?" + verify_ssh_key_file } add_keys "$@" diff --git a/plugins/ssh-keys/subcommands/default b/plugins/ssh-keys/subcommands/default new file mode 100644 index 000000000..abdbaa619 --- /dev/null +++ b/plugins/ssh-keys/subcommands/default @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" + +ssh_keys_main_cmd() { + declare desc="an alias for ssh-keys:list" + local cmd="ssh-keys" + list_ssh_keys +} + +ssh_keys_main_cmd "$@" \ No newline at end of file diff --git a/plugins/ssh-keys/subcommands/list b/plugins/ssh-keys/subcommands/list index ce485bbd6..fb78c5e2a 100755 --- a/plugins/ssh-keys/subcommands/list +++ b/plugins/ssh-keys/subcommands/list @@ -3,11 +3,4 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions" -list_ssh_keys() { - declare desc="List ssh key hashes" - local cmd="ssh-keys:list" - verify_ssh_key_file - sshcommand list dokku -} - list_ssh_keys "$@" diff --git a/plugins/storage/functions b/plugins/storage/functions index 767059f13..d65daeb26 100755 --- a/plugins/storage/functions +++ b/plugins/storage/functions @@ -2,6 +2,16 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +storage_list_cmd() { + declare desc="List all bound mounts" + local cmd="storage:list" + local passed_phases="deploy" + [[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list." + verify_app_name "$2" && local APP="$2" + echo "$APP volume bind-mounts:" + get_bind_mounts "$(get_phase_file_path "$passed_phases")" +} + verify_paths() { declare desc="verifies storage paths" echo "$1" | grep -qe '^/.*\:/' || dokku_log_fail "Storage path must be two valid paths divided by colon." diff --git a/plugins/storage/plugin.toml b/plugins/storage/plugin.toml index b822d1c04..862e8342e 100644 --- a/plugins/storage/plugin.toml +++ b/plugins/storage/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core storage plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/storage/subcommands/default b/plugins/storage/subcommands/default new file mode 100644 index 000000000..194ef7942 --- /dev/null +++ b/plugins/storage/subcommands/default @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" + +storage_main_cmd() { + declare desc="an alias for storage:list" + local cmd="storage" + storage_list_cmd "$@" +} + +storage_main_cmd "$@" diff --git a/plugins/storage/subcommands/list b/plugins/storage/subcommands/list index ecaab29b0..a16999a38 100755 --- a/plugins/storage/subcommands/list +++ b/plugins/storage/subcommands/list @@ -4,14 +4,5 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/storage/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/docker-options/functions" -storage_list_cmd() { - declare desc="List all bound mounts" - local cmd="storage:list" - local passed_phases="deploy" - [[ ! $2 ]] && dokku_log_fail "storage:list requires an app to list." - verify_app_name "$2" && local APP="$2" - echo "$APP volume bind-mounts:" - get_bind_mounts "$(get_phase_file_path "$passed_phases")" -} storage_list_cmd "$@" diff --git a/plugins/tags/plugin.toml b/plugins/tags/plugin.toml index c5bc6d690..07231f6d2 100644 --- a/plugins/tags/plugin.toml +++ b/plugins/tags/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core tags plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/plugins/tar/functions b/plugins/tar/functions index 93b024645..a9c8aa049 100755 --- a/plugins/tar/functions +++ b/plugins/tar/functions @@ -24,7 +24,7 @@ tar_build() { tar -x -C "$TAR_BUILD_TMP_WORK_DIR" -f "$DOKKU_ROOT/$APP/src.tar" --strip-components="$BOGUS_PARTS" chmod -R u+r "$TAR_BUILD_TMP_WORK_DIR" - if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then + if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]] && [[ -z $(config_get "$APP" BUILDPACK_URL || true) ]]; then plugn trigger pre-receive-app "$APP" "dockerfile" "$TAR_BUILD_TMP_WORK_DIR" dokku_receive "$APP" "dockerfile" "$TAR_BUILD_TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/" else diff --git a/plugins/tar/plugin.toml b/plugins/tar/plugin.toml index 25b425fcc..bf5dc5000 100644 --- a/plugins/tar/plugin.toml +++ b/plugins/tar/plugin.toml @@ -1,4 +1,4 @@ [plugin] description = "dokku core tar plugin" -version = "0.7.2" +version = "0.8.0" [plugin.config] diff --git a/rpm.mk b/rpm.mk new file mode 100644 index 000000000..67d7662d9 --- /dev/null +++ b/rpm.mk @@ -0,0 +1,178 @@ +RPM_ARCHITECTURE = x86_64 +HEROKUISH_RPM_PACKAGE_NAME = herokuish-$(HEROKUISH_VERSION)-1.$(RPM_ARCHITECTURE).rpm +PLUGN_RPM_PACKAGE_NAME = plugn-$(PLUGN_VERSION)-1.$(RPM_ARCHITECTURE).rpm +SSHCOMMAND_RPM_PACKAGE_NAME = sshcommand-$(SSHCOMMAND_VERSION)-1.$(RPM_ARCHITECTURE).rpm +SIGIL_RPM_PACKAGE_NAME = gliderlabs-sigil-$(SIGIL_VERSION)-1.$(RPM_ARCHITECTURE).rpm + +.PHONY: rpm-all + +rpm-all: rpm-setup rpm-herokuish rpm-dokku rpm-plugn rpm-sshcommand rpm-sigil + mv /tmp/*.rpm . + @echo "Done" + +rpm-setup: + @echo "-> Installing rpm build requirements" + @sudo apt-get update -qq > /dev/null + @sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -qq -y gcc git build-essential wget ruby-dev ruby1.9.1 rpm > /dev/null 2>&1 + @command -v fpm > /dev/null || sudo gem install fpm --no-ri --no-rdoc + @ssh -o StrictHostKeyChecking=no git@github.com || true + +rpm-herokuish: + rm -rf /tmp/tmp /tmp/build $(HEROKUISH_RPM_PACKAGE_NAME) + mkdir -p /tmp/tmp /tmp/build + + @echo "-> Cloning repository" + git clone -q "https://github.com/$(HEROKUISH_REPO_NAME).git" \ + --branch "v$(HEROKUISH_VERSION)" /tmp/tmp/herokuish > /dev/null + rm -rf /tmp/tmp/herokuish/.git /tmp/tmp/herokuish/.gitignore + + @echo "-> Copying files into place" + mkdir -p "/tmp/build/var/lib" + cp -rf /tmp/tmp/herokuish /tmp/build/var/lib/herokuish + + @echo "-> Creating $(HEROKUISH_RPM_PACKAGE_NAME)" + sudo fpm -t rpm -s dir -C /tmp/build -n herokuish \ + -v $(HEROKUISH_VERSION) \ + -a $(RPM_ARCHITECTURE) \ + -p $(HEROKUISH_RPM_PACKAGE_NAME) \ + --depends 'docker-engine >= 1.9.1' \ + --depends 'sudo' \ + --after-install rpm/herokuish.postinst \ + --url "https://github.com/$(HEROKUISH_REPO_NAME)" \ + --description $(HEROKUISH_DESCRIPTION) \ + --license 'MIT License' \ + . + mv *.rpm /tmp + +rpm-dokku: + rm -rf /tmp/tmp /tmp/build dokku_*_$(RPM_ARCHITECTURE).rpm + mkdir -p /tmp/tmp /tmp/build + + mkdir -p /tmp/build/usr/bin + mkdir -p /tmp/build/usr/share/doc/dokku + mkdir -p /tmp/build/usr/share/dokku/contrib + mkdir -p /tmp/build/usr/share/lintian/overrides + mkdir -p /tmp/build/usr/share/man/man1 + mkdir -p /tmp/build/var/lib/dokku/core-plugins/available + + cp dokku /tmp/build/usr/bin + cp LICENSE /tmp/build/usr/share/doc/dokku/copyright + find . -name ".DS_Store" -depth -exec rm {} \; + cp -r plugins/* /tmp/build/var/lib/dokku/core-plugins/available + find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do touch /tmp/build/var/lib/dokku/core-plugins/available/$$plugin/.core; done + $(MAKE) help2man + $(MAKE) addman + cp /usr/local/share/man/man1/dokku.1 /tmp/build/usr/share/man/man1/dokku.1 + gzip -9 /tmp/build/usr/share/man/man1/dokku.1 + cp contrib/dokku-installer.py /tmp/build/usr/share/dokku/contrib +ifeq ($(DOKKU_VERSION),master) + git describe --tags > /tmp/build/var/lib/dokku/VERSION +else + echo $(DOKKU_VERSION) > /tmp/build/var/lib/dokku/VERSION +endif + cat /tmp/build/var/lib/dokku/VERSION | cut -d '-' -f 1 | cut -d 'v' -f 2 > /tmp/build/var/lib/dokku/STABLE_VERSION +ifneq (,$(findstring false,$(IS_RELEASE))) + sed -i.bak -e "s/^/`date +%s`-/" /tmp/build/var/lib/dokku/STABLE_VERSION && rm /tmp/build/var/lib/dokku/STABLE_VERSION.bak +endif +ifdef DOKKU_GIT_REV + echo "$(DOKKU_GIT_REV)" > /tmp/build/var/lib/dokku/GIT_REV +else + git rev-parse HEAD > /tmp/build/var/lib/dokku/GIT_REV +endif + + @echo "-> Creating rpm package" + VERSION=$$(cat /tmp/build/var/lib/dokku/STABLE_VERSION); \ + sudo fpm -t rpm -s dir -C /tmp/build -n dokku \ + -v "$$VERSION" \ + -a $(RPM_ARCHITECTURE) \ + -p "dokku-$$VERSION-1.x86_64.rpm" \ + --depends 'git' \ + --depends 'make' \ + --depends 'curl' \ + --depends 'gcc' \ + --depends 'man-db' \ + --depends 'sshcommand' \ + --depends 'gliderlabs-sigil' \ + --depends 'docker-engine >= 1.9.1' \ + --depends 'bind-utils' \ + --depends 'nginx' \ + --depends 'plugn' \ + --depends 'sudo' \ + --depends 'python' \ + --depends 'nc' \ + --after-install rpm/dokku.postinst \ + --url "https://github.com/$(DOKKU_REPO_NAME)" \ + --description $(DOKKU_DESCRIPTION) \ + --license 'MIT License' \ + . + mv *.rpm /tmp + +rpm-plugn: + rm -rf /tmp/tmp /tmp/build $(PLUGN_RPM_PACKAGE_NAME) + mkdir -p /tmp/tmp /tmp/build /tmp/build/usr/bin + + @echo "-> Downloading package" + wget -q -O /tmp/tmp/plugn-$(PLUGN_VERSION).tgz $(PLUGN_URL) + cd /tmp/tmp/ && tar zxf /tmp/tmp/plugn-$(PLUGN_VERSION).tgz + + @echo "-> Copying files into place" + cp /tmp/tmp/plugn /tmp/build/usr/bin/plugn && chmod +x /tmp/build/usr/bin/plugn + + @echo "-> Creating $(PLUGN_RPM_PACKAGE_NAME)" + sudo fpm -t rpm -s dir -C /tmp/build -n plugn \ + --version $(PLUGN_VERSION) \ + -a $(RPM_ARCHITECTURE) \ + --package $(PLUGN_RPM_PACKAGE_NAME) \ + --url "https://github.com/$(PLUGN_REPO_NAME)" \ + --category utils \ + --description "$$PLUGN_DESCRIPTION" \ + --license 'MIT License' \ + . + mv *.rpm /tmp + +rpm-sshcommand: + rm -rf /tmp/tmp /tmp/build $(SSHCOMMAND_RPM_PACKAGE_NAME) + mkdir -p /tmp/tmp /tmp/build /tmp/build/usr/bin + + @echo "-> Downloading package" + wget -q -O /tmp/tmp/sshcommand-$(SSHCOMMAND_VERSION) $(SSHCOMMAND_URL) + + @echo "-> Copying files into place" + mkdir -p "/tmp/build/usr/bin" + cp /tmp/tmp/sshcommand-$(SSHCOMMAND_VERSION) /tmp/build/usr/bin/sshcommand + chmod +x /tmp/build/usr/bin/sshcommand + + @echo "-> Creating $(SSHCOMMAND_RPM_PACKAGE_NAME)" + sudo fpm -t rpm -s dir -C /tmp/build -n sshcommand \ + --version $(SSHCOMMAND_VERSION) \ + -a $(RPM_ARCHITECTURE) \ + --package $(SSHCOMMAND_RPM_PACKAGE_NAME) \ + --url "https://github.com/$(SSHCOMMAND_REPO_NAME)" \ + --category admin \ + --description "$$SSHCOMMAND_DESCRIPTION" \ + --license 'MIT License' \ + . + mv *.rpm /tmp + +rpm-sigil: + rm -rf /tmp/tmp /tmp/build $(SIGIL_PACKAGE_NAME) + mkdir -p /tmp/tmp /tmp/build /tmp/build/usr/bin + + @echo "-> Downloading package" + wget -q -O /tmp/tmp/sigil-$(SIGIL_VERSION).tgz $(SIGIL_URL) + cd /tmp/tmp/ && tar zxf /tmp/tmp/sigil-$(SIGIL_VERSION).tgz + + @echo "-> Copying files into place" + cp /tmp/tmp/sigil /tmp/build/usr/bin/sigil && chmod +x /tmp/build/usr/bin/sigil + + @echo "-> Creating $(SIGIL_RPM_PACKAGE_NAME)" + sudo fpm -t rpm -s dir -C /tmp/build -n gliderlabs-sigil \ + --version $(SIGIL_VERSION) \ + -a $(RPM_ARCHITECTURE) \ + --package $(SIGIL_RPM_PACKAGE_NAME) \ + --url "https://github.com/$(SIGIL_REPO_NAME)" \ + --category utils \ + --description "$$SIGIL_DESCRIPTION" \ + --license 'MIT License' \ + . + mv *.rpm /tmp diff --git a/rpm/dokku.postinst b/rpm/dokku.postinst new file mode 100644 index 000000000..8638a9065 --- /dev/null +++ b/rpm/dokku.postinst @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set +o posix # rpm uses /bin/sh that forces bash in posix mode +set -eo pipefail; [[ $TRACE ]] && set -x + +setup-user() { + echo "Setting up dokku user" + getent passwd dokku >/dev/null || useradd -m -s /bin/bash dokku + mkdir -p "$DOKKU_ROOT/.ssh" + touch "$DOKKU_ROOT/.ssh/authorized_keys" + chown -R dokku:dokku "$DOKKU_ROOT/.ssh" + usermod -aG docker dokku +} + +setup-storage() { + echo "Setting up storage directories" + mkdir -p "${DOKKU_LIB_ROOT}/data" "${DOKKU_LIB_ROOT}/data/storage" + chown dokku:dokku -R "${DOKKU_LIB_ROOT}/data" +} + +setup-plugins() { + echo "Setting up plugin directories" + # should be replaced by `plugn init` + mkdir -p "${DOKKU_LIB_ROOT}/core-plugins/available" "${DOKKU_LIB_ROOT}/plugins/available" + mkdir -p "${DOKKU_LIB_ROOT}/core-plugins/enabled" "${DOKKU_LIB_ROOT}/plugins/enabled" + touch "${DOKKU_LIB_ROOT}/core-plugins/config.toml" "${DOKKU_LIB_ROOT}/plugins/config.toml" + + echo "Enabling all core plugins" + find "${DOKKU_LIB_ROOT}/core-plugins/available" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do + if [ ! -d "${DOKKU_LIB_ROOT}/plugins/available/$plugin" ]; then + ln -s "${DOKKU_LIB_ROOT}/core-plugins/available/$plugin" "${DOKKU_LIB_ROOT}/plugins/available/$plugin" + PLUGIN_PATH="${DOKKU_LIB_ROOT}/core-plugins" plugn enable "$plugin" + PLUGIN_PATH="${DOKKU_LIB_ROOT}/plugins" plugn enable "$plugin" + fi + done + find -L "${DOKKU_LIB_ROOT}" -type l -delete + chown dokku:dokku -R "${DOKKU_LIB_ROOT}/plugins" "${DOKKU_LIB_ROOT}/core-plugins" + + echo "Install all core plugins" + dokku plugin:install --core +} + +setup-sshcommand() { + echo "Ensure proper sshcommand path" + echo '/usr/bin/dokku' > "${DOKKU_ROOT}/.sshcommand" +} + +setup-version() { + rm -f "${DOKKU_ROOT}/VERSION" + cp "${DOKKU_LIB_ROOT}/STABLE_VERSION" "${DOKKU_ROOT}/VERSION" +} + +main() { + readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" + readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" + + setup-user + setup-storage + setup-plugins + setup-sshcommand + setup-version +} + +main diff --git a/rpm/herokuish.postinst b/rpm/herokuish.postinst new file mode 100644 index 000000000..e9c5db778 --- /dev/null +++ b/rpm/herokuish.postinst @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set +o posix # rpm uses /bin/sh that forces bash in posix mode + +main() { + echo 'Starting docker' + systemctl start docker + + sleep 5 + + count=$(sudo docker images | grep -c gliderlabs/herokuish) + if [ "$count" -ne 0 ]; then + echo 'Removing old herokuish image' + sudo docker rmi gliderlabs/herokuish + fi + + echo 'Importing herokuish into docker (around 5 minutes)' + sudo docker build -t gliderlabs/herokuish /var/lib/herokuish 1> /dev/null +} + +main diff --git a/tests/apps/multi/static/styles/main.scss b/tests/apps/multi/static/styles/main.scss index 93efb53fa..20b7ae981 100644 --- a/tests/apps/multi/static/styles/main.scss +++ b/tests/apps/multi/static/styles/main.scss @@ -1,4 +1,4 @@ -// override scss variables within bootsrap by delaring them +// override scss variables within bootsrap by declaring them // before importing bootstrap $brand-primary: #428bca !default; diff --git a/tests/unit/20_domains.bats b/tests/unit/20_domains.bats index 3aba4aa8f..dbbafae4e 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -146,6 +146,27 @@ teardown() { refute_line *.dokku.me } +@test "(domains) domains:set" { + run dokku domains:add $TEST_APP www.test.app.dokku.me test.app.dokku.me + echo "output: "$output + echo "status: "$status + assert_success + + run dokku domains:set $TEST_APP 2.app.dokku.me a--domain.with--hyphens + echo "output: "$output + echo "status: "$status + assert_success + + run dokku domains $TEST_APP + echo "output: "$output + echo "status: "$status + assert_success + refute_line www.test.app.dokku.me + refute_line test.app.dokku.me + assert_line 2.app.dokku.me + assert_line a--domain.with--hyphens +} + @test "(domains) domains:clear" { run dokku domains:add $TEST_APP test.app.dokku.me echo "output: "$output @@ -170,7 +191,7 @@ teardown() { echo "status: "$status assert_success - run bash -c "dokku domains | grep -q global.dokku.me" + run bash -c "dokku domains | egrep -qw '^global.dokku.me\$'" echo "output: "$output echo "status: "$status assert_success @@ -217,13 +238,34 @@ teardown() { assert_success dokku domains:setup $TEST_APP - run bash -c "dokku domains $TEST_APP | grep -q ${TEST_APP}.global1.dokku.me" + + run dokku domains $TEST_APP + echo "output: "$output + echo "status: "$status + assert_success + assert_line ${TEST_APP}.global1.dokku.me + assert_line ${TEST_APP}.global2.dokku.me +} + +@test "(domains) domains:set-global" { + run dokku domains:add-global global1.dokku.me global2.dokku.me echo "output: "$output echo "status: "$status assert_success - run bash -c "dokku domains $TEST_APP | grep -q ${TEST_APP}.global2.dokku.me" + run dokku domains:set-global global3.dokku.me global4.dokku.me echo "output: "$output echo "status: "$status assert_success + + dokku domains:setup $TEST_APP + + run dokku domains $TEST_APP + echo "output: "$output + echo "status: "$status + assert_success + refute_line ${TEST_APP}.global1.dokku.me + refute_line ${TEST_APP}.global2.dokku.me + assert_line ${TEST_APP}.global3.dokku.me + assert_line ${TEST_APP}.global4.dokku.me } diff --git a/tests/unit/30_ssh_keys.bats b/tests/unit/30_ssh_keys.bats index d3f157c04..6f4b3e287 100644 --- a/tests/unit/30_ssh_keys.bats +++ b/tests/unit/30_ssh_keys.bats @@ -4,10 +4,31 @@ load test_helper setup() { global_setup + + # create a temporary key and save in a variable create_key + local KEY="$(cat /tmp/testkey.pub)" + destroy_key + + # now create key that will be really used + create_key + + # the temporary key is useful for adding in the file with two keys + # useful for a negative test + { cat /tmp/testkey.pub ; echo "$KEY" ; } > /tmp/testkey-double.pub + + # another negative test input + echo 'invalid!' > /tmp/testkey-invalid.pub + + # save current authorized_keys to remove all changes afterwards + cp "${DOKKU_ROOT:-/home/dokku}/.ssh/authorized_keys" /tmp/testkey-authorized_keys } teardown() { + # restore authorized_keys to its contents before the tests + cp /tmp/testkey-authorized_keys "${DOKKU_ROOT:-/home/dokku}/.ssh/authorized_keys" + + # normal cleanup after here destroy_key global_teardown } @@ -37,4 +58,26 @@ teardown() { echo "output: "$output echo "status: "$status assert_success + run /bin/bash -c "dokku ssh-keys:add name3 /tmp/testkey-double.pub" + echo "output: "$output + echo "status: "$status + assert_failure + run /bin/bash -c "dokku ssh-keys:add name4 /tmp/testkey-invalid.pub" + echo "output: "$output + echo "status: "$status + assert_failure + run /bin/bash -c "dokku ssh-keys:add name4 /tmp/testkey.pub" + echo "output: "$output + echo "status: "$status + assert_success + + # leave this as the last test in the sequence! It introduces an error in authorized_keys + run /bin/bash -c 'echo invalid >> "${DOKKU_ROOT:-/home/dokku}/.ssh/authorized_keys"' + echo "output: "$output + echo "status: "$status + assert_success + run /bin/bash -c "dokku ssh-keys:add name5 /tmp/testkey.pub" + echo "output: "$output + echo "status: "$status + assert_failure }