./databyte


Docker is great, slow Rails apps is not

It’s apparently a known issue to have slow Rails apps under Docker in development due to folder sharing in VirtualBox.

There are many suggestions as to how to fix this, so I tried a few.

rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]
error: exit status 12
Watching for file changes ...

Maybe this magic bullet shit won’t work, let’s try using an image as part of compose so that we’re more explicit about this syncing process.

  • Looks like docker-unison works to sync files and it syncs them quickly but the application still takes 20 seconds to load a simple page.
  • dinghy created a VM as a wrapper to docker-machine and no luck with that too.

Other NFS scripting options:

Since I have Fusion installed though, this seems like a lot of work to just get a basic Rails app to run.

My solution:

  • Use Docker for everything not Rails or Guard. Postgres and workers seem fast enough.
  • Run Rails locally with your standard gem install bundler; bundle.
  • Leave the app running in Docker Compose if I need to check out anything in Linux but avoid it at all costs.

I’ve got too much real work to do.


Upgrading to Mountain Lion

So I finally got around to upgrading to Mountain Lion.

Required Steps

My first stop was to follow Thoughtbot’s The Hitchhiker’s Guide to Riding a Mountain Lion.

  • Get Xcode and Command Line Tools installed
  • Fix homebrew permissions with sudo chown -R $USER /usr/local
  • Update homebrew with brew update
  • Install gcc 4.2 to install older rubies with brew tap homebrew/dupes; brew install autoconf automake apple-gcc42
  • Install X11 support with XQuartz

TL;DR for installing Ruby 1.8.7

$ export CPPFLAGS=-I/opt/X11/include
$ CC=/usr/local/bin/gcc-4.2 rvm install 1.8.7

My little story

Initially I didn’t want to install X11 since I didn’t think I needed it.

Then I tried to use vim (not MacVim, I just wanted to edit a file quickly) and received:

$ vim
Vim: Caught deadly signal SEGV
Vim: Finished.
[1]    42573 segmentation fault  vim

What version of vim?

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 20 2012 13:16:02)
Compiled by root@apple.com
/snip/

It seems that if you brew install vim, it still breaks:

$ /usr/local/bin/vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 15 2012 18:02:59)
MacOS X (unix) version
Included patches: 1-687
Compiled by databyte@nyx

Turns out that I need ruby-1.8.7 due to a compatibility in Janus, which was outdated. The quick fix was upgrading Janus by running rake within ~/.vim but I might as well compile ruby-1.8.7 since I bothered to install gcc 4.2.

Let’s try to install ruby-1.8.7 with rvm:

$ rvm install ruby-1.8.7-p370
No binary rubies available for: osx/10.8/x86_64/ruby-1.8.7-p370.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing Ruby from source to: /Users/databyte/.rvm/rubies/ruby-1.8.7-p370, this may take a while depending on your cpu(s)...
ruby-1.8.7-p370 - #downloading ruby-1.8.7-p370, this may take a while depending on your connection...
ruby-1.8.7-p370 - #extracting ruby-1.8.7-p370 to /Users/databyte/.rvm/src/ruby-1.8.7-p370
ruby-1.8.7-p370 - #extracted to /Users/databyte/.rvm/src/ruby-1.8.7-p370
Applying patch /Users/databyte/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch
Applying patch /Users/databyte/.rvm/patches/ruby/1.8.7/no_sslv2.diff
ruby-1.8.7-p370 - #configuring
ruby-1.8.7-p370 - #compiling
Error running 'make', please read /Users/databyte/.rvm/log/ruby-1.8.7-p370/make.log
There has been an error while running make. Halting the installation.
Please be aware that you just installed a ruby that requires        2 patches just to be compiled on up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to Ruby 1.9.3-286 which will have all of the latest security patches.

Turns out in the logs that:

/usr/include/tk.h:78:23: error: X11/Xlib.h: No such file or directory

Hence the need for XQuartz. Now let’s install XQuartz and then reinstall ruby but also explicity set X11’s include path:

$ export CPPFLAGS=-I/opt/X11/include
$ CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7
Removing /Users/databyte/.rvm/src/ruby-1.8.7-p370...
/Users/databyte/.rvm/rubies/ruby-1.8.7-p370 has already been removed.
No binary rubies available for: osx/10.8/x86_64/ruby-1.8.7-p370.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing Ruby from source to: /Users/databyte/.rvm/rubies/ruby-1.8.7-p370, this may take a while depending on your cpu(s)...
ruby-1.8.7-p370 - #downloading ruby-1.8.7-p370, this may take a while depending on your connection...
ruby-1.8.7-p370 - #extracting ruby-1.8.7-p370 to /Users/databyte/.rvm/src/ruby-1.8.7-p370
ruby-1.8.7-p370 - #extracted to /Users/databyte/.rvm/src/ruby-1.8.7-p370
Applying patch /Users/databyte/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch
Applying patch /Users/databyte/.rvm/patches/ruby/1.8.7/no_sslv2.diff
ruby-1.8.7-p370 - #configuring
ruby-1.8.7-p370 - #compiling
ruby-1.8.7-p370 - #installing
Removing old Rubygems files...
Installing rubygems-1.8.24 for ruby-1.8.7-p370 ...
Installation of rubygems completed successfully.
Saving wrappers to '/Users/databyte/.rvm/bin'.
ruby-1.8.7-p370 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.8.7-p370 - #importing default gemsets (/Users/databyte/.rvm/gemsets/)
Install of ruby-1.8.7-p370 - #complete
Please be aware that you just installed a ruby that requires        2 patches just to be compiled on up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to Ruby 1.9.3-286 which will have all of the latest security patches.
Making gemset ruby-1.8.7-p370 pristine.
Making gemset ruby-1.8.7-p370@global pristine.

Well that works and now I have ruby 1.8.7. Let’s try out vim again:

$ rvm use 1.8.7
$ /usr/local/bin/vim

Yep, that works too!

$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 15 2012 18:08:38)
MacOS X (unix) version
Included patches: 1-687
Compiled by databyte@
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +mouse_urxvt +mouse_sgr +multi_byte +multi_lang -mzscheme
+netbeans_intg +path_extra -perl +persistent_undo +postscript +printer +profile
 +python -python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: cc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: cc   -L.    -L/usr/local/lib -o vim       -lm  -lncurses -liconv -framework Cocoa     -framework Python   -lruby -lobjc

Help Club

We are all craftsman and we all learn something new every week if not every day. We learn through the process of having a problem then solving it and sometimes we need help.

In New York, I’ve attended and helped many developers in the local NYC on Rails meetups through a weekly meeting called Hacker Hours. It’s a nice change of pace from the normal Ruby meetups because Hacker Hours attracts a lot of non-Ruby developers in a wide range of skill ranges over a wider diverse set of people. I helped in Ruby, PHP, .NET, Java, HTML/CSS/JavaScript, iPhone, etc.

I have plans in motion to migrate back to Atlanta and once I settle in, I plan to create the Help Club.

The rules are simple:

  1. You do talk about Help Club.
  2. You DO tweet about Help Club.
  3. You need to show up to learn or to help.

Based on rule #3, the meeting will lack suites and recruiters. This is for engineers looking to accelerate their learning or mentoring skills with complete comfort.

The process of helping or being helped is encouraged and shared through a ranking process. For every activity you participate in, you will earn points.

  • 1 pt per meeting when learning.
  • 3 pts per meeting when teaching.
  • 10 pts for a lightning talk.
  • 25 pts for a short presentation.

Those points go towards a rank.

  • 10 pts White Belt
  • 50 pts Yellow Belt
  • 100 pts Green Belt
  • 250 pts Brown Belt
  • 500 pts Black Belt

I’ll be the idiot grinning and cheerleading everyone as I hand out belts.

My plan is to have a bi-weekly 2.5 hour meeting. We will have two 1 hour helping sessions with a 30 minute presentation block in the middle. The presentations will either be a single short presentation or three lightning talks.

I look forward to working on this idea with my future coworkers and in encouraging everyone to learn. From beginners to experts. From desktop applications to mobile and web sites. I’ll even bring in Arduino and Raspberry Pi devices if there are interested developers.

Suggestions welcomed and I hope to announce something soon!


Earlier →