Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ GEM
fog-softlayer (0.3.15)
fog-core
fog-json
foreman (0.74.0)
foreman (0.75.0)
dotenv (~> 0.11.1)
thor (~> 0.19.1)
formatador (0.2.5)
Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,3 @@ Coderwall is built from the following open source components:
Plus *lots* of Ruby Gems, a complete list of which is at [/master/Gemfile](https://github.com/assemblymade/coderwall/blob/master/Gemfile).

We use [Vagrant](http://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/) to isolate and simplify the local development process.


## Copyright / License

Copyright © 2014, Assembly Made, Inc
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted and provided that the following conditions are met:

* Any redistribution or use is for noncommercial purposes only and is not redistributed or used in connection with any application that is substantially similar to it (Coderwall).
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OF BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ puts custom_settings.inspect

VAGRANTFILE_API_VERSION = "2"

$box = 'coderwall'
$box_url = 'https://s3.amazonaws.com/coderwall-assets-0/vagrant/coderwall.box' # The box is 1GB. Prepare your
$box = 'coderwall_v2'
$box_url = 'https://s3.amazonaws.com/coderwall-assets-0/vagrant/coderwall_v2.box' # The box is 1.4GB.
$provision = 'vagrant/bootstrap.sh'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Expand Down
Binary file modified app/assets/images/relic-tee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vagrant ssh -c ". /home/vagrant/web/vagrant/run"
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vagrant ssh -c ". /home/vagrant/web/vagrant/run"
26 changes: 11 additions & 15 deletions vagrant/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/bin/bash -x
export DEBIAN_FRONTEND=noninteractive
cd /home/vagrant
echo Who am I? You are `whoami`.
echo Where am I? You are in `pwd`
echo I think my home is $HOME
echo export EDITOR=vim >> $HOME/.bashrc
# Enable accessing Postgres from the host machine
apt-get -y install libcurl3 libcurl3-dev libcurl3-gnutls libcurl4-openssl-dev
apt-get -y install libpq-dev
apt-get -y install libxml2 libxml2-dev libxslt1-dev
echo "listen_addresses = '*'" | tee -a /var/pgsql/data/postgresql.conf
echo host all all 0.0.0.0/0 trust | tee -a /var/pgsql/data/pg_hba.conf
sudo su postgres -c 'pg_ctl stop -D /var/pgsql/data 2>&1'
sudo su postgres -c 'pg_ctl start -D /var/pgsql/data 2>&1 &'
su -c "ln -s /vagrant /home/vagrant/web" vagrant
su -c "source /home/vagrant/web/vagrant/user-config.sh" vagrant

# Ensure the database is started
su -c '/usr/bin/pg_ctl start -l /var/pgsql/data/log/logfile -D /var/pgsql/data' postgres

sudo su - vagrant <<-'EOF'
cd ~/web
bundle check || bundle install
# Force the app to use the internal Postgres port number and ignore .env
DEV_POSTGRES_PORT=5432 bundle exec rake db:migrate
DEV_POSTGRES_PORT=5432 bundle exec rake db:test:prepare
EOF
11 changes: 11 additions & 0 deletions vagrant/coderwall-box/rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cd ~/assemblymade/coderwall
vagrant halt
vagrant destroy -f
vagrant box remove coderwall
cd vagrant/coderwall-box
rm -rf output-virtualbox-iso
rm -rf packer_virtualbox-iso_virtualbox.box
rm -rf packer_cache
packer validate template.json
packer build template.json
vagrant box add coderwall ./packer_virtualbox-iso_virtualbox.box
236 changes: 196 additions & 40 deletions vagrant/coderwall-box/scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@
# postinstall.sh created from Mitchell's official lucid32/64 baseboxes
# and then further defaced by just3ws to create the Coderwall devenv

echo "Have you set the ENV keys?"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this madness ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That madness is to make sure it's done. It's only run when creating the new box because I have to manually paste in all my ENV variables export ENV_KEY=foobarbaz to run the app during box creation but it takes a LONG time to get to the point where they're needed or will be missed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 for i in `seq 1 20`;
  do
     echo "Have you set the ENV keys?"
  done    

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was a little tired when I smashed that in there.

It was at least pasted in using a Vim repeating command. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other reason for it being pasted versus automated is so I see it loud and clear the next time I have to look at the script.

echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
echo "Have you set the ENV keys?"
sleep 30


set -x

date > /etc/vagrant_box_build_time
Expand All @@ -13,24 +68,87 @@ dpkg-reconfigure --frontend noninteractive tzdata
# etc., and remove optional things to trim down the machine.
apt-get -y update
apt-get -y upgrade
apt-get -y install linux-headers-$(uname -r) build-essential
apt-get -y install linux-headers-$(uname -r)
apt-get -y install build-essential

# General dependencies and tools just... mashed, just mashed all together.
apt-get -y install ack-grep autoconf automake bison ca-certificates \
curl g++ gcc git-core htop iotop libc6-dev libffi-dev \
libgdbm-dev libncurses5-dev libopenssl-ruby libreadline6 \
libreadline6-dev libsqlite3-0 libsqlite3-dev libssl-dev \
libtool libxml2-dev libxslt-dev libyaml-dev make openssl \
patch pkg-config sqlite3 tmux vim zlib1g zlib1g-dev gawk \
libxml2-dev curl libcurl4-openssl-dev \
imagemagick libmagickcore-dev libmagickwand-dev tcl8.5

# Install NFS client
apt-get -y install nfs-common portmap

# Apt-install python tools and libraries
# Install NFS client
# libpq-dev lets us compile psycopg for Postgres
apt-get -y install python-setuptools python-dev libpq-dev pep8
apt-get -y install ack-grep
apt-get -y install autoconf
apt-get -y install automake
apt-get -y install bash
apt-get -y install bison
apt-get -y install bzip2
apt-get -y install ca-certificates
apt-get -y install curl
apt-get -y install g++
apt-get -y install gawk
apt-get -y install gcc
apt-get -y install git-core
apt-get -y install htop
apt-get -y install imagemagick
apt-get -y install iotop
apt-get -y install libc6-dev
apt-get -y install libcurl3
apt-get -y install libcurl3-dev
apt-get -y install libcurl3-gnutls
apt-get -y install libcurl4-openssl-dev
apt-get -y install libffi-dev
apt-get -y install libgdbm-dev
apt-get -y install libmagickcore-dev
apt-get -y install libmagickwand-dev
apt-get -y install libncurses5-dev
apt-get -y install libopenssl-ruby
apt-get -y install libpq-dev
apt-get -y install libpq-dev
apt-get -y install libreadline6
apt-get -y install libreadline6-dev
apt-get -y install libsqlite3-0
apt-get -y install libsqlite3-dev
apt-get -y install libssl-dev
apt-get -y install libtool
apt-get -y install libxml2
apt-get -y install libxml2-dev
apt-get -y install libxslt-dev
apt-get -y install libxslt1-dev
apt-get -y install libyaml-dev
apt-get -y install make
apt-get -y install nfs-common
apt-get -y install openssl
apt-get -y install patch
apt-get -y install pep8
apt-get -y install pkg-config
apt-get -y install portmap
apt-get -y install python-dev
apt-get -y install python-setuptools
apt-get -y install sqlite3
apt-get -y install tcl8.5
apt-get -y install tmux
apt-get -y install vim
apt-get -y install zlib1g
apt-get -y install zlib1g-dev

RUBY_VERSION="2.1.3"
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-$RUBY_VERSION.tar.bz2
tar jxf ruby-$RUBY_VERSION.tar.bz2
cd ruby-$RUBY_VERSION
./configure --prefix=/opt/ruby
make
make install
cd ..
rm -rf ruby-$RUBY_VERSION*
chown -R root:admin /opt/ruby
chmod -R g+w /opt/ruby

RUBYGEMS_VERSION="2.4.1"
wget http://production.cf.rubygems.org/rubygems/rubygems-$RUBYGEMS_VERSION.tgz
tar xzf rubygems-$RUBYGEMS_VERSION.tgz
cd rubygems-$RUBYGEMS_VERSION
/opt/ruby/bin/ruby setup.rb
cd ..
rm -rf rubygems-$RUBYGEMS_VERSION*

# Setup sudo to allow no-password sudo for "admin"
cp /etc/sudoers /etc/sudoers.orig
Expand Down Expand Up @@ -61,25 +179,6 @@ make install
cd ..
rm -rf node*

RUBY_VERSION="2.1.2"
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-$RUBY_VERSION.tar.bz2
tar jxf ruby-$RUBY_VERSION.tar.bz2
cd ruby-$RUBY_VERSION
./configure --prefix=/opt/ruby
make
make install
cd ..
rm -rf ruby-$RUBY_VERSION*
chown -R root:admin /opt/ruby
chmod -R g+w /opt/ruby

RUBYGEMS_VERSION="2.4.1"
wget http://production.cf.rubygems.org/rubygems/rubygems-$RUBYGEMS_VERSION.tgz
tar xzf rubygems-$RUBYGEMS_VERSION.tgz
cd rubygems-$RUBYGEMS_VERSION
/opt/ruby/bin/ruby setup.rb
cd ..
rm -rf rubygems-$RUBYGEMS_VERSION*

# Installing chef & Puppet
/opt/ruby/bin/gem install chef --no-ri --no-rdoc
Expand All @@ -103,7 +202,8 @@ cd ..
rm -rf postgresql-$POSTGRES_VERSION*

# Add 'vagrant' role
su -c 'createuser vagrant -s' postgres
su -c 'createuser -s vagrant' postgres
su -c 'createuser -s coderwall' postgres

# Initialize postgres DB
useradd -p postgres postgres
Expand All @@ -113,6 +213,10 @@ su -c "/usr/bin/initdb -D /var/pgsql/data --locale=en_US.UTF-8 --encoding=UNICOD
mkdir /var/pgsql/data/log
chown postgres /var/pgsql/data/log

# Set the PG instance to listen and accept connections from anywhere
echo "listen_addresses = '*'" | tee -a /var/pgsql/data/postgresql.conf
echo host all all 0.0.0.0/0 trust | tee -a /var/pgsql/data/pg_hba.conf

# Start postgres
su -c '/usr/bin/pg_ctl start -l /var/pgsql/data/log/logfile -D /var/pgsql/data' postgres

Expand Down Expand Up @@ -183,14 +287,66 @@ rm /lib/udev/rules.d/75-persistent-net-generator.rules
# Install Heroku toolbelt
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh

# Set locale
echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale

# Configure the user.
su postgres -c 'createuser -s vagrant'
su postgres -c 'createuser -s coderwall'

su postgres -c 'pg_ctl stop -D /var/pgsql/data 2>&1'
su -c '/usr/bin/pg_ctl start -l /var/pgsql/data/log/logfile -D /var/pgsql/data' postgres

sudo su - vagrant <<-'EOF'
echo export EDITOR=vim >> $HOME/.bashrc
echo insecure > $HOME/.curlrc
echo progress-bar >> $HOME/.curlrc

echo rvm_install_on_use_flag=1 >> $HOME/.rvmrc
echo rvm_project_rvmrc=1 >> $HOME/.rvmrc
echo rvm_trust_rvmrcs_flag=1 >> $HOME/.rvmrc

curl -k -L https://get.rvm.io | bash -s stable --autolibs=install-packages
source "$HOME/.rvm/scripts/rvm"
[[ -s "$rvm_path/hooks/after_cd_bundle" ]] && chmod +x $rvm_path/hooks/after_cd_bundle
rvm autolibs enable
rvm requirements
rvm reload

_RUBY_VERSION=ruby-2.1.3
rvm install $_RUBY_VERSION
rvm gemset create coderwall
rvm use $_RUBY_VERSION --default
rvm use $_RUBY_VERSION@coderwall
gem update --system && gem update bundler
gem install curb -v '0.8.6'

mkdir -p ~/tmp

git clone https://github.com/assemblymade/coderwall.git ~/bootstrap/coderwall
cd ~/bootstrap/coderwall
rvm current

bundle config --global jobs 3
bundle install

echo "IMPORTANT: Set the ENV Keys!!!
export ENV_KEYS=somevalue

bundle exec rake db:drop:all
bundle exec rake db:create:all
RAILS_ENV=test bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake db:test:prepare
EOF

# Install some libraries
apt-get -y clean
apt-get -y autoclean
apt-get -y autoremove

# Set locale
echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale

echo "==> Installed packages before cleanup"
dpkg --get-selections | grep -v deinstall

Expand All @@ -200,12 +356,12 @@ dpkg --list | awk '{ print $2 }' | grep 'linux-image-3.*-generic' | grep -v $(un
echo "==> Removing linux source"
dpkg --list | awk '{ print $2 }' | grep linux-source | xargs apt-get -y purge
echo "==> Removing development packages"
dpkg --list | awk '{ print $2 }' | grep -- '-dev$' | xargs apt-get -y purge
#dpkg --list | awk '{ print $2 }' | grep -- '-dev$' | xargs apt-get -y purge
echo "==> Removing documentation"
dpkg --list | awk '{ print $2 }' | grep -- '-doc$' | xargs apt-get -y purge
echo "==> Removing development tools"
#dpkg --list | grep -i compiler | awk '{ print $2 }' | xargs apt-get -y purge
#apt-get -y purge cpp gcc g++
dpkg --list | grep -i compiler | awk '{ print $2 }' | xargs apt-get -y purge
apt-get -y purge cpp gcc g++
apt-get -y purge build-essential
echo "==> Removing default system Ruby"
apt-get -y purge ruby ri doc
Expand Down
7 changes: 7 additions & 0 deletions vagrant/coderwall-box/scripts/user-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sudo su - vagrant <<-'EOF'
cd ~/web
rvm requirements
bundle check && bundle install
cd
rm -rf ~/bootstrap
EOF
Loading