回答編集履歴

1

Add seccond expression

2020/07/04 11:21

投稿

y_shinoda
y_shinoda

スコア3272

test CHANGED
@@ -1,3 +1,7 @@
1
+ ## 元の回答
2
+
3
+
4
+
1
5
  参照している公式ドキュメントのすぐ下に書いてあるように、
2
6
 
3
7
  フォルダは生成されません
@@ -97,3 +101,331 @@
97
101
  rails new .
98
102
 
99
103
  ```
104
+
105
+
106
+
107
+ ## 追記
108
+
109
+
110
+
111
+ > フォルダの名前を「myapp」以外にすると、このようなログが出力されます。
112
+
113
+ > myappの部分をすべて任意の名前のフォルダ名に変更したのですが
114
+
115
+
116
+
117
+ どこかで書き換えを誤っているものと思われます
118
+
119
+
120
+
121
+ すべての箇所を正確に書き換えればファイルは出力されます
122
+
123
+ 以下に `myapp` をすべて `hello-world` に書き換えて実行した結果を示します
124
+
125
+
126
+
127
+ `Dockerfile`:
128
+
129
+
130
+
131
+ ```dockerfile
132
+
133
+ FROM ruby:2.5
134
+
135
+ RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
136
+
137
+ RUN mkdir /hello-world
138
+
139
+ WORKDIR /hello-world
140
+
141
+ COPY Gemfile /hello-world/Gemfile
142
+
143
+ COPY Gemfile.lock /hello-world/Gemfile.lock
144
+
145
+ RUN bundle install
146
+
147
+ COPY . /hello-world
148
+
149
+
150
+
151
+ # Add a script to be executed every time the container starts.
152
+
153
+ COPY entrypoint.sh /usr/bin/
154
+
155
+ RUN chmod +x /usr/bin/entrypoint.sh
156
+
157
+ ENTRYPOINT ["entrypoint.sh"]
158
+
159
+ EXPOSE 3000
160
+
161
+
162
+
163
+ # Start the main process.
164
+
165
+ CMD ["rails", "server", "-b", "0.0.0.0"]
166
+
167
+ ```
168
+
169
+
170
+
171
+ `entrypoint.sh`:
172
+
173
+
174
+
175
+ ```bash
176
+
177
+ #!/bin/bash
178
+
179
+ set -e
180
+
181
+
182
+
183
+ # Remove a potentially pre-existing server.pid for Rails.
184
+
185
+ rm -f /hello-world/tmp/pids/server.pid
186
+
187
+
188
+
189
+ # Then exec the container's main process (what's set as CMD in the Dockerfile).
190
+
191
+ exec "$@"
192
+
193
+ ```
194
+
195
+
196
+
197
+ `docker-compose.yml`:
198
+
199
+
200
+
201
+ ```yaml
202
+
203
+ version: '3'
204
+
205
+ services:
206
+
207
+ db:
208
+
209
+ image: postgres
210
+
211
+ volumes:
212
+
213
+ - ./tmp/db:/var/lib/postgresql/data
214
+
215
+ environment:
216
+
217
+ POSTGRES_PASSWORD: password
218
+
219
+ web:
220
+
221
+ build: .
222
+
223
+ command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
224
+
225
+ volumes:
226
+
227
+ - .:/hello-world
228
+
229
+ ports:
230
+
231
+ - "3000:3000"
232
+
233
+ depends_on:
234
+
235
+ - db
236
+
237
+ ```
238
+
239
+
240
+
241
+ コマンド:
242
+
243
+
244
+
245
+ ```console
246
+
247
+ $ docker-compose run web rails new . --force --no-deps --database=postgresql
248
+
249
+ Creating network "test-rails_default" with the default driver
250
+
251
+
252
+
253
+ ---略---
254
+
255
+
256
+
257
+ Successfully built fe37ff08edcf
258
+
259
+ Successfully tagged test-rails_web:latest
260
+
261
+ Starting test-rails_db_1 ... done
262
+
263
+ exist
264
+
265
+ create README.md
266
+
267
+ create Rakefile
268
+
269
+ create .ruby-version
270
+
271
+ create config.ru
272
+
273
+ create .gitignore
274
+
275
+ force Gemfile
276
+
277
+ run git init from "."
278
+
279
+ Initialized empty Git repository in /hello-world/.git/
280
+
281
+ create package.json
282
+
283
+ create app
284
+
285
+ create app/assets/config/manifest.js
286
+
287
+
288
+
289
+ ---略---
290
+
291
+
292
+
293
+ create tmp/storage
294
+
295
+ create tmp/storage/.keep
296
+
297
+ remove config/initializers/cors.rb
298
+
299
+ remove config/initializers/new_framework_defaults_5_2.rb
300
+
301
+ run bundle install
302
+
303
+ The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
304
+
305
+ Fetching gem metadata from https://rubygems.org/............
306
+
307
+ Fetching gem metadata from https://rubygems.org/.
308
+
309
+ Resolving dependencies....
310
+
311
+ Using rake 13.0.1
312
+
313
+
314
+
315
+ ---略---
316
+
317
+
318
+
319
+ Bundle complete! 18 Gemfile dependencies, 78 gems now installed.
320
+
321
+ Use `bundle info [gemname]` to see where a bundled gem is installed.
322
+
323
+ Post-install message from chromedriver-helper:
324
+
325
+
326
+
327
+ +--------------------------------------------------------------------+
328
+
329
+ | |
330
+
331
+ | NOTICE: chromedriver-helper is deprecated after 2019-03-31. |
332
+
333
+ | |
334
+
335
+ | Please update to use the 'webdrivers' gem instead. |
336
+
337
+ | See https://github.com/flavorjones/chromedriver-helper/issues/83 |
338
+
339
+ | |
340
+
341
+ +--------------------------------------------------------------------+
342
+
343
+
344
+
345
+ Post-install message from sass:
346
+
347
+
348
+
349
+ Ruby Sass has reached end-of-life and should no longer be used.
350
+
351
+
352
+
353
+ * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
354
+
355
+ primary implementation: https://sass-lang.com/install
356
+
357
+
358
+
359
+ * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
360
+
361
+ sassc gem: https://github.com/sass/sassc-ruby#readme
362
+
363
+
364
+
365
+ * For more details, please refer to the Sass blog:
366
+
367
+ https://sass-lang.com/blog/posts/7828841
368
+
369
+
370
+
371
+ run bundle exec spring binstub --all
372
+
373
+ * bin/rake: Spring inserted
374
+
375
+ * bin/rails: Spring inserted
376
+
377
+ ```
378
+
379
+
380
+
381
+ ファイルの確認:
382
+
383
+
384
+
385
+ ```console
386
+
387
+ $ ls -l
388
+
389
+ total 35
390
+
391
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 app
392
+
393
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:58 bin
394
+
395
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 config
396
+
397
+ -rw-r--r-- 1 shinoda 197121 130 Jul 4 19:57 config.ru
398
+
399
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 db
400
+
401
+ -rw-r--r-- 1 shinoda 197121 377 Jul 4 19:56 docker-compose.yml
402
+
403
+ -rw-r--r-- 1 shinoda 197121 498 Jul 4 19:55 Dockerfile
404
+
405
+ -rwxr-xr-x 1 shinoda 197121 207 Jul 4 19:55 entrypoint.sh
406
+
407
+ -rw-r--r-- 1 shinoda 197121 2228 Jul 4 19:57 Gemfile
408
+
409
+ -rw-r--r-- 1 shinoda 197121 5324 Jul 4 19:58 Gemfile.lock
410
+
411
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 lib
412
+
413
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 log
414
+
415
+ -rw-r--r-- 1 shinoda 197121 69 Jul 4 19:57 package.json
416
+
417
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 public
418
+
419
+ -rw-r--r-- 1 shinoda 197121 227 Jul 4 19:57 Rakefile
420
+
421
+ -rw-r--r-- 1 shinoda 197121 374 Jul 4 19:57 README.md
422
+
423
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 storage
424
+
425
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 test
426
+
427
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 tmp
428
+
429
+ drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 vendor
430
+
431
+ ```