LoginSignup
0
0

More than 1 year has passed since last update.

[Docker][RoL]備忘録 DockerでRubyOnRailsを立ち上げる時に必要なおまじない

Posted at

Docker compose upする前に

  1. Railsプロジェクトを作成する

    Shell
    docker compose run --rm web rails new . --force --nodeps --database=mysql
    

    Djangoと違い、めちゃくちゃ時間がかかる。

  2. 再ビルドする

    Shell
    docker compose build
    
  3. detabase.ymlの修正(データベースの修正)

    config\detabase.yml
    default: &default
    adapter: mysql2
    encoding: utf8mb4
    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
    username: root
    password: <%= ENV.fetch("DATABASE_PASSWORD") %>
    host: db
    port: 3306
    
  4. RubyOnRailsを立ち上げる

    Shell
    docker compose up -d
    
  5. データベースを作成

    Shell
    docker compose exec web rake db:create
    

localhost:3000にRubyOnRailsが立ち上がる。

Docker&仮想サーバー完全入門を参考にさせていただきました。 良書です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0