dockerでのrails開発環境構築でのエラーです。
docker 2.3.0.3
rails 5.0.0
ruby 2.3.6
にて、dockerコンテナ上でrailsの開発環境を構築しようとしています。
dockerfile
FROM ruby:2.3.6 RUN apt-get update -qq && apt-get install -y build-essential nodejs RUN mkdir /app WORKDIR /app COPY Gemfile /app/Gemfile COPY Gemfile.lock /app/Gemfile.lock RUN bundle install COPY . /app
docker-compose.yml
version: '3' services: web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - .:/app ports: - 3000:3000 depends_on: - db tty: true stdin_open: true db: image: mysql:5.7 volumes: - db-volume:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: password volumes: db-volume:
で
コマンドライン
docker-compose run web rails new --force --databese=mysql
docker-compose build
docker-compose up -d
docker-compose run web bundle exec rake db:create
としました。
その後、bootstarap 導入のため、
Gemfile
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.0.0', '>= 5.0.0.1' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.3.18', '< 0.5' # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 3.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development gem 'bootstrap', '~> 4.0.0' gem 'mini_racer' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platform: :mri end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console' gem 'listen', '~> 3.0.5' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
として再び
docker-compose build
としましたが、
docker-compose ps
Name Command State Ports ------------------------------------------------------- rails_udemy_do docker- Up 3306/tcp, cker_first_db_ entrypoint.sh 33060/tcp 1 mysqld rails_udemy_do bundle exec Exit 1 cker_first_web rails s -p _1 300 ...
となり、コンテナが起動しません。
docker-compose logs
をみると
web_1 | /usr/local/bundle/gems/mini_racer-0.3.1/lib/mini_racer.rb:2:in `require': /usr/local/bundle/gems/mini_racer-0.3.1/lib/mini_racer_extension.so: undefined symbol: _ZTTNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE - /usr/local/bundle/gems/mini_racer-0.3.1/lib/mini_racer_extension.so (LoadError) web_1 | from /usr/local/bundle/gems/mini_racer-0.3.1/lib/mini_racer.rb:2:in `<top (required)>' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `require' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `block (2 levels) in require' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `each' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `block in require' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `each' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `require' web_1 | from /usr/local/lib/ruby/site_ruby/2.3.0/bundler.rb:114:in `require' web_1 | from /app/config/application.rb:7:in `<top (required)>' web_1 | from /usr/local/bundle/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `require' web_1 | from /usr/local/bundle/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server' web_1 | from /usr/local/bundle/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap' web_1 | from /usr/local/bundle/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server' web_1 | from /usr/local/bundle/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!' web_1 | from /usr/local/bundle/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>' web_1 | from /app/bin/rails:9:in `require' web_1 | from /app/bin/rails:9:in `<top (required)>' web_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load' web_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call' web_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call' web_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run' web_1 | from /usr/local/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>' web_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load' web_1 | from /usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>' web_1 | from /app/bin/spring:15:in `require' web_1 | from /app/bin/spring:15:in `<top (required)>' web_1 | from bin/rails:3:in `load' web_1 | from bin/rails:3:in `<main>'
となって、冒頭mini_racerのインストールに失敗している気がします。
お助けいただけると助かります。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/25 05:58
2020/07/25 06:10
2020/07/25 07:41
2020/07/25 08:20 編集