{"id":272,"date":"2016-06-02T18:46:29","date_gmt":"2016-06-02T09:46:29","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2016\/06\/02\/deploy-rails-to-opsworks-chef11-with-custom-layer"},"modified":"2016-06-02T18:46:29","modified_gmt":"2016-06-02T09:46:29","slug":"deploy-rails-to-opsworks-chef11-with-custom-layer","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2016\/06\/02\/deploy-rails-to-opsworks-chef11-with-custom-layer\/","title":{"rendered":"\u3010OpsWorks(Chef11)\u3011\u8907\u6570\u306eRails\u30ec\u30a4\u30e4\u30fc\u3067\u7c21\u5358\u306b\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b5\u3064\u306e\u8a2d\u5b9a"},"content":{"rendered":"
\u524d\u7530\u3067\u3059\u3002 \u3055\u3066\u30d6\u30ed\u30b0\u3067\u3059\u304c\u3001\u524d\u56de\u306e\u7d9a\u304d\u306e\u300cChef12\u306b\u5bfe\u5fdc\u3057\u305fAWS OpsWorks\u306bRails\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u300d<\/a>\u306e\u7b2c3\u56de\u76ee\u3092\u3084\u308d\u3046\u304b\u3068\u601d\u3044\u307e\u3057\u305f\u304c\u3001\u5c11\u3057\u5909\u3048\u3066\u3001\u300cOpsWorks Chef11\u7248\u306b\u3001\u8907\u6570\u306eRails\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4\u3067\u304d\u308b\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u300d\u3068\u3044\u3046\u5185\u5bb9\u3067\u66f8\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n Chef11\u7248\u306eOpsWorks\u306b\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067Rails\u30ec\u30a4\u30e4\u30fc\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u306e\u306f\u7c21\u5358\u3067\u3059\u3002 <\/p>\n VPC(\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u3082\u826f\u3044), EC2\u7528\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7, EC2\u30ad\u30fc\u30da\u30a2, RDS(MySQL 5.6.27), Rails\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3(Rails 4.2.6, ruby 2.2.5, bundler 1.12.4, GitHub\u304bBitBucket\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u3066\u3044\u308b\u72b6\u614b), Custom Chef Cookbooks\u30ec\u30dd\u30b8\u30c8\u30ea<\/p>\n OpsWorks\u306eStack\u3092\u4f5c\u6210\u3057\u3001Custom\u30ec\u30a4\u30e4\u30fc\u306e\u4f5c\u6210\u3001RDS\u306e\u8a2d\u5b9a\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u306a\u3069\u3092\u6e08\u307e\u305b\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n \u30c7\u30d7\u30ed\u30a4\u6642\u306bmigration\u3059\u308b\u70ba\u306e\u8a2d\u5b9a\u3067\u3059\u3002<\/p>\n Stack\u306eCustomJSON\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u826f\u3044\u306e\u3067\u3059\u304c\u3001Stack\u5185\u306b\u69d8\u3005\u306a\u30ec\u30a4\u30e4\u30fc\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306bRails\u30ec\u30a4\u30e4\u30fc\u306b\u3060\u3051CustomJSON\u3092\u30bb\u30c3\u30c8\u3057\u305f\u3044\u306e\u3067\u3001\u30ec\u30a4\u30e4\u30fc\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002 OpsWorks\u3067\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u30ec\u30b7\u30d4\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n <\/p>\n
\n\u4eca\u3061\u3087\u3046\u3069AWS\u30b5\u30df\u30c3\u30c8<\/a>\u304c\u958b\u50ac\u3055\u308c\u3066\u3044\u307e\u3059\u306d\u3002
\n\u6628\u5e74\u306e\u3088\u3046\u306bYouTube\u306b\u30a2\u30c3\u30d7<\/a>\u3055\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u307e\u305f\u6642\u9593\u304c\u3042\u308b\u6642\u306b\u898b\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
\n\u3057\u304b\u3057Chef11\u7248\u3067\u306f\u3001\u30b9\u30bf\u30c3\u30af\u5185\u306b\u306f1\u3064\u306eRails\u30ec\u30a4\u30e4\u30fc\u3057\u304b\u4f5c\u6210\u51fa\u6765\u306a\u3044\u3088\u3046\u306b\u306a\u3063\u3066\u304a\u308a\u3001\u30b9\u30bf\u30c3\u30af\u5185\u30672\u3064\u4ee5\u4e0a\u306eRails\u30a2\u30d7\u30ea\u304c\u5fc5\u8981\u3068\u306a\u3063\u305f\u5834\u5408\u3001\u81ea\u5206\u3067\u7528\u610f\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002
\n\u4eca\u56de\u306f\u30b9\u30bf\u30c3\u30af\u5185\u306b\u3001\u3044\u304f\u3064\u3082\u4f5c\u308b\u3053\u3068\u304c\u51fa\u6765\u308bCustom\u30ec\u30a4\u30e4\u30fc\u3092\u4f7f\u3063\u3066\u3001\u8907\u6570\u306e\u30ab\u30b9\u30bf\u30e0Rails\u30ec\u30a4\u30e4\u30fc\u3092\u4f5c\u6210\u3057\u3001\u5404\u30ec\u30a4\u30e4\u30fc\u306bRails\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308bOpsWorks\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\u30b4\u30fc\u30eb\u56f3<\/h4>\n
\u6e96\u5099<\/h2>\n
\u5fc5\u8981\u306a\u3082\u306e<\/h4>\n
OpsWorks\u6e96\u5099<\/h4>\n
Custom Layer\u306bRails\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b5\u3064\u306e\u8a2d\u5b9a<\/h2>\n
1. OpsWorks Stack\u306bCustomJSON\u3092\u30bb\u30c3\u30c8<\/h4>\n
{\n "deploy": {\n "\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d": {\n "migrate": true\n }\n }\n}<\/code><\/pre>\n
2. Custom Layer\u306bCustomJSON\u3092\u30bb\u30c3\u30c8<\/h4>\n
\nruby_version 2.2<\/code>\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u30ce\u30fc\u30c9\u306b\u306f2.2\u306e\u6700\u65b0\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002(2016\/6\/3\u73fe\u5728\u306f2.2.5)<\/p>\n
{\n "opsworks": {\n "rails_stack": {\n "name": "nginx_unicorn"\n },\n "ruby_version": "2.2"\n },\n "languages": {\n "ruby": {\n "ruby_bin": "\/usr\/bin\/ruby"\n }\n },\n "rails": {\n "max_pool_size": 2\n },\n "unicorn": {\n },\n "opsworks_bundler": {\n "version": "1.12.4",\n "manage_package": true\n }\n}<\/code><\/pre>\n
3. \u30ec\u30a4\u30e4\u30fc\u306b\u30ec\u30b7\u30d4\u3092\u30bb\u30c3\u30c8<\/h4>\n
4. \u30c7\u30d7\u30ed\u30a4\u30ec\u30b7\u30d4\u3092\u7528\u610f\u3057\u3001deploy.rb\u3092\u4fee\u6b63<\/h4>\n