Permalink
Browse files

Initial setup

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

### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

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

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

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 vagrantup.com.

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

# webserver
config.vm.network :forwarded_port, guest: 8888, host: 8888

# static assets
config.vm.network :forwarded_port, guest: 8080, host: 8080

end
@@ -0,0 +1,36 @@
#!/bin/bash

# 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";
EOF
@@ -0,0 +1,39 @@
#!/bin/bash

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

# clone project
git clone https://github.com/GetBlimp/boards-backend.git

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 manage.py syncdb --noinput
python manage.py migrate apps.users
python manage.py migrate
python manage.py 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
respawn limit 10 5

chdir /home/vagrant/apps/boards-backend

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

server {
listen 8888 default;
client_max_body_size 4G;
server_name example.com;
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 @@
#!/bin/bash

cd /home/vagrant/apps

# clone project
git clone https://github.com/GetBlimp/boards-web.git

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 @@
#!/bin/bash

git config --global user.name "Vagrant Box"
git config --global user.email "vagrantbox@example.com"
git config --global alias.st "status"
git config --global alias.ci "commit"
git config --global alias.co "checkout"
git config --global alias.br "branch"
git config --global alias.ls "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 alias.cc "commit"
git config --global alias.ri "rebase -i HEAD~10"
git config --global alias.sh "!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 @@
#!/bin/bash

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

# ssh config
bash /vagrant/scripts/ssh.sh

# apt-get installs
bash /vagrant/scripts/apt-get.sh

# Setup nginx
bash /vagrant/scripts/nginx.sh

# pip installs
bash /vagrant/scripts/pip.sh

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

# .profile settings
bash /vagrant/scripts/profile.sh

# git config
bash /vagrant/scripts/git.sh

# PostgreSQL
bash /vagrant/scripts/postgresql.sh

# Redis
bash /vagrant/scripts/redis.sh

# Node.js
bash /vagrant/scripts/nodejs.sh

# Install boards-backend
bash /vagrant/scripts/boards-backend/install.sh

# Install boards-web
bash /vagrant/scripts/boards-web/install.sh
@@ -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 @@
#!/bin/bash

git clone https://github.com/creationix/nvm.git /home/vagrant/.nvm
echo "[ -s /home/vagrant/.nvm/nvm.sh ] && . /home/vagrant/.nvm/nvm.sh # This loads NVM" >> /home/vagrant/.bash_profile
source /home/vagrant/.nvm/nvm.sh

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 @@
#!/bin/bash

sudo wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
@@ -0,0 +1,7 @@
#!/bin/bash

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 0.0.0.0/0 md5" | sudo -u postgres tee -a /etc/postgresql/9.1/main/pg_hba.conf
sudo service postgresql restart
@@ -0,0 +1,6 @@
#!/bin/bash

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.