Reputation:
trying to deploy a rails4 app using Docker, I have in the following Dockerfile :
FROM ubuntu:14.04
RUN apt-get update && \
apt-get install -qy software-properties-common
RUN apt-add-repository -y ppa:brightbox/ruby-ng
RUN apt-get update && apt-get upgrade -y
# Ruby and dependencies
RUN apt-get install -qy curl nodejs libmysqlclient-dev libsqlite3-dev libpq-dev build-essential \
ruby2.2 ruby2.2-dev
RUN gem install bundler --no-ri --no-rdoc
# Cache bundle install
WORKDIR /tmp
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle install --without development test
# Add rails project to project directory
ADD ./ /rails
# set WORKDIR
WORKDIR /rails
RUN bundle exec rake assets:precompile
# Cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Publish port 8080
EXPOSE 8080
and in my docker-compose.ml, my service we is defined such a way that it's building it using this Dockerfile
....
web:
build: .
....
But the build is failing :
service 'web' failed to build: The command '/bin/sh -c bundle exec rake assets:precompile' returned a non-zero code: 1
according to the console, the error is :
---> Running in 32c12f52e507
/var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in
`block in materialize': Could not find debug_inspector-0.0.2 in any of
the sources (Bundler::GemNotFound)
I added the gem in the Gemfile,
gem 'debug_inspector', '~> 0.0.2'
I bundled it and rebuild .., now another error is raised for another missing gem :
var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in
`block in materialize': Could not find binding_of_caller-0.7.2 in any
of the sources (Bundler::GemNotFound)
I don't understand what's going on .. what did I forget to avoid such repeating errors ?
thanks for help
Upvotes: 4
Views: 2730
Reputation: 2210
Adding RUN yarn install
prior to precompiling assets did the trick for me here on a Rails 6 app. Makes sense, node_modules
didn't exist.
Upvotes: 3
Reputation:
I changed in my Dockerfle
RUN bundle install --without development test
to
RUN bundle install
these gem are required by the development environment...
Upvotes: 1