回答編集履歴
1
Add seccond expression
answer
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
## 元の回答
|
2
|
+
|
1
3
|
参照している公式ドキュメントのすぐ下に書いてあるように、
|
2
4
|
フォルダは生成されません
|
3
5
|
ファイルは `docker-compose.yml` などと同階層に作成されます
|
@@ -47,4 +49,168 @@
|
|
47
49
|
|
48
50
|
```console
|
49
51
|
rails new .
|
52
|
+
```
|
53
|
+
|
54
|
+
## 追記
|
55
|
+
|
56
|
+
> フォルダの名前を「myapp」以外にすると、このようなログが出力されます。
|
57
|
+
> myappの部分をすべて任意の名前のフォルダ名に変更したのですが
|
58
|
+
|
59
|
+
どこかで書き換えを誤っているものと思われます
|
60
|
+
|
61
|
+
すべての箇所を正確に書き換えればファイルは出力されます
|
62
|
+
以下に `myapp` をすべて `hello-world` に書き換えて実行した結果を示します
|
63
|
+
|
64
|
+
`Dockerfile`:
|
65
|
+
|
66
|
+
```dockerfile
|
67
|
+
FROM ruby:2.5
|
68
|
+
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
|
69
|
+
RUN mkdir /hello-world
|
70
|
+
WORKDIR /hello-world
|
71
|
+
COPY Gemfile /hello-world/Gemfile
|
72
|
+
COPY Gemfile.lock /hello-world/Gemfile.lock
|
73
|
+
RUN bundle install
|
74
|
+
COPY . /hello-world
|
75
|
+
|
76
|
+
# Add a script to be executed every time the container starts.
|
77
|
+
COPY entrypoint.sh /usr/bin/
|
78
|
+
RUN chmod +x /usr/bin/entrypoint.sh
|
79
|
+
ENTRYPOINT ["entrypoint.sh"]
|
80
|
+
EXPOSE 3000
|
81
|
+
|
82
|
+
# Start the main process.
|
83
|
+
CMD ["rails", "server", "-b", "0.0.0.0"]
|
84
|
+
```
|
85
|
+
|
86
|
+
`entrypoint.sh`:
|
87
|
+
|
88
|
+
```bash
|
89
|
+
#!/bin/bash
|
90
|
+
set -e
|
91
|
+
|
92
|
+
# Remove a potentially pre-existing server.pid for Rails.
|
93
|
+
rm -f /hello-world/tmp/pids/server.pid
|
94
|
+
|
95
|
+
# Then exec the container's main process (what's set as CMD in the Dockerfile).
|
96
|
+
exec "$@"
|
97
|
+
```
|
98
|
+
|
99
|
+
`docker-compose.yml`:
|
100
|
+
|
101
|
+
```yaml
|
102
|
+
version: '3'
|
103
|
+
services:
|
104
|
+
db:
|
105
|
+
image: postgres
|
106
|
+
volumes:
|
107
|
+
- ./tmp/db:/var/lib/postgresql/data
|
108
|
+
environment:
|
109
|
+
POSTGRES_PASSWORD: password
|
110
|
+
web:
|
111
|
+
build: .
|
112
|
+
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
113
|
+
volumes:
|
114
|
+
- .:/hello-world
|
115
|
+
ports:
|
116
|
+
- "3000:3000"
|
117
|
+
depends_on:
|
118
|
+
- db
|
119
|
+
```
|
120
|
+
|
121
|
+
コマンド:
|
122
|
+
|
123
|
+
```console
|
124
|
+
$ docker-compose run web rails new . --force --no-deps --database=postgresql
|
125
|
+
Creating network "test-rails_default" with the default driver
|
126
|
+
|
127
|
+
---略---
|
128
|
+
|
129
|
+
Successfully built fe37ff08edcf
|
130
|
+
Successfully tagged test-rails_web:latest
|
131
|
+
Starting test-rails_db_1 ... done
|
132
|
+
exist
|
133
|
+
create README.md
|
134
|
+
create Rakefile
|
135
|
+
create .ruby-version
|
136
|
+
create config.ru
|
137
|
+
create .gitignore
|
138
|
+
force Gemfile
|
139
|
+
run git init from "."
|
140
|
+
Initialized empty Git repository in /hello-world/.git/
|
141
|
+
create package.json
|
142
|
+
create app
|
143
|
+
create app/assets/config/manifest.js
|
144
|
+
|
145
|
+
---略---
|
146
|
+
|
147
|
+
create tmp/storage
|
148
|
+
create tmp/storage/.keep
|
149
|
+
remove config/initializers/cors.rb
|
150
|
+
remove config/initializers/new_framework_defaults_5_2.rb
|
151
|
+
run bundle install
|
152
|
+
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`.
|
153
|
+
Fetching gem metadata from https://rubygems.org/............
|
154
|
+
Fetching gem metadata from https://rubygems.org/.
|
155
|
+
Resolving dependencies....
|
156
|
+
Using rake 13.0.1
|
157
|
+
|
158
|
+
---略---
|
159
|
+
|
160
|
+
Bundle complete! 18 Gemfile dependencies, 78 gems now installed.
|
161
|
+
Use `bundle info [gemname]` to see where a bundled gem is installed.
|
162
|
+
Post-install message from chromedriver-helper:
|
163
|
+
|
164
|
+
+--------------------------------------------------------------------+
|
165
|
+
| |
|
166
|
+
| NOTICE: chromedriver-helper is deprecated after 2019-03-31. |
|
167
|
+
| |
|
168
|
+
| Please update to use the 'webdrivers' gem instead. |
|
169
|
+
| See https://github.com/flavorjones/chromedriver-helper/issues/83 |
|
170
|
+
| |
|
171
|
+
+--------------------------------------------------------------------+
|
172
|
+
|
173
|
+
Post-install message from sass:
|
174
|
+
|
175
|
+
Ruby Sass has reached end-of-life and should no longer be used.
|
176
|
+
|
177
|
+
* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
|
178
|
+
primary implementation: https://sass-lang.com/install
|
179
|
+
|
180
|
+
* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
|
181
|
+
sassc gem: https://github.com/sass/sassc-ruby#readme
|
182
|
+
|
183
|
+
* For more details, please refer to the Sass blog:
|
184
|
+
https://sass-lang.com/blog/posts/7828841
|
185
|
+
|
186
|
+
run bundle exec spring binstub --all
|
187
|
+
* bin/rake: Spring inserted
|
188
|
+
* bin/rails: Spring inserted
|
189
|
+
```
|
190
|
+
|
191
|
+
ファイルの確認:
|
192
|
+
|
193
|
+
```console
|
194
|
+
$ ls -l
|
195
|
+
total 35
|
196
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 app
|
197
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:58 bin
|
198
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 config
|
199
|
+
-rw-r--r-- 1 shinoda 197121 130 Jul 4 19:57 config.ru
|
200
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 db
|
201
|
+
-rw-r--r-- 1 shinoda 197121 377 Jul 4 19:56 docker-compose.yml
|
202
|
+
-rw-r--r-- 1 shinoda 197121 498 Jul 4 19:55 Dockerfile
|
203
|
+
-rwxr-xr-x 1 shinoda 197121 207 Jul 4 19:55 entrypoint.sh
|
204
|
+
-rw-r--r-- 1 shinoda 197121 2228 Jul 4 19:57 Gemfile
|
205
|
+
-rw-r--r-- 1 shinoda 197121 5324 Jul 4 19:58 Gemfile.lock
|
206
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 lib
|
207
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 log
|
208
|
+
-rw-r--r-- 1 shinoda 197121 69 Jul 4 19:57 package.json
|
209
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 public
|
210
|
+
-rw-r--r-- 1 shinoda 197121 227 Jul 4 19:57 Rakefile
|
211
|
+
-rw-r--r-- 1 shinoda 197121 374 Jul 4 19:57 README.md
|
212
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 storage
|
213
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 test
|
214
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 tmp
|
215
|
+
drwxr-xr-x 1 shinoda 197121 0 Jul 4 19:57 vendor
|
50
216
|
```
|