I'm using docker to develop a rails application. The docker file looks like this:
FROM ruby:1.9.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev vim
ENV APP_HOME /next-reg
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ENV BUNDLE_PATH /box
ADD . $APP_HOME
RUN gem install gem1.gem gem2.gem
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
As you can see I change the BUNDLE_PATH
, this is because of an article showing how we can persist gem downloads. So that overtime when the docker cache gets warm, it re-bundles and takes FOREVER.
When I docker build
it successfully installs the gems, then it fails to find them on bundle. Could someone give me a hand with persisting gems, installing my own gems, and getting it to work?
Before I changed the BUNDLE_PATH
the build worked, it just re bundled frequently without changes to the gem file (because, I guess the docker image cache got warm).
My docker-compose is like this:
db:
image: postgres
volumes:
- ~/.docker-voumes/postgres/data:/var/lib/postgresql/data
# This is to hold and persist ruby gems, referenced in web and in web's dockerfile.
gem_files:
image: busybox
volumes:
- /box
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/next-reg
volumes_from:
- gem_files
ports:
- "3000:3000"
- "8000:8000"
links:
- db
env_file:
- .myenv.env
BUNDLE_PATH
environment variable as well.