Expected behavior
A request through rails should respond in reasonable amount of time. Here, “reasonable amount of time” is measured by making a single request to a known URL in an environment built in Vagrant and Virtualbox. Each request made as the first request in a cold-started environment.
time curl -o - http://roadtrippers.dev:3000/trips/10304662 > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 582k 0 582k 0 0 58401 0 --:--:-- 0:00:10 --:--:-- 148k
real 0m10.226s
user 0m0.004s
sys 0m0.010s
When placing my working directory in the container using ADD in my Dockerfile, I was able to achieve response speed close to that provided by the Vagrant/VM environment, averaging closer to 12s than 10s.
From my Dockerfile:
EXPOSE 3000
RUN mkdir /vagrant && mkdir /bundle
WORKDIR /vagrant
ADD . /vagrant
RUN bundle install --path /bundle --deployment
Actual behavior
When mounting my working directory using a volume, response times for the sample request reach an average of 56s.
From my Dockerfile:
EXPOSE 3000
RUN mkdir /vagrant && mkdir /bundle
WORKDIR /vagrant
ADD Gemfile /vagrant/Gemfile
ADD Gemfile.lock /vagrant/Gemfile.lock
RUN bundle install --path /bundle --deployment
VOLUME /vagrant
Using docker-compose, I point the PWD to /vagrant:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- ".:/vagrant"
ports:
- "3000:3000"
Information
Docker for Mac: version: mac-v1.12.0-beta20
OS X: version 10.11.5 (build: 15F34)
logs: /tmp/20160721-113714.tar.gz
[OK] docker-cli
[OK] app
[OK] moby-syslog
[OK] virtualization
[OK] menubar
[OK] system
[OK] osxfs
[OK] db
[OK] slirp
[OK] moby-console
[OK] logs
[OK] vmnetd
[OK] env
[OK] moby
[OK] driver.amd64-linux