{"id":11359,"date":"2020-07-18T08:20:58","date_gmt":"2020-07-17T23:20:58","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=11359"},"modified":"2023-05-27T22:47:47","modified_gmt":"2023-05-27T13:47:47","slug":"%e3%80%90ruby-on-rails%e3%80%91%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89%e3%81%a7%e4%bd%bf%e3%81%86%e7%92%b0%e5%a2%83%e5%a4%89%e6%95%b0","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=11359","title":{"rendered":"\u3010Ruby on Rails\u3011\u74b0\u5883\u5909\u6570\u306b\u95a2\u3059\u308b\u77e5\u8b58\u3001direnv"},"content":{"rendered":"<h2>Rails\u3067\u74b0\u5883\u5909\u6570\u3092\u4f7f\u3046\u7406\u7531<\/h2>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306aGithub\u306b\u4e0a\u3052\u305f\u304f\u306a\u3044\u3088\u3046\u306a\u60c5\u5831\u306a\u3069\u306f\u30a2\u30d7\u30ea\u306b\u7d44\u307f\u8fbc\u307e\u305a\u306bOS\u306e\u74b0\u5883\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u3066\u8aad\u307f\u8fbc\u307e\u305b\u308b\u3088\u3046\u306b\u3059\u308b\u306e\u304c\u666e\u901a\u3067\u3059\u3002<\/p>\n<ul>\n<li>S3\u306e\u30d0\u30b1\u30c3\u30c8\u540d<\/li>\n<li>AWS\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/li>\n<li>MySQL\u306e\u30d1\u30b9\u30ef\u30fc\u30c9<\/li>\n<li>\u5404\u7a2eAPI\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/li>\n<\/ul>\n<h2>Rails\u3067\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/h2>\n<h3>direnv\u306b\u3066\u8a2d\u5b9a\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u958b\u767a\u74b0\u5883\u7279\u6709\u306e\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a<\/strong><\/span>\u3057\u305f\u3044\u5834\u5408\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002direnv\u3068\u3044\u3046\u30c4\u30fc\u30eb\u3092\u4f7f\u3048\u3070\u8a72\u5f53\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u79fb\u52d5\u3057\u305f\u969b\u306b\u81ea\u52d5\u3067\u8a2d\u5b9a\u3067\u304d\u307e\u3059\u3002\u8a2d\u5b9a\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306f.gitignore\u306b\u5fc5\u305a\u8a2d\u5b9a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>Rails\u3067\u74b0\u5883\u5909\u6570\u3092\u5229\u7528\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/h2>\n<h3>\u30a2\u30d7\u30ea\u5185\u3067\u5229\u7528\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/h3>\n<p>Ruby\u306e<span style=\"color: #ff0000;\"><strong>ENV\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u304b\u3089\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30ad\u30fc\u540d\u3092\u6307\u5b9a\u3059\u308c\u3070\u6b32\u3057\u3044\u74b0\u5883\u5909\u6570\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">ENV['\u30ad\u30fc\u540d']<\/pre>\n<h3>docker-compose\u3067\u5229\u7528\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>$\u74b0\u5883\u5909\u6570\u540d\u3084args<\/strong><\/span>\u306b\u3066\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u57fa\u672c\u306f\u3053\u3061\u3089\u3092\u4f7f\u3046\u3053\u3068\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<h3>Dockerfile\u3067\u5229\u7528\u3059\u308b\u30d1\u30bf\u30fc\u30f3<\/h3>\n<p>\u30ed\u30b1\u30fc\u30eb\u3084\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u306a\u3069\u3002\u56fa\u5b9a\u5024\u306f\u57cb\u3081\u8fbc\u3093\u3067\u3057\u307e\u3063\u3066\u3082\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u305f\u3060\u3001\u3053\u3046\u3057\u305f\u60c5\u5831\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b3\u30fc\u30c9\u3084Dockerfile\u306b\u57cb\u3081\u8fbc\u3093\u3067\u3057\u307e\u3046\u306e\u306f\u975e\u5e38\u306b\u5371\u967a\u306a\u306e\u3067\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>API\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/li>\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u60c5\u5831<\/li>\n<\/ul>\n<h2>\u3069\u306e\u74b0\u5883\u3067\u8d77\u52d5\u3059\u308b\u304b\u306e\u8a2d\u5b9a<\/h2>\n<p>\u74b0\u5883\u5909\u6570<span style=\"color: #ff0000;\"><strong>\u300cRAILS_ENV\u300d<\/strong><\/span>\u3067\u6c7a\u307e\u308a\u307e\u3059\u3002<\/p>\n<h3>\u8d77\u52d5<\/h3>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8d77\u52d5\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u5834\u5408\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u300cdevelopment\u300d\u74b0\u5883\u304c\u9078\u3070\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">rails s<\/pre>\n<p>\u74b0\u5883\u3092\u6307\u5b9a\u3057\u3066\u8d77\u52d5\u3057\u305f\u3044\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">rails s RAILS_ENV=production<\/pre>\n<h2>Rails\u3067\u3088\u304f\u4f7f\u3046\u74b0\u5883\u5909\u6570<\/h2>\n<p>\u4e3b\u306bDocker\u3092\u4f7f\u3063\u3066\u74b0\u5883\u69cb\u7bc9\u3092\u884c\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u969b\u306b\u3088\u304f\u4f7f\u3046\u74b0\u5883\u5909\u6570\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n<h3>DB\u30b3\u30f3\u30c6\u30ca<\/h3>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u74b0\u5883\u5909\u6570<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>MYSQL_ROOT_PASSWORD<\/div>\n<\/div>\n<\/td>\n<td>MySQL\u306eroot\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Web\u30b3\u30f3\u30c6\u30ca<\/h3>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u74b0\u5883\u5909\u6570<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>BUNDLE_PATH<\/div>\n<\/div>\n<\/td>\n<td>\n<div>\n<div>\u300cBUNDLE_PATH=\/app\/vendor\/bundle\u300d\u7b49\u3068\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067bundle install\u3057\u305f\u969b\u306eGem\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5148\u3092\u3053\u3053\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>DEV_HOST<\/div>\n<\/div>\n<\/td>\n<td>\u30db\u30b9\u30c8\u540d\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>S3\u30b3\u30f3\u30c6\u30ca<\/h3>\n<p>\u958b\u767a\u74b0\u5883\u3067\u306fs3\u306e\u4ee3\u308f\u308a\u3068\u306a\u308bminio\u3092\u4f7f\u3046\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u74b0\u5883\u5909\u6570<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>MINIO_ACCESS_KEY<\/div>\n<\/div>\n<\/td>\n<td>minio\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>MINIO_SECRET_KEY<\/div>\n<\/div>\n<\/td>\n<td>minio\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>AP\u30b5\u30fc\u30d0\u306e\u30b3\u30f3\u30c6\u30ca<\/h3>\n<p>AP\u30b5\u30fc\u30d0\uff08Rails\u7b49\uff09\u3067\u306fAWS\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u74b0\u5883\u5909\u6570<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>AWS_ACCESS_KEY_ID<\/div>\n<\/div>\n<\/td>\n<td>AWS\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc<\/td>\n<\/tr>\n<tr>\n<td>\n<div>\n<div>AWS_SECRET_ACCESS_KEY<\/div>\n<\/div>\n<\/td>\n<td>AWS\u306e\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4ed6\u306e\u624b\u6cd5<\/h2>\n<p>AWS\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3042\u308c\u3070\u4eca\u306f\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>Secrets Manager\u3092\u4f7f\u3046\u3002<\/h3>\n<p>ECS\u30bf\u30b9\u30af\u5185\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>SSM\u30d1\u30e9\u30e1\u30fc\u30bf\u30b9\u30c8\u30a2\u3092\u4f7f\u3046\u3002<\/h3>\n<p>\u306a\u304a\u3001\u3053\u3061\u3089\u3092\u6271\u3046\u5834\u5408\u306f\u30d7\u30ec\u30fc\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u6271\u3046string\u5b9a\u7fa9\u3068\u3001\u6697\u53f7\u5316\u3055\u308c\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6271\u3046secure string\u5b9a\u7fa9\u304c\u3042\u308b\u3002\u6a5f\u5bc6\u60c5\u5831\u3092\u6271\u3046\u5834\u5408\u306f<span style=\"color: #ff0000;\"><strong>\u300csecure string\u5b9a\u7fa9\u300d<\/strong><\/span>\u3092\u4f7f\u3046\u3068\u826f\u3044\u3002<\/p>\n<h2>direnv\u3068\u306f\uff1f<\/h2>\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3054\u3068\u306b\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<h3>\u30e1\u30ea\u30c3\u30c8<\/h3>\n<ul>\n<li>\u958b\u767a\u3057\u3066\u3044\u308b\u30a2\u30d7\u30ea\u3054\u3068\u306b\u74b0\u5883\u5909\u6570\u3092\u5909\u3048\u305f\u3044\u5834\u5408\u306b\u91cd\u5b9d\u3059\u308b\u3002<\/li>\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u3001GitHub\u306b\u6b8b\u3057\u305f\u304f\u306a\u3044\u304c\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u306b\u63d0\u4f9b\u3057\u305f\u3044\u60c5\u5831\u3092\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u6271\u3046\u3002<\/li>\n<\/ul>\n<h3>\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u4e00\u89a7<\/h3>\n<ul>\n<li>AWS\u306e\u74b0\u5883\u5909\u6570\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408(AWS_PROFILE\u3001AWS_DEFAULT_PROFILE)<\/li>\n<li>API\u306e\u79d8\u5bc6\u9375<\/li>\n<\/ul>\n<h3>\u57cb\u3081\u8fbc\u307f\u305f\u3044\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a<\/h3>\n<pre class=\"lang:default decode:true\">direnv edit .<\/pre>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068<span style=\"color: #ff0000;\"><strong>\u300c.envrc\u300d<\/strong><\/span>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u4e2d\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306b\u74b0\u5883\u5909\u6570\u3092\u57cb\u3081\u8fbc\u3093\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true  \">export \u74b0\u5883\u5909\u6570\u540d1=\u5909\u6570\u5185\u5bb91\r\nexport \u74b0\u5883\u5909\u6570\u540d2=\u5909\u6570\u5185\u5bb92<\/pre>\n","protected":false},"excerpt":{"rendered":"Rails\u3067\u74b0\u5883\u5909\u6570\u3092\u4f7f\u3046\u7406\u7531 \u4e0b\u8a18\u306e\u3088\u3046\u306aGithub\u306b\u4e0a\u3052\u305f\u304f\u306a\u3044\u3088\u3046\u306a\u60c5\u5831\u306a\u3069\u306f\u30a2\u30d7\u30ea\u306b\u7d44\u307f\u8fbc\u307e\u305a\u306bOS\u306e\u74b0\u5883\u5909\u6570\u306b\u8a2d\u5b9a\u3057\u3066\u8aad\u307f\u8fbc\u307e\u305b\u308b\u3088\u3046\u306b\u3059\u308b\u306e\u304c\u666e\u901a\u3067\u3059\u3002 S3\u306e\u30d0\u30b1\u30c3\u30c8\u540d AWS\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc MySQL\u306e [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[36],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11359"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11359"}],"version-history":[{"count":13,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11359\/revisions"}],"predecessor-version":[{"id":20512,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11359\/revisions\/20512"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11359"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}