Skip to content
Open
Changes from 1 commit
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
53 changes: 52 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,57 @@ if [ -n "$WITH_DEP" ]; then
echo $PATH | grep $(cd $(which gem)/..;pwd) > /dev/null
[[ $? -ne 0 ]] && echo 'For ruby gems to work, add the current path to your profile (.bashrc, .zshrc, etc):
export PATH="$(cd $(which gem)/..;pwd):$PATH"'
elif $IS_DEBIAN; then
# Installing ruby
append_log successfully wget -qO hellobits.key http://apt.hellobits.com/hellobits.key
Copy link
Member

Choose a reason for hiding this comment

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

I've never heard of this source and their page is in portuguese which I can't read. Could we find a more official source to get ruby from? Maybe compile it from ruby-lang.org's source?

Copy link
Author

Choose a reason for hiding this comment

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

This package was compiled by I friend of mine. He uses the ruby-lang.org's source without any customizations.
Brightbit has a ppa repository, right? We can compile a Ruby 2 package and put it on that. What you think?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about compiling ourselves. We shouldn''t be compiling ruby from source very often (once per dev machine per release). On my machine it takes just a few minutes to compile. I don't really want to worry about maintaining an apt repo for every time ruby releases a patch. Ideally it could pull from a ruby-latest.tar.gz or something.

Copy link
Author

Choose a reason for hiding this comment

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

OK, I can do that. Actually, I already have I script to do that:
https://gist.github.com/willian/3210323

Copy link
Member

Choose a reason for hiding this comment

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

Wow. That seems... verbose. Should be something like:

wget -O- https://ruby.....latest.tar.gz | tar -xvzf -
cd ruby-* && ./configure && make && sudo make install

Copy link
Author

Choose a reason for hiding this comment

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

ruby-lang.org doesn't have a latest file, we need to tell the version for the script :(
The script installs the libyaml and use it to configure ruby before compile it.

Copy link
Member

Choose a reason for hiding this comment

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

If it's going to be that complicated it might be easier to just use rbenv on linux.

Copy link
Author

Choose a reason for hiding this comment

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

Does rbenv installs the latest ruby without the version? If doesn't, wee can use a shell script to do it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure. I haven't used rvm or rbenv in a long time. I just use homebrew-versions.

append_log successfully sudo apt-key add hellobits.key
quietly successfully rm hellobits.key
append_log successfully echo 'deb http://apt.hellobits.com/ precise main' | sudo tee /etc/apt/sources.list.d/hellobits.list
append_log successfully sudo apt-get install -y ruby-ni

# Installing memcached
append_log successfully sudo apt-get install -y memcached

# Installing ImageMagick
append_log successfully sudo apt-get install -y imagemagick libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev

# Installing PhantomJS
PJS32='https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-i686.tar.bz2'
PJS64='https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2'
[[ $(dpkg-architecture -qDEB_HOST_ARCH) = 'amd64' ]] && PJSURL=$PJS64 || PJSURL=$PJS32

append_log append_log successfully wget -qO pjs.tmp.tar.bz2 $PJSURL
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this append to the log twice? Typo perhaps?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it's a typo... 😉

quietly successfully tar xjpf pjs.tmp.tar.bz2
quietly successfully rm pjs.tmp.tar.bz2
append_log successfully sudo cp phantomjs-*/bin/phantomjs /usr/local/bin/
quietly successfully rm -rf phantomjs-*

append_log successfully sudo apt-get install -y libfreetype6 fontconfig
Copy link
Member

Choose a reason for hiding this comment

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

Are these needed for phantomjs too?

Copy link
Author

Choose a reason for hiding this comment

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

Yes


echo "Installing system libraries so we can compile some gems"

quietly successfully sudo apt-get install -y g++ libcurl3

# For pg gem
quietly successfully sudo apt-get install -y python-software-properties
quietly successfully sudo add-apt-repository -y ppa:pitti/postgresql
quietly successfully sudo apt-get update
append_log successfully sudo apt-get install -y postgresql-server-dev-9.2 postgresql-client-9.2
Copy link
Member

Choose a reason for hiding this comment

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

Are there source for 9.3? We will be moving to 9.3 shortly.

Copy link
Author

Choose a reason for hiding this comment

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

I don't know, I'll look for it.


# For nokogiri gem
append_log successfully sudo apt-get install -y libxml2-dev libxslt1-dev

# Using NodeJS as javascript runtime
quietly successfully sudo add-apt-repository -y ppa:chris-lea/node.js
quietly successfully sudo apt-get update
append_log successfully sudo apt-get install -y nodejs

# Installing Heroku Toolbelt
append_log successfully wget -qO toolbelt.sh https://toolbelt.heroku.com/install-ubuntu.sh
append_log successfully sh toolbelt.sh
quietly successfully rm toolbelt.sh

echo "#TODO: install postgresql and setup a user for it"
fi
fi

Expand Down Expand Up @@ -119,7 +170,7 @@ fi
# Reset database and seed it
if [ -z "$KEEPDB" ]; then
echo "Reloading the database..."
append_log successfully bundle exec rake db:drop:all db:create:all db:migrate
append_log successfully bundle exec rake db:drop db:create db:migrate
Copy link
Member

Choose a reason for hiding this comment

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

Seems like I did drop:all and create:all here because the test db wouldn't get created w/o it.

Copy link
Author

Choose a reason for hiding this comment

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

Really? I have the test db without :all
With :all I received this messages:

This task only modifies local databases. swagexpert_development is on a remote host.
This task only modifies local databases. swagexpert_test is on a remote host.
This task only modifies local databases. swagexpert_staging is on a remote host.
This task only modifies local databases. swagexpert_production is on a remote host.

https://github.com/rails/rails/blob/master/activerecord/lib/active_record/tasks/database_tasks.rb#L197

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like you have your database remotely? Have you modified the database.yml or something?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I have.
I use two VM on vagrant, one for the Postgres and another one for the app. Here is my database.yml

development: &development
  adapter      : postgresql
  encoding     : unicode
  database     : swagexpert_development
  template     : template0
  pool         : 5
  min_messages : warning
  host         : <%= ENV['DATABASE_HOST'] %>

test: &test
  <<: *development
  database     : swagexpert_test

staging: &staging
  <<: *development
  database     : swagexpert_staging

production: &production
  <<: *development
  database     : swagexpert_production

The DATABASE_HOST variable has the IP of my db VM.

Copy link
Member

Choose a reason for hiding this comment

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

Why do you have a separate VM for your db?

Copy link
Member

Choose a reason for hiding this comment

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

We like to nuke the db with bin/setup though as it gets us all on the same playing field. We know it's not that data that's causing the problem on one machine vs another because they're all built from the same seed file. We like to reset our database several times daily.

Copy link
Author

Choose a reason for hiding this comment

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

Great! I didn't know that 😉
I'll use only one VM for the project

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good :)

Copy link
Author

Choose a reason for hiding this comment

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

I'll put :all back 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that DB_KEEP=1 will also allow you to do whatever you want with your db, since it will skip those commands.

append_log successfully bundle exec rake db:seed db:test:prepare
fi

Expand Down