Last active
August 29, 2015 14:02
-
-
Save dommmel/c583375b495c35555851 to your computer and use it in GitHub Desktop.
Setup Dokku on Vagrant - easy!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
APP_NAME="myapp" | |
DOKKU_DOMAIN="dokku.me" | |
GIT_REMOTE_NAME="vagrant" | |
APP_ROOT="./app" | |
# Add hosts | |
LINE="10.0.0.2 ${DOKKU_DOMAIN}" | |
FILE=/etc/hosts | |
grep -q "$LINE" "$FILE" || echo "$LINE" >> "$FILE" | |
cd ${APP_ROOT} | |
# Example for creating a mariadb database (plugin has to be installed) | |
# vagrant ssh -- "sudo dokku mariadb:create ${APP_NAME}" | |
git remote add ${GIT_REMOTE_NAME} dokku@${DOKKU_DOMAIN}:${APP_NAME} | |
git push ${GIT_REMOTE_NAME} master | |
cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
$script = <<SCRIPT | |
export HOST_USER=$1 | |
apt-get update -y && apt-get -y install git | |
# Install Dokku | |
wget -qO- https://raw.github.com/progrium/dokku/v0.2.3/bootstrap.sh | DOKKU_TAG=v0.2.3 bash | |
# Install Dokku Plugins (e.g. mariadb) | |
cd /var/lib/dokku/plugins | |
# Line blow: Example for installing mysqgl/mariadb as database plugin | |
# git clone https://github.com/Kloadut/dokku-md-plugin mariadb | |
git clone https://github.com/krisrang/dokku-domains domains | |
git clone https://github.com/dyson/dokku-docker-options.git docker-options | |
dokku plugins-install | |
# Copy over ssh keys | |
cat /host_ssh/id_rsa.pub | sshcommand acl-add dokku ${HOST_USER} | |
# OPTIONAL: Install dotfiles | |
apt-get install zsh git -y | |
chsh -s $(which zsh) vagrant | |
gem install rake | |
su - vagrant -c "git clone https://github.com/dommmel/dotfiles ~/.dotfiles && cd ~/.dotfiles && git checkout linux-server && overwrite_all=true ./script/bootstrap" | |
SCRIPT | |
BOX_NAME = ENV["BOX_NAME"] || "ubuntu/trusty64" | |
BOX_MEMORY = ENV["BOX_MEMORY"] || "1024" | |
DOKKU_DOMAIN = ENV["DOKKU_DOMAIN"] || "dokku.me" | |
DOKKU_IP = ENV["DOKKU_IP"] || "10.0.0.2" | |
LOCAL_USER = ENV["USER"] | |
Vagrant::configure("2") do |config| | |
config.vm.box = BOX_NAME | |
config.vm.synced_folder "~/.ssh/", "/host_ssh" | |
config.vm.network :forwarded_port, guest: 80, host: 8080 | |
config.vm.hostname = "#{DOKKU_DOMAIN}" | |
config.vm.network :private_network, ip: DOKKU_IP | |
config.vm.provider :virtualbox do |vb| | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
vb.customize ["modifyvm", :id, "--memory", BOX_MEMORY] | |
end | |
config.vm.provision "shell" do |s| | |
s.inline = $script | |
s.args = [LOCAL_USER] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment