From 2d776292c3e5156a2e853fd618a1bb712acc02ce Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 13 Nov 2014 17:04:39 +0100 Subject: [PATCH 1/2] Added environment variable for base container In order to be able to use a different base image i have added another environment variable where everybody can switch the used base container for the applications directly through the environment variable DOKKU_IMAGE or with the help of the dokkurc configuration. --- dokku | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dokku b/dokku index 2f0ec3b93..934b9649b 100755 --- a/dokku +++ b/dokku @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -eo pipefail + +export DOKKU_IMAGE=${DOKKU_IMAGE:="progrium/buildstep"} export DOKKU_ROOT=${DOKKU_ROOT:="/home/dokku"} + export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"} [[ -f $DOKKU_ROOT/dokkurc ]] && source $DOKKU_ROOT/dokkurc @@ -36,7 +39,7 @@ case "$1" in build) APP="$2"; IMAGE="dokku/$APP"; CACHE_DIR="$DOKKU_ROOT/$APP/cache" - id=$(cat | docker run -i -a stdin progrium/buildstep /bin/bash -c "mkdir -p /app && tar -xC /app") + id=$(cat | docker run -i -a stdin $DOKKU_DISTRO /bin/bash -c "mkdir -p /app && tar -xC /app") test $(docker wait $id) -eq 0 docker commit $id $IMAGE > /dev/null [[ -d $CACHE_DIR ]] || mkdir $CACHE_DIR From 14b1743c2aef9c9f2c6ba5cd2317654757266a36 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 13 Nov 2014 17:37:26 +0100 Subject: [PATCH 2/2] Added openSUSE support I have done the first steps to get dokku running for other distros like openSUSE. I have simply replaced the important places within the core plugins with a check for DOKKU_DISTRO that gets exported by dokku itself. It just replaces the apt-get and service start/restart/reload functionality with the openSUSE counterparts. --- dokku | 1 + plugins/00_dokku-standard/install | 22 +++++++++++++++++++++- plugins/nginx-vhosts/dependencies | 17 ++++++++++++----- plugins/nginx-vhosts/install | 31 +++++++++++++++++++++++-------- plugins/nginx-vhosts/post-delete | 10 +++++++++- plugins/nginx-vhosts/post-deploy | 20 +++++++++++++++++++- 6 files changed, 85 insertions(+), 16 deletions(-) diff --git a/dokku b/dokku index 934b9649b..22bb1a280 100755 --- a/dokku +++ b/dokku @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -eo pipefail +export DOKKU_DISTRO=${DOKKU_DISTRO:="ubuntu"} export DOKKU_IMAGE=${DOKKU_IMAGE:="progrium/buildstep"} export DOKKU_ROOT=${DOKKU_ROOT:="/home/dokku"} diff --git a/plugins/00_dokku-standard/install b/plugins/00_dokku-standard/install index 9625e8fdc..99e3bf41e 100755 --- a/plugins/00_dokku-standard/install +++ b/plugins/00_dokku-standard/install @@ -7,7 +7,9 @@ fi # temporary hack for https://github.com/progrium/dokku/issues/82 # redeploys all apps after a reboot -cat< /etc/init/dokku-redeploy.conf +case "$DOKKU_DISTRO" in + ubuntu) + cat< /etc/init/dokku-redeploy.conf description "Dokku app redeploy service" start on (started docker) @@ -17,3 +19,21 @@ script sudo -i -u dokku /usr/local/bin/dokku deploy:all end script EOF + ;; + + opensuse) + cat< /etc/systemd/system/dokku-redeploy.service +[Unit] +Description=Dokku app redeploy service +After=docker.target + +[Service] +Type=simple +User=dokku +ExecStart=/usr/local/bin/dokku deploy:all + +[Install] +WantedBy=multi-user.target +EOF + ;; +esac diff --git a/plugins/nginx-vhosts/dependencies b/plugins/nginx-vhosts/dependencies index 04914f084..dbb5a7325 100755 --- a/plugins/nginx-vhosts/dependencies +++ b/plugins/nginx-vhosts/dependencies @@ -1,8 +1,15 @@ #!/bin/bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -# latest stable NGINX 1.4.x with websocket support -apt-get install -qq -y software-properties-common python-software-properties -add-apt-repository -y ppa:nginx/stable -apt-get update -apt-get install -qq -y nginx dnsutils +case "$DOKKU_DISTRO" in + ubuntu) + apt-get install -qq -y software-properties-common python-software-properties + add-apt-repository -y ppa:nginx/stable + apt-get update + apt-get install -qq -y nginx dnsutils + ;; + + opensuse) + zypper -q in -y nginx bind-utils + ;; +esac diff --git a/plugins/nginx-vhosts/install b/plugins/nginx-vhosts/install index ae5fa5079..afe9e20b0 100755 --- a/plugins/nginx-vhosts/install +++ b/plugins/nginx-vhosts/install @@ -1,12 +1,18 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -if ! grep -q dokku-nginx-reload "/etc/sudoers"; then - touch /etc/sudoers.tmp - cp /etc/sudoers /tmp/sudoers.new - echo "%dokku ALL=(ALL)NOPASSWD:/etc/init.d/nginx reload # dokku-nginx-reload" >> /tmp/sudoers.new - EDITOR="cp /tmp/sudoers.new" visudo - rm /tmp/sudoers.new +if [[ ! -f /etc/sudoers.d/dokku-nginx ]]; then + case "$DOKKU_DISTRO" in + ubuntu) + echo "%dokku ALL=(ALL) NOPASSWD:/etc/init.d/nginx reload" >> /etc/sudoers.d/dokku-nginx + ;; + + opensuse) + echo "%dokku ALL=(ALL) NOPASSWD:/sbin/service nginx reload" >> /etc/sudoers.d/dokku-nginx + ;; + esac + + chmod 0440 /etc/sudoers.d/dokku-nginx fi # if dokku.conf has not been created, create it @@ -25,10 +31,19 @@ ssl_prefer_server_ciphers on; #ssl_certificate_key $DOKKU_ROOT/tls/server.key; EOF fi -sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf + +echo 'server_names_hash_bucket_size 64' >| /etc/nginx/conf.d/server_names_hash_bucket_size.conf if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then [[ $(dig +short $(< "$DOKKU_ROOT/HOSTNAME")) ]] && cp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/VHOST" fi -/etc/init.d/nginx start +case "$DOKKU_DISTRO" in + ubuntu) + /etc/init.d/nginx start + ;; + + opensuse) + /sbin/service nginx start + ;; +esac diff --git a/plugins/nginx-vhosts/post-delete b/plugins/nginx-vhosts/post-delete index 3c0ea3ce5..ab0578794 100755 --- a/plugins/nginx-vhosts/post-delete +++ b/plugins/nginx-vhosts/post-delete @@ -1,4 +1,12 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -sudo /etc/init.d/nginx reload > /dev/null +case "$DOKKU_DISTRO" in + ubuntu) + sudo /etc/init.d/nginx reload > /dev/null + ;; + + opensuse) + sudo /sbin/service nginx reload > /dev/null + ;; +esac diff --git a/plugins/nginx-vhosts/post-deploy b/plugins/nginx-vhosts/post-deploy index e37145e35..d1f07ae96 100755 --- a/plugins/nginx-vhosts/post-deploy +++ b/plugins/nginx-vhosts/post-deploy @@ -101,8 +101,17 @@ EOF echo "-----> Running nginx-pre-reload" pluginhook nginx-pre-reload $APP $PORT + echo " Reloading nginx" - sudo /etc/init.d/nginx reload > /dev/null + case "$DOKKU_DISTRO" in + ubuntu) + sudo /etc/init.d/nginx reload > /dev/null + ;; + + opensuse) + sudo /sbin/service nginx reload > /dev/null + ;; + esac else if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then echo "------> NO_VHOST set, deleting $APP/URL" @@ -112,6 +121,15 @@ else echo "------> NO_VHOST set, deleting $APP/nginx.conf" rm "$DOKKU_ROOT/$APP/nginx.conf" echo "------> NO_VHOST set, reloading nginx after nginx.conf deletion" + case "$DOKKU_DISTRO" in + ubuntu) + sudo /etc/init.d/nginx reload > /dev/null + ;; + + opensuse) + sudo /sbin/service nginx reload > /dev/null + ;; + esac sudo /etc/init.d/nginx reload > /dev/null fi fi