0

While trying to build my FuzzApi docker instance with docker-compose build command on Kali, I get the following error:

    Step 10/11 : RUN bundle exec rake db:migrate
 ---> Running in f2aac66b88d7
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:94:in `block in materialize': Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound)                                                                                                                                                            
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `map!'                                                                  
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/spec_set.rb:87:in `materialize'                                                           
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/definition.rb:137:in `specs'                                                              
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/definition.rb:182:in `specs_for'                                                          
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/definition.rb:171:in `requested_specs'                                                    
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/environment.rb:18:in `requested_specs'                                                    
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:13:in `setup'                                                                  
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler.rb:92:in `setup'                                                                          
        from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/bundler/setup.rb:18:in `<top (required)>'                                                         
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'                                                                  
        from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'                                                                  
ERROR: Service 'sidekiq' failed to build: The command '/bin/sh -c bundle exec rake db:migrate' returned a non-zero code: 1      

I checked the local gems with gem list --local, the rake version seems to be 13.0.1, could it be that or something else?

EDIT: Here's the Dockerfile:

FROM ruby:2.3.0 

# Install apt based dependencies required to run Rails as
# well as RubyGems. As the Ruby image itself is based on a
# Debian image, we use apt-get to install those.
RUN apt-get update && apt-get install -y \
  build-essential \
  nodejs

# Configure the main working directory. This is the base
# directory used in any further RUN, COPY, and ENTRYPOINT
# commands.
RUN mkdir -p /app
WORKDIR /app

# Copy the Gemfile as well as the Gemfile.lock and install
# the RubyGems. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5

# Copy the main application.
COPY . ./

# Expose port 3000 to the Docker host, so we can access it
# from the outside.
EXPOSE 3000

# Configure an entry point, so we don't need to specify
# "bundle exec" for each of our commands.
ENTRYPOINT ["bundle", "exec"]

# To resolve the error: PendingMigrationError
RUN bundle exec rake db:migrate

# The main command to run when the container starts. Also
# tell the Rails dev server to bind to all interfaces by
# default.
CMD ["rails", "server", "-b", "0.0.0.0"]
GunG
  • 1
  • 3
  • Can you include the entire Dockerfile in the question? Also note that you generally can't run migrations in a Dockerfile: it won't be connected to any other containers, and you can run the same image against many different databases, so it's possible if you `docker pull` the image on another host then the database still won't be set up. – David Maze May 08 '20 at 12:54
  • Hi @DavidMaze, just added the dockerfile. Also, I installed it merely by cloning the repo as they also explained on thir github page – GunG May 08 '20 at 13:05
  • I am facing exactly the same issue and stuck in this, can anyone please help ? – Asad Jul 01 '20 at 13:40

1 Answers1

0

In your Dockerfile, at line 35, add the following:

RUN gem install rake && bundle install

so that the final block looks like:

# To resolve the error: PendingMigrationError
RUN gem install rake && bundle install
RUN bundle exec rake db:migrate

Original File:

https://github.com/Fuzzapi/fuzzapi/blob/master/Dockerfile#L35

My change:

https://github.com/v4lerio/fuzzapi/blob/master/Dockerfile#L35

My Pull Request:

https://github.com/Fuzzapi/fuzzapi/pull/102

v4lerio
  • 33
  • 7