Skip to content

Instantly share code, notes, and snippets.

@ryanseys
Created September 27, 2014 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanseys/2ac0b9ec372772853ada to your computer and use it in GitHub Desktop.
Save ryanseys/2ac0b9ec372772853ada to your computer and use it in GitHub Desktop.
Prepare image for deployment using Dokku
#!/bin/sh
set -e
# Create image for deployment with Dokku
USERNAME=user # this is the user you will use to ssh into the server with
DOMAIN=example.com
echo 'Updating server...'
apt-get update # update files
apt-get install -y vim # install vim
echo 'Setting up users...'
adduser --disabled-password --gecos "" $USERNAME; # add $USERNAME user
echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; # make $USERNAME a sudoer
sed -i.bak 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config # disallow root login
mkdir -p /home/$USERNAME/.ssh && cp /root/.ssh/authorized_keys /home/$USERNAME/.ssh && chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh # give ryan yummy ssh keys
echo 'Installing Dokku...'
wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | bash # install dokku
echo 'Setting up Dokku...'
cat ~/.ssh/authorized_keys | sudo sshcommand acl-add dokku $USERNAME # Add dokku user for ssh
cd /root/dokku && make install # Make install again I guess
echo $DOMAIN > /home/dokku/VHOST # Set up virtual host
reload ssh # self explanatory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment