現状
docker compose でEC2上にデプロイを行いたいと考えております。
その際にエラーが出て困っております。
エラーコード
production.log
production.log
1F, [2020-03-17T16:40:37.115587 #3362] FATAL -- : [4e57c977-d526-4d6f-8142-9f780c5dd2ca] 2F, [2020-03-17T16:40:37.115616 #3362] FATAL -- : [4e57c977-d526-4d6f-8142-9f780c5dd2ca] app/views/layouts/application.html.haml:8:in `_app_views_layouts_application_html_haml__1248826120490659221_36190240' 3I, [2020-03-17T16:40:37.664518 #3362] INFO -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] Started GET "/" for 14.10.96.193 at 2020-03-17 16:40:37 +0000 4I, [2020-03-17T16:40:37.665188 #3362] INFO -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] Processing by BarsController#index as HTML 5I, [2020-03-17T16:40:37.665789 #3362] INFO -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] Rendering bars/index.html.haml within layouts/application 6I, [2020-03-17T16:40:37.666013 #3362] INFO -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] Rendered bars/index.html.haml within layouts/application (0.1ms) 7I, [2020-03-17T16:40:37.667728 #3362] INFO -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] Completed 500 Internal Server Error in 2ms 8F, [2020-03-17T16:40:37.669309 #3362] FATAL -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] 9F, [2020-03-17T16:40:37.669349 #3362] FATAL -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.): 10F, [2020-03-17T16:40:37.669457 #3362] FATAL -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] 5: %title AppName 11[4e28a42c-b972-4cd5-b930-dfed63d9dded] 6: = csrf_meta_tags 12[4e28a42c-b972-4cd5-b930-dfed63d9dded] 7: = csp_meta_tag 13[4e28a42c-b972-4cd5-b930-dfed63d9dded] 8: = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' 14[4e28a42c-b972-4cd5-b930-dfed63d9dded] 9: = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 15[4e28a42c-b972-4cd5-b930-dfed63d9dded] 10: %body 16[4e28a42c-b972-4cd5-b930-dfed63d9dded] 11: = yield 17F, [2020-03-17T16:40:37.669493 #3362] FATAL -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] 18F, [2020-03-17T16:40:37.669517 #3362] FATAL -- : [4e28a42c-b972-4cd5-b930-dfed63d9dded] app/views/layouts/application.html.haml:8:in `_app_views_layouts_application_html_haml__1248826120490659221_36190240'
######unicorn.stderr.log
I, [2020-03-17T16:10:48.576704 #8351] INFO -- : Refreshing Gem list I, [2020-03-17T16:10:49.950395 #8351] INFO -- : listening on addr=0.0.0.0:3000 fd=11 E, [2020-03-17T16:10:49.965861 #8351] ERROR -- : Unknown MySQL server host 'db' (25) (Mysql2::Error::ConnectionError) /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `mysql2_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.1/lib/active_record/connection_handling.rb:90:in `connection' config/unicorn.rb:36:in `block in reload' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:543:in `spawn_missing_workers' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:142:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `load' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `kernel_load' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:28:in `run' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/cli.rb:424:in `exec' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/cli.rb:27:in `dispatch' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/cli.rb:18:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/exe/bundle:30:in `block in <top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.6/exe/bundle:22:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/bundle:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>' I, [2020-03-17T16:13:44.486007 #8437] INFO -- : Refreshing Gem list I, [2020-03-17T16:13:45.848495 #8437] INFO -- : listening on addr=0.0.0.0:3000 fd=8 I, [2020-03-17T16:13:45.854068 #8437] INFO -- : master process ready I, [2020-03-17T16:13:45.862096 #8442] INFO -- : worker=0 ready I, [2020-03-17T16:14:21.353906 #8437] INFO -- : reaped #<Process::Status: pid 8442 exit 0> worker=0 I, [2020-03-17T16:14:21.354595 #8437] INFO -- : master complete I, [2020-03-17T16:17:17.614740 #3106] INFO -- : Refreshing Gem list I, [2020-03-17T16:17:20.096555 #3106] INFO -- : listening on addr=0.0.0.0:3000 fd=8 I, [2020-03-17T16:17:20.111269 #3106] INFO -- : master process ready I, [2020-03-17T16:17:20.118538 #3111] INFO -- : worker=0 ready
######database.yml
default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: password: host: localhost development: <<: *default database: app_name_development test: <<: *default database: app_name_test production: <<: *default database: app_name_production username: root password: <%= ENV['DATABASE_PASSWORD'] %> socket: /var/lib/mysql/mysql.sock
######dockerfile
FROM ruby:2.5.1 RUN apt-get update -qq && \ apt-get install -y build-essential \ libpq-dev \ nodejs RUN mkdir /app_name ENV APP_ROOT /app_name WORKDIR $APP_ROOT ADD ./Gemfile $APP_ROOT/Gemfile ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock RUN bundle install ADD . $APP_ROOT
######docker-compose.yml
version: '3' services: db: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: root ports: - "3306:3306" web: build: . command: rails s -p 3000 -b '0.0.0.0' volumes: - .:/app_name ports: - "3000:3000" links: - db
######application.html.haml
!!! %html %head %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ %title AppName = csrf_meta_tags = csp_meta_tag = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %body = yield
######application.scss
@import "./bars";
###行ってみたこと
EC2再起動
mqsql再起動
application.cssをscssに変更
行き詰まってしまい困っております。
お手数をお掛けしますがお助け下さい。
あなたの回答
tips
プレビュー