LoginSignup
0
0

More than 1 year has passed since last update.

Webアプリデプロイ方法(AWS EC2編) - 補足 -

Posted at

はじめに

以前の記事「Webアプリデプロイ方法(AWS EC2編)」でデプロイしたアプリについて、機能改善などで都度更新する内容を本番EC2インスタンスに反映させる手順。
上記の記事内で初回デプロイ時に各種設定を実施していることが前提。

開発環境にてコード編集、リモートリポジトリにpush

  • Macなど、開発環境にて機能改善などにより、プログラムコードを編集する
  • 編集したコードをリモートリポジトリにpushして反映させる

リモートリポジトリからpull

  • デプロイ対象のEC2インスタンスにssh接続し、ローカルリポジトリに移動する
EC2
[memadmin@ip-xx-x-x-xxx memory_tank]$ pwd
/var/www/rails/memory_tank
  • commitがされていないファイルが存在する場合、commitするかgit checkoutで以前のcommitまで戻す
    ※ リモートリポジトリと競合しない状態にする
EC2
[memadmin@ip-xx-x-x-xxx memory_tank]$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   A
no changes added to commit (use "git add" and/or "git commit -a")
[memadmin@ip-xx-x-x-xxx memory_tank]$ git checkout A
Updated 1 path from the index
  • リモートリポジトリからpullする
EC2
[memadmin@ip-xx-x-x-xxx memory_tank]$ git pull
Updating 0790397..a16a99b
Fast-forward
 Gemfile                                     | 7 ++++++-
 app/controllers/words_controller.rb         | 4 ++--
 app/models/word.rb                          | 4 ++--
 app/views/devise/registrations/new.html.erb | 2 +-
 app/views/devise/sessions/new.html.erb      | 2 +-
 app/views/words/edit.html.erb               | 4 ++--
 app/views/words/new.html.erb                | 4 ++--
 config/credentials.yml.enc                  | 2 +-
 config/database.yml                         | 8 ++------
 9 files changed, 19 insertions(+), 18 deletions(-)

Gemfile編集

  • 開発環境のファイルとの差分を解消する
EC2
[memadmin@ip-xx-x-x-xxx memory_tank]$ pwd
/var/www/rails/memory_tank
[memadmin@ip-xx-x-x-xxx memory_tank]$ vi Gemfile 以下を追記
+ group :production do
+    gem 'unicorn'
+    gem 'dotenv-rails'
+ end

以上、最後まで読んで頂きありがとうございました!

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