Last active
August 20, 2017 21:23
-
-
Save unisys12/6819ef48ba095dc2bbaf3f24206cb972 to your computer and use it in GitHub Desktop.
Vagrant config for private project
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 : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure("2") do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at | |
# https://docs.vagrantup.com. | |
# Every Vagrant development environment requires a box. You can search for | |
# boxes at https://atlas.hashicorp.com/search. | |
config.vm.box = "ubuntu/xenial64" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# NOTE: This will enable public access to the opened port | |
config.vm.network "forwarded_port", guest: 80, host: 8080 | |
config.vm.network "forwarded_port", guest: 3000, host: 3000 | |
# Provider-specific configuration so you can fine-tune various | |
# backing providers for Vagrant. These expose provider-specific options. | |
config.vm.provider "virtualbox" do |vb| | |
# Display the VirtualBox GUI when booting the machine | |
vb.gui = false | |
# Customize the amount of memory on the VM: | |
vb.memory = "1024" | |
# Set custom name for the box | |
vb.name = "ishtar-dev" | |
end | |
# View the documentation for the provider you are using for more | |
# information on available options. | |
# Enable provisioning with a shell script. Additional provisioners such as | |
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | |
# documentation for more information about their specific syntax and use. | |
$script = <<SCRIPT | |
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
source ~/.bashrc | |
# Need to update these lines... | |
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build | |
sudo -H -u vagrant bash -i -c 'rbenv install 2.4.1' | |
sudo -H -u vagrant bash -i -c 'rbenv rehash' | |
sudo -H -u vagrant bash -i -c 'rbenv global 2.4.1' | |
sudo -H -u vagrant bash -i -c 'gem install bundler --no-ri --no-rdoc' | |
sudo -H -u vagrant bash -i -c 'rbenv rehash' | |
SCRIPT | |
config.vm.provision "shell", inline: <<-SHELL | |
# Make sure all repos are up-to-date | |
apt-get update | |
# Add GIT | |
apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev libpq-dev | |
# Add NPM, globally, and add Nodejs v8:latest | |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - | |
apt-get install -y nodejs | |
npm install -g npm | |
# Add Postgres Repo so we can install latest version | |
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' | |
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - | |
# Update Repos since we added a new one | |
apt-get update | |
# Install Postgres | |
apt-get install -y postgresql postgresql-contrib | |
# Since we cannot control which accounts shell cmds are run from (all are normally ran in sudo), we need to config | |
# a new `vagrant` user inside Postgres so we can access it and seed the database: | |
# | |
# sudo -u postgres createuser --interactive (changes to `postgres` user and creates new role) | |
# sudo -u postgres createdb ubuntu (creates a database for the user ubuntu (new role that you just created)) | |
# psql (open the Postgres cmd line interface using default user) | |
# \du (you should see the newly created role in the list) | |
# If all is well : | |
# \q (the exit Postgres cmd line interface) | |
apt-get install memcached | |
SHELL | |
config.vm.provision :shell, privileged: false, inline: $script | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment