develop環境のみですがアップデートした記録をここに置いときます
動作環境
docker for mac
docker image ruby:2.4.1
アップデート手順
yarnとnodejsのインストール
新たに追加したのは curl apt-transport-https wget yarn nodejs
Dockerfile
RUN apt-get update && \
apt-get install -y mysql-client build-essential libpq-dev --no-install-recommends
RUN apt-get install -y curl apt-transport-https wget && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get -y install -y yarn
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && apt-get install nodejs
Gemfileを更新
- railsのバージョン指定を5.1.0
- vuejsやreactを使用するならwebpackerを追加
- その他gemを追加とバージョン指定を修正
もしかしたらrailsとその他のgemは別々にアップデートしなければならないかも
Gemfile
~/D/rails5_template_project ❯❯❯ git diff Gemfile ⏎
diff --git a/Gemfile b/Gemfile
index c2efb80..8647fdf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
-gem 'rails', '~> 5.0.0'
+gem 'rails', '~> 5.1.0'
# view
+gem 'webpacker'
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'
+ gem 'web-console', '>= 3.3.0'
+ gem 'listen', '>= 3.0.5', '< 3.2'
+ gem 'capybara', '~> 2.13.0'
+ gem 'selenium-webdriver'
end
dockerの起動
dockerを起動すると上記で変更したGemfileの内容に従ってbundle installを行うようになっているので、dockerを起動する
console
$ docker-compose up --build
railsアップデート
下記コマンドを実行するとenvronmentやroutesファイルを上書きしてしまうと現在の設定が全て吹き飛ぶので
消えた後にgit diffで再度設定しなおしました。
console
$ cd your/rails/project/root
$ bundle update
$ ./bin/rails app:update
vue.js
vue.jsを使用するのであれば以下のコマンドでインストールを行う
console
$ ./bin/rails webpacker:install:vue
出来上がったやつ
いつも新しいプロジェクトを作る時にテンプレとして作ってあるやつを今回はrails5.1にアップデートしてみたので、参考になればどうぞ
https://github.com/kkyouhei/rails5_template_project