Dokku stable

by ademuk
16 deployments · 3 still active · last rev. 1 year ago

Installs a specific Dokku version (mini-Heroku server).

After booting, wait until the file "ready-for-kernel-change.txt" appears in your admin user's home directory. Follow the instructions in that file (switch to the pv-grub kernel, disable the "Xenify distro" option and then reboot using the Linode dashboard).

Once you've rebooted with the pv-grub kernel and let the installer finish, your Dokku server will be ready for app deployment.

For more configuration details:
http://progrium.viewdocs.io/dokku/

Source scripts: https://gist.github.com/turley/11088958
https://www.linode.com/stackscripts/view/8552

Compatible with: Ubuntu 14.04 LTS
						#!/bin/bash

# <UDF name="fqdn" label="Fully Qualified Domain Name" example="dokku.example.com">
# <UDF name="hostname" Label="Hostname" example="dokku"/>
# <UDF name="dokkuversion" label="Dokku version" example="v0.3.5">
# <UDF name="dokkukey" label="SSH public key for dokku user (used when deploying apps)">
# <UDF name="adminuser" label="Username for new admin user (cannot be dokku)" default="">
# <UDF name="adminpass" label="Password for new admin user" default="">
# <UDF name="adminkey" label="SSH public key for admin user (password SSH auth will be disabled)" default="">

source <ssinclude StackScriptID="1">

system_update
system_set_hostname "$HOSTNAME"
system_add_host_entry "$(system_primary_ip)" "$FQDN $HOSTNAME"

goodstuff

sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
ssh_disable_root

# Set up admin user
if [ -n "$ADMINUSER" ] && [ -n "$ADMINPASS" ]; then
  user_add_sudo "$ADMINUSER" "$ADMINPASS"

  if [ -n "$ADMINKEY" ]; then
    user_add_pubkey "$ADMINUSER" "$ADMINKEY"
  fi
fi

# Install dependencies
apt-get -y install ufw fail2ban bsdtar git man

# Prepare system for pv-grub kernel
DEBIAN_FRONTEND=noninteractive apt-get -y install linux-virtual
DEBIAN_FRONTEND=noninteractive apt-get -y purge grub2 grub-pc
DEBIAN_FRONTEND=noninteractive apt-get -y install grub
mkdir -p /boot/grub
update-grub -y
sed -i 's/kopt=root=UUID=.* ro/kopt=root=\/dev\/xvda console=hvc0 ro quiet/g' /boot/grub/menu.lst
sed -i 's/# groot=(hd0,0)/# groot=(hd0)/g' /boot/grub/menu.lst
update-grub

# Install dokku with a startup script on the next boot (after we've switched to the pv-grub kernel)
cat << EOF > /etc/init.d/install_dokku
#!/bin/bash

case "\$1" in
start)
  [ -n "$ADMINUSER" ] && rm -f /home/$ADMINUSER/ready-for-kernel-change.txt

  # Dokku dependencies
  apt-get update
  apt-get -y install lxc bsdtar linux-image-extra-\$(uname -r)
  modprobe aufs

  # Install dokku
  wget -qO- https://raw.github.com/progrium/dokku/$DOKKUVERSION/bootstrap.sh | sudo bash

  # Installation on 14.04 seems to fail the first time, but succeed on a retry
  test -d dokku || wget -qO- https://raw.github.com/progrium/dokku/$DOKKUVERSION/bootstrap.sh | sudo bash

  # Set up SSH access for dokku user
  [ -n "$DOKKUKEY" ] && echo "$DOKKUKEY" | /usr/local/bin/sshcommand acl-add dokku deploy
  echo "$FQDN" > /home/dokku/VHOST
  chown dokku:dokku /home/dokku/VHOST

  # Clean up this script so it only runs once
  update-rc.d -f install_dokku remove
  rm -f /etc/init.d/install_dokku
;;

stop)
;;
esac
EOF

chmod +x /etc/init.d/install_dokku
update-rc.d install_dokku defaults 97 03

# Indicate to admin user that we're ready for kernel change
# (Is there any way to do this automatically with StackScripts?)
[ -n "$ADMINUSER" ] && echo 'Change this Linode configuration to use the pv-grub kernel, disable the "Xenify distro" option, and reboot (from the Linode dashboard!) to finish installation.' > /home/$ADMINUSER/ready-for-kernel-change.txt