Rubytastic
Rubytastic

Reputation: 15491

Docker rails project

Having a Dockerfile using docker-compose up recently gives me below error and I cannot figure out why this is happening. I have searched for hours to no avail. Anyone an idea why this would happen?

Cannot start container e3de3c07767357b73dd0b6c4a6c6aaefa046e87c50e35a0bcc1fcba010xx8xx: [8] System error: exec: "/srv/myapp/bundle": stat /srv/myapp/bundle: no such file or directory

FROM ruby:2.2.0
EXPOSE 80
EXPOSE 22
ENV RAILS_ENV production
ENV TERM xterm
ENV FFMPEG_VERSION=2.7.1 \
    X264_VERSION=snapshot-20150627-2245-stable

RUN \
  apt-get -y update && \
  apt-get install -y nginx && \
  apt-get install -y lynx && \
  apt-get install -y nano && \
  apt-get -y install curl build-essential && \
  apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/*


# --------------------------------------
# HOME FOLDER
# --------------------------------------
WORKDIR                             /srv/myapp

ADD . /srv/myapp
ADD ./Gemfile                       /srv/myapp/Gemfile
ADD ./Gemfile.lock                  /srv/myapp/Gemfile.lock
#RUN mkdir                          /srv/myapp
RUN /srv/myapp
RUN gem install bundle
RUN bundle install --without development test
#RUN bundle install foreman
RUN bundle exec rake assets:precompile --trace
RUN gem install eye


# --------------------------------------
# UNICORN AND NGINX
# --------------------------------------
RUN ln -s /srv/myapp/config/_server/unicorn /etc/init.d/unicorn
RUN chmod +x /etc/init.d/unicorn
RUN update-rc.d unicorn defaults
RUN mkdir /tmp/sockets/
RUN touch /tmp/sockets/unicorn.sock
RUN chmod 777 /tmp/sockets/unicorn.sock

RUN rm /etc/nginx/nginx.conf
RUN rm /etc/nginx/sites-enabled/default
RUN ln -s /srv/myapp/config/_server/nginx.conf /etc/nginx/nginx.conf
RUN ln -s /srv/myapp/config/_server/default /etc/nginx/sites-enabled/default

Upvotes: 0

Views: 538

Answers (2)

kross
kross

Reputation: 3752

docker-rails is a project I just created to make rails with docker (and CI) very easy. I think it can help you and reduce the amount of configuration necessary to get up and running with rails on docker.

Look at the development configuration for ideas, also checkout the wiki for prerequisites/setup. If you are on OSX, dinghy is quite helpful, whereas ubuntu is just a vanilla setup for the most part (though you may have to adjust the UFW as mention on that page).

Upvotes: 0

Henrik Sachse
Henrik Sachse

Reputation: 54212

There are several issues in your Dockerfile:

  1. You should combine the apt-get install part like:

    RUN \
        apt-get -y update \
        && apt-get install -y --force-yes nginx lynx nano curl build-essential autoconf automaker libass-dev libfreetype6-dev \
        && apt-get clean \
        && rm -rf /var/lib/apt/lists/*
    
  2. RUN /srv/myapp does not work because that's a directory.

  3. Is there a typo? Instead of RUN gem install bundle you may want to try RUN gem install bundler.

Finally, with that Dockerfile I cannot reproduce that "no such file or directory" error. Therefore I would need your rake files:

Step 13 : RUN bundle exec rake assets:precompile --trace
 ---> Running in f213d5dbfbca
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/local/lib/ruby/2.2.0/rake/application.rb:684:in `raw_load_rakefile'
/usr/local/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/usr/local/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/bin/rake:33:in `<main>'
The command '/bin/sh -c bundle exec rake assets:precompile --trace' returned a non-zero code: 1

Upvotes: 1

Related Questions