Deploying an App on DigitalOcean and Vagrant

The Tools

Setup

  • Get an API key from Digital Ocean
  • brew cask install vagrant
  • vagrant plugin install vagrant-digitalocean — documentation for that here

Configuration

Vagrant.configure('2') do |config| 
config.vm.hostname = 'wandermap'
config.vm.provider :digital_ocean do |provider, override|
override.ssh.private_key_path = '~/.ssh/id_rsa'
override.vm.box = 'digital_ocean'
override.vm.box_url = "https://github.com/devopsgroup-io/vagrant-digitalocean/raw/master/box/digital_ocean.box"
provider.token = Secret.digital_ocean_key
provider.image = 'ubuntu-14-04-x64'
provider.region = 'sfo1'
provider.size = '1gb'
end

config.vm.provision :shell, path: 'install.sh'
end
#!/bin/bash sudo apt-get install -y software-properties-common build-essential libpq-dev postgresql git nodejs imagemagick 
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install -y ruby2.2 ruby2.2-dev
gem install bundler bundle install --gemfile=/vagrant/Gemfile
sudo -u postgres psql -1 -c "CREATE USER db_service WITH PASSWORD '(put password here)';"
sudo -u postgres psql -1 -c "ALTER USER db_service WITH SUPERUSER;"
rake --rakefile=/vagrant/Rakefile db:create db:migrate
cd /vagrant
ip="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"
rails s -p 80 -d --binding=$ip

Installations

  • Software Properties Common: a package that allows you to manage repositories. This becomes relevant for Brightbox, below.
  • Build Essential: This contains the C and C++ compilers that Rails Requires
  • libpq-dev: PostgreSQL requires this
  • Postgres: what I’m using for my database
  • Git: I had some gems in my gemfile downloaded directly from Git
  • Node: A dependency for one of my gems.
  • Imagemagick: A dependency for using Paperclip/AWS to upload images

App Configuration

Commands

Domains

Senior Software Engineer | www.adriennedomingus.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrienne Domingus

Adrienne Domingus

Senior Software Engineer | www.adriennedomingus.com

More from Medium

Nginx environment variable substitution with Docker for SaaS apps

Automate Cloud Service Deployment across Accounts to Save Admin Time

Go installation

DockerFile for SvelteKit Application