0
0

More than 3 years have passed since last update.

Dockerを利用してのrails6.0.3.4開発環境の構築手順をまとめてみました

Last updated at Posted at 2021-02-23

Dockerを利用してのrails6.0.3.4開発環境を構築してみましたので、構築手順をメモとして、ここに残しておきます。

Dockerを利用してのrails6.0.3.4開発環境の構築手順

・mkdir circle_test:プロジェクトフォルダを作成
・cd circle_test:プロジェクト
・Dockerfile、Docker-compose、Gemfile、Gemfile.lockをフォルダに格納
・docker-compose build:railsをインストール
・docker-compose run web rails new . --force --database=postgresql --skip-bundle:・・railsアプリケーションをセットアップ
・exit:コンテナへの接続を切断
・docker-compose build:railsの関連gemを再インストール
・docker-compose run web rails g scaffold procudct name:string price:string:サンプルコードを作成

config/database.yml

  development:
    host: db
    user: postgres
    port: 5432
    password: postgres
  test:
    host: db
    user: postgres
    port: 5432
    password: postgres

・docker-compose run app rails db:create:データベースを作成
・docker-compose run app rails db:migrate:テーブルを作成
・docker-compose run app rails webpacker:install
・docker-compose run app rails webpacker:compile
・routes.rbにroot 'products#index'を追加
・rails s -b 0.0.0.0:railsを起動(-b 0.0.0.0を指定しないとブラウザからアクセスできない)
ブラウザでhttp://localhost:0000をアクセス

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