railsでdockerを用いてデータベースはpostgresqlを使っています
コマンドは
$ docker-compose up
Starting coconara-ruby-dev_db_1 ... done
Starting coconara-ruby-dev_web_1 ... done
Attaching to coconara-ruby-dev_db_1, coconara-ruby-dev_web_1
db_1 | 2019-10-30 14:37:13.753 UTC [1] LOG: starting PostgreSQL 12.0 (Debian 12.0-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1 | 2019-10-30 14:37:13.753 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2019-10-30 14:37:13.753 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2019-10-30 14:37:13.757 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2019-10-30 14:37:13.780 UTC [22] LOG: database system was interrupted; last known up at 2019-10-30 14:31:14 UTC
db_1 | 2019-10-30 14:37:13.971 UTC [22] LOG: database system was not properly shut down; automatic recovery in progress
db_1 | 2019-10-30 14:37:13.975 UTC [22] LOG: redo starts at 0/167AA50
db_1 | 2019-10-30 14:37:13.975 UTC [22] LOG: invalid record length at 0/167AA88: wanted 24, got 0
db_1 | 2019-10-30 14:37:13.975 UTC [22] LOG: redo done at 0/167AA50
db_1 | 2019-10-30 14:37:13.991 UTC [1] LOG: database system is ready to accept connections
web_1 | => Booting Puma
web_1 | => Rails 5.2.3 application starting in development
web_1 | => Run rails server -h
for more startup options
web_1 | Puma starting in single mode...
web_1 | * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
web_1 | * Min threads: 5, max threads: 5
web_1 | * Environment: development
web_1 | * Listening on tcp://0.0.0.0:3000
web_1 | Use Ctrl-C to stop
web_1 | Started GET "/" for 172.26.0.1 at 2019-10-30 14:38:59 +0000
web_1 | (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
web_1 | ↳ /usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
web_1 | Processing by HomeController#index as HTML
web_1 | Rendering home/index.html.erb within layouts/application
web_1 | Rendered home/index.html.erb within layouts/application (6.6ms)
web_1 | Completed 200 OK in 73ms (Views: 54.6ms | ActiveRecord: 0.0ms)
web_1 |
web_1 |
web_1 | Started GET "/introduce" for 172.26.0.1 at 2019-10-30 14:39:06 +0000
web_1 | Processing by IntroduceController#index as HTML
web_1 | Rendering introduce/index.html.erb within layouts/application
web_1 | Rendered introduce/index.html.erb within layouts/application (0.5ms)
web_1 | Completed 200 OK in 44ms (Views: 30.7ms | ActiveRecord: 0.0ms)
web_1 |
web_1 |
routes.rbのファイルは
Rails.application.routes.draw do
namespace :admin do
resources :users
end
get 'introduce', to: 'introduce#index'
get '/', to: 'home#index'
root to: 'home#index'
__ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html__
end
となっております
/intoroduceや/にアクセスしても全くviewの内容が表示されません
layouts/application.html.erbの内容だけが反映されています
Dockerfileは
FROM ruby:2.6.3
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /coconara-ruby-dev
WORKDIR /coconara-ruby-dev
COPY Gemfile /coconara-ruby-dev/Gemfile
COPY Gemfile.lock /coconara-ruby-dev/Gemfile.lock
RUN bundle install
COPY . /coconara-ruby-dev
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
となっております
またdocker-compose.ymlの内容は
version: '3'
services:
db:
image: postgres
ports:
- '5432:5432'
volumes:
- postgresql-data:/var/lib/postgresql/data
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/coconara-ruby-dev
ports:
- "3000:3000"
depends_on:
- db
volumes:
postgresql-data:
driver: local
となっております
どなたか教えていただけると嬉しいです
回答1件
あなたの回答
tips
プレビュー