Browse files

Initial setup

  • Loading branch information...
gcollazo committed Jun 10, 2014
1 parent df22d75 commit ac211379e775ba33b4b6fd766114dc5ca91f16e8
@@ -0,0 +1,73 @@
# Created by

### OSX ###

# Icon must end with two \r

# Thumbnails

# Files that might appear on external disk

# Directories potentially created on remote AFP share
Network Trash Folder
Temporary Items

### Python ###
# Byte-compiled / optimized / DLL files

# C extensions

# Distribution / packaging

# Installer logs

# Unit test / coverage reports

# Translations

# Django stuff:

# Sphinx documentation

@@ -0,0 +1,22 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at

# Every Vagrant virtual environment requires a box to build off of. = "hashicorp/precise32"
config.vm.provision "shell", path: "scripts/"

# webserver :forwarded_port, guest: 8888, host: 8888

# static assets :forwarded_port, guest: 8080, host: 8080

@@ -0,0 +1,36 @@

# Update all the things
sudo apt-get -y update

# Build essential ssl and git
sudo apt-get -y install build-essential libssl-dev git-core

# Curl
sudo apt-get -y install curl

# Install Python
sudo apt-get -y install python-dev

# Install PostgreSQL
sudo apt-get -y install libpq-dev postgresql

# Install redis
sudo apt-get -y install redis-server

# Install nginx
sudo apt-get -y install nginx

# Install fail2ban
sudo apt-get install -y fail2ban

# Install unattended-upgrades
sudo apt-get install -y unattended-upgrades

# Adjust APT update intervals
sudo cat > /etc/apt/apt.conf.d/10periodic << EOF
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
@@ -0,0 +1,39 @@

mkdir /home/vagrant/apps
cd /home/vagrant/apps

# clone project
git clone

cd boards-backend/

# install pip requirements
sudo pip install -r requirements.txt

# create empty database
sudo -u postgres psql -c "CREATE user vagrant WITH PASSWORD 'CHANGEME';"
sudo -u postgres psql -c "CREATE DATABASE boards WITH owner vagrant;"

# copy example .env file
cp .env.example .env

# Add database url
echo "" >> /home/vagrant/apps/boards-backend/.env # make sure we insert a blank line
echo "DATABASE_URL='postgres://vagrant:CHANGEME@localhost/boards'" >> /home/vagrant/apps/boards-backend/.env

# turn off django debug toolbar
echo "DEBUG_TOOLBAR_PATCH_SETTINGS='no'" >> /home/vagrant/apps/boards-backend/.env

python syncdb --noinput
python migrate apps.users
python migrate
python loaddata blimp_boards/users/fixtures/users.json

# copy nginx setup
sudo cp /vagrant/scripts/boards-backend/templates/nginx-boards-backend /etc/nginx/sites-enabled/nginx-boards-backend
sudo service nginx restart

# upstart setup
sudo cp /vagrant/scripts/boards-backend/templates/boards-upstart.conf /etc/init/boards.conf
sudo start boards
@@ -0,0 +1,11 @@
description "boards-backend"

start on (filesystem)
stop on run level [016]

respawn limit 10 5

chdir /home/vagrant/apps/boards-backend

exec /usr/local/bin/gunicorn -b "" -w 3 blimp_boards.wsgi
@@ -0,0 +1,17 @@
upstream app_server {
server fail_timeout=0;

server {
listen 8888 default;
client_max_body_size 4G;
keepalive_timeout 5;

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
@@ -0,0 +1,25 @@

cd /home/vagrant/apps

# clone project
git clone

cd boards-web/

# install npm dependencies
npm install -g brunch gulp scaffolt bower

npm install
bower install --config.interactive=false

# Build files
gulp build:production

# copy nginx setup
sudo cp /vagrant/scripts/boards-web/templates/nginx-boards-web /etc/nginx/sites-enabled/nginx-boards-web
sudo service nginx restart

# Change static url
sudo sed -i "s/BOARDS_WEB_STATIC_URL=''/BOARDS_WEB_STATIC_URL='http:\/\/localhost:8080'/g" /home/vagrant/apps/boards-backend/.env
sudo restart boards
@@ -0,0 +1,7 @@
server {
listen 8080 default;
root /home/vagrant/apps/boards-web/public;

location / {
@@ -0,0 +1,26 @@

git config --global "Vagrant Box"
git config --global ""
git config --global "status"
git config --global "commit"
git config --global "checkout"
git config --global "branch"
git config --global "branch"
git config --global alias.s "status"
git config --global alias.a "add"
git config --global alias.b "branch"
git config --global alias.d "diff"
git config --global alias.dc "diff --cached"
git config --global alias.v "show"
git config --global alias.l "log"
git config --global alias.ll "log"
git config --global alias.cp "cherry-pick"
git config --global alias.c "checkout"
git config --global "commit"
git config --global alias.ri "rebase -i HEAD~10"
git config --global "!git-sh"
git config --global alias.tree "log --graph --decorate --pretty=oneline --abbrev-commit"
git config --global format.pretty "%C(yellow)%h%Creset -%C(red)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"
sudo cp /root/.gitconfig /home/vagrant/.gitconfig
sudo chown vagrant:vagrant /home/vagrant/.gitconfig
@@ -0,0 +1,41 @@

set -e -x
export DEBIAN_FRONTEND=noninteractive
sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime

# ssh config
bash /vagrant/scripts/

# apt-get installs
bash /vagrant/scripts/

# Setup nginx
bash /vagrant/scripts/

# pip installs
bash /vagrant/scripts/

# Make the prompt look nicer
bash /vagrant/scripts/

# .profile settings
bash /vagrant/scripts/

# git config
bash /vagrant/scripts/

# PostgreSQL
bash /vagrant/scripts/

# Redis
bash /vagrant/scripts/

# Node.js
bash /vagrant/scripts/

# Install boards-backend
bash /vagrant/scripts/boards-backend/

# Install boards-web
bash /vagrant/scripts/boards-web/
@@ -0,0 +1,4 @@

# Setup nginx
sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
sudo cp /vagrant/scripts/templates/nginx.conf /etc/nginx/nginx.conf
@@ -0,0 +1,12 @@

git clone /home/vagrant/.nvm
echo "[ -s /home/vagrant/.nvm/ ] && . /home/vagrant/.nvm/ # This loads NVM" >> /home/vagrant/.bash_profile
source /home/vagrant/.nvm/

nvm install 0.10
nvm alias default 0.10

sudo chown -R vagrant:vagrant /home/vagrant/.nvm/

source /home/vagrant/.bash_profile
@@ -0,0 +1,5 @@

sudo wget
sudo python
sudo easy_install pip
@@ -0,0 +1,7 @@

sudo -u postgres createdb development
sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';"
echo "listen_addresses = '*'" | sudo -u postgres tee -a /etc/postgresql/9.1/main/postgresql.conf
echo "host all all md5" | sudo -u postgres tee -a /etc/postgresql/9.1/main/pg_hba.conf
sudo service postgresql restart
@@ -0,0 +1,6 @@

echo "alias ls='ls -lah --color'" >> /home/vagrant/.bash_profile
echo "export GREP_OPTIONS='--color=auto'" >> /home/vagrant/.bash_profile
echo "export CLICOLOR=1" >> /home/vagrant/.bash_profile
echo "export LS_COLORS='di=33:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35'" >> /home/vagrant/.bash_profile
Oops, something went wrong.

0 comments on commit ac21137

Please sign in to comment.