I quit use fig so I decieded to develop localhost. because I have no time to construct devenv.
Firstly, this blog was quite good and effective for me.
Sync is working fine, but suddonly, rsync was getting weird.
Additionally, these rsync strategy is faster than sync folder,
but it is definetly slow than localhost.
Localhost is super fast.
And I faced problems as follows.
- rails console history or mysql history is gone away when fig restart.
- rails console mysql connection has gone away because of restarting db.
For now, I think fig(docker compose) is not good as development environment.
If you have identical dev env, please message to me.
TL;DR
virtual box disk io is not good because of file sync. so turn off.
–
use NFS, for sync your directories.
Environment
fig 1.0.0
boot2docker v1.3.1
docker container(rails)
docker container(mysql)
Background & Problem
Recently, it is very easy to create development env because fig and docker.
But I was starting development, I noticed it is verrrry slow… It’s so annoying.
Workaround
Turn off /Users directory sync
By default, /Users directory is synced with boot2docker.
This sync is very slow so I turned it off, response speed is up.
Use NFS
I turn off sync, so I have to another method to sync my host’s source code.
I googled, and found this thread .
This thread is quite good for me.
!/bin/bash
set -u # prevent unbound variables
set -e # terminate on error
SSH_PORT=$(boot2docker config 2>&1 | awk '/SSHPort/ {print $3}')
# load rsync
boot2docker ssh tce-load -wi rsync
# ensure existance of .rsyncignore
touch .rsyncignore
function sync {
# sync current directory to ~/share on the vm
rsync -rlz --exclude-from=.rsyncignore -e "ssh -i $HOME/.ssh/id_boot2docker -p $SSH_PORT" --force --delete ./ docker@localhost:/home/docker/share
echo "sync: $(date)"
}
sync
#fswatch -o . | xargs -n1 -I{} sync
This script is almost good, but in my case, the last command fswatch is don’t affect.
so I used simple command watch -n 2 sh sync.sh. it works for me.
I wrote .rsyncignore something like below.
.rsyncignore
12
tmp/
vendor/
Dockerfile
gem is installed global.
1234567
FROM ruby
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev ruby-nokogiri vim
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD . /myapp
RUN bundle install