質問編集履歴
2
1.内容の一部が消えてたので追加しました。 2.Ruby on Railsに関する質問からDockerに関する質問にしました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
dockerでrails
|
1
|
+
dockerでrails newをするとエラーになる。
|
test
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
rails newをしたいけど、エラーになるので、解決策が知りたい。
|
4
4
|
|
5
|
+
|
6
|
+
|
5
7
|
#使用している環境
|
6
8
|
|
7
9
|
windows10 64bit
|
@@ -10,21 +12,291 @@
|
|
10
12
|
|
11
13
|
|
12
14
|
|
15
|
+
#問題が発生するまでの流れ・手順
|
16
|
+
|
13
17
|
[参考にしたサイト](https://qiita.com/naokit-dev/items/99225bf3d8665ecfdec2)
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
[このページから](http://https://github.com/naokit-dev/sample_app_on_docker.git)git cloneをして、5つのファイル(Dockerfile, docker-compose.yml, Gemfile, Gemfile.lock, entrypoint.sh)ができました。以下、ファイルの中身です。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```Dockerfile
|
24
|
+
|
25
|
+
FROM ruby:2.6.3-alpine
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
ENV LANG=ja_JP.UTF-8
|
30
|
+
|
31
|
+
ENV TZ=Asia/Tokyo
|
32
|
+
|
33
|
+
ENV ROOT=/myapp \
|
34
|
+
|
35
|
+
GEM_HOME=/bundle \
|
36
|
+
|
37
|
+
BUNDLE_PATH=$GEM_HOME
|
38
|
+
|
39
|
+
ENV BUNDLE_BIN=$BUNDLE_PATH/bin
|
40
|
+
|
41
|
+
ENV PATH /app/bin:$BUNDLE_BIN:$PATH
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
WORKDIR $ROOT
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
RUN apk update && \
|
52
|
+
|
53
|
+
apk upgrade && \
|
54
|
+
|
55
|
+
apk add --no-cache \
|
56
|
+
|
57
|
+
gcc \
|
58
|
+
|
59
|
+
g++ \
|
60
|
+
|
61
|
+
libc-dev \
|
62
|
+
|
63
|
+
libxml2-dev \
|
64
|
+
|
65
|
+
linux-headers \
|
66
|
+
|
67
|
+
make \
|
68
|
+
|
69
|
+
nodejs \
|
70
|
+
|
71
|
+
postgresql \
|
72
|
+
|
73
|
+
postgresql-dev \
|
74
|
+
|
75
|
+
tzdata \
|
76
|
+
|
77
|
+
yarn && \
|
78
|
+
|
79
|
+
apk add --virtual build-packs --no-cache \
|
80
|
+
|
81
|
+
build-base \
|
82
|
+
|
83
|
+
curl-dev
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
COPY Gemfile $ROOT
|
88
|
+
|
89
|
+
COPY Gemfile.lock $ROOT
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
RUN bundle install -j4
|
94
|
+
|
95
|
+
# 不要ファイル削除
|
96
|
+
|
97
|
+
RUN rm -rf /usr/local/bundle/cache/* /usr/local/share/.cache/* /var/cache/* /tmp/* && \
|
98
|
+
|
99
|
+
apk del build-packs
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
COPY . $ROOT
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
# Add a script to be executed every time the container starts.
|
108
|
+
|
109
|
+
COPY entrypoint.sh /usr/bin/
|
110
|
+
|
111
|
+
RUN chmod +x /usr/bin/entrypoint.sh
|
112
|
+
|
113
|
+
ENTRYPOINT ["sh", "/usr/bin/entrypoint.sh"]
|
114
|
+
|
115
|
+
EXPOSE 3000
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
# Start the main process.
|
120
|
+
|
121
|
+
# CMD ["rails", "server", "-b", "0.0.0.0"]
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
```dockercomposeyml
|
128
|
+
|
129
|
+
version: '3'
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
services:
|
134
|
+
|
135
|
+
db:
|
136
|
+
|
137
|
+
image: postgres:11.0-alpine
|
138
|
+
|
139
|
+
volumes:
|
140
|
+
|
141
|
+
- postgres:/var/lib/postgresql/data:cached
|
142
|
+
|
143
|
+
environment:
|
144
|
+
|
145
|
+
- TZ=Asia/Tokyo
|
146
|
+
|
147
|
+
ports:
|
148
|
+
|
149
|
+
- '5432:5432'
|
150
|
+
|
151
|
+
environment:
|
152
|
+
|
153
|
+
PGDATA: /var/lib/postgresql/data/pgdata
|
154
|
+
|
155
|
+
POSTGRES_USER: postgres
|
156
|
+
|
157
|
+
POSTGRES_PASSWORD: password
|
158
|
+
|
159
|
+
POSTGRES_INITDB_ARGS: '--encoding=UTF-8 --locale=ja_JP.UTF-8'
|
160
|
+
|
161
|
+
TZ: Asia/Tokyo
|
162
|
+
|
163
|
+
app:
|
164
|
+
|
165
|
+
build: .
|
166
|
+
|
167
|
+
command: ash -c "rm -f tmp/pids/server.pid && ./bin/rails s -p 3000 -b '0.0.0.0'"
|
168
|
+
|
169
|
+
volumes:
|
170
|
+
|
171
|
+
- .:/myapp:cached
|
172
|
+
|
173
|
+
- rails_cache:/myapp/tmp/cache
|
174
|
+
|
175
|
+
- bundle:/bundle:cached
|
176
|
+
|
177
|
+
tmpfs:
|
178
|
+
|
179
|
+
- /tmp
|
180
|
+
|
181
|
+
tty: true
|
182
|
+
|
183
|
+
stdin_open: true
|
184
|
+
|
185
|
+
ports:
|
186
|
+
|
187
|
+
- "3000:3000"
|
188
|
+
|
189
|
+
environment:
|
190
|
+
|
191
|
+
RAILS_ENV: development
|
192
|
+
|
193
|
+
NODE_ENV: development
|
194
|
+
|
195
|
+
DATABASE_HOST: db
|
196
|
+
|
197
|
+
DATABASE_PORT: 5432
|
198
|
+
|
199
|
+
DATABASE_USER: postgres
|
200
|
+
|
201
|
+
DATABASE_PASSWORD: password
|
202
|
+
|
203
|
+
WEBPACKER_DEV_SERVER_HOST: webpacker
|
204
|
+
|
205
|
+
depends_on:
|
206
|
+
|
207
|
+
- db
|
208
|
+
|
209
|
+
- webpacker
|
210
|
+
|
211
|
+
links:
|
212
|
+
|
213
|
+
- db
|
214
|
+
|
215
|
+
- webpacker
|
216
|
+
|
217
|
+
webpacker:
|
218
|
+
|
219
|
+
build: .
|
220
|
+
|
221
|
+
command: ./bin/webpack-dev-server
|
222
|
+
|
223
|
+
volumes:
|
224
|
+
|
225
|
+
- .:/myapp:cached
|
226
|
+
|
227
|
+
environment:
|
228
|
+
|
229
|
+
RAILS_ENV: development
|
230
|
+
|
231
|
+
NODE_ENV: development
|
232
|
+
|
233
|
+
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
|
234
|
+
|
235
|
+
tty: false
|
236
|
+
|
237
|
+
stdin_open: false
|
238
|
+
|
239
|
+
ports:
|
240
|
+
|
241
|
+
- '3035:3035'
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
volumes:
|
246
|
+
|
247
|
+
rails_cache:
|
248
|
+
|
249
|
+
postgres:
|
250
|
+
|
251
|
+
bundle:
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
```
|
256
|
+
|
257
|
+
```Gemfile
|
258
|
+
|
259
|
+
source 'https://rubygems.org'
|
260
|
+
|
261
|
+
gem 'rails', '6.0.3'
|
262
|
+
|
263
|
+
```
|
264
|
+
|
265
|
+
```Gemfilelock
|
266
|
+
|
267
|
+
空です。
|
268
|
+
|
269
|
+
```
|
270
|
+
|
271
|
+
```entrypoint.sh
|
272
|
+
|
273
|
+
#!/bin/bash
|
274
|
+
|
275
|
+
set -e
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
# Remove a potentially pre-existing server.pid for Rails.
|
280
|
+
|
281
|
+
rm -f /myapp/tmp/pids/server.pid
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
# Then exec the container's main process (what's set as CMD in the Dockerfile).
|
286
|
+
|
287
|
+
exec "$@"
|
288
|
+
|
289
|
+
```
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
#発生している問題・エラーメッセージ
|
294
|
+
|
295
|
+
2.docker-compose run app rails new . --force --no-deps --database=postgresql --skip-bundleをしようとしたら以下のようなエラーが出ました。
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
```
|
28
300
|
|
29
301
|
[+] Building 18.3s (10/14)
|
30
302
|
|
@@ -66,266 +338,6 @@
|
|
66
338
|
|
67
339
|
#10 5.293 Fetching rake 13.0.6
|
68
340
|
|
69
|
-
#10 5.438 Installing rake 13.0.6
|
70
|
-
|
71
|
-
#10 5.490 Fetching concurrent-ruby 1.1.9
|
72
|
-
|
73
|
-
#10 5.493 Fetching thread_safe 0.3.6
|
74
|
-
|
75
|
-
#10 5.494 Fetching minitest 5.14.4
|
76
|
-
|
77
|
-
#10 5.669 Installing minitest 5.14.4
|
78
|
-
|
79
|
-
#10 5.681 Installing thread_safe 0.3.6
|
80
|
-
|
81
|
-
#10 5.740 Fetching zeitwerk 2.4.2
|
82
|
-
|
83
|
-
#10 5.778 Installing concurrent-ruby 1.1.9
|
84
|
-
|
85
|
-
#10 5.831 Fetching builder 3.2.4
|
86
|
-
|
87
|
-
#10 5.851 Installing zeitwerk 2.4.2
|
88
|
-
|
89
|
-
#10 5.886 Fetching erubi 1.10.0
|
90
|
-
|
91
|
-
#10 5.962 Installing builder 3.2.4
|
92
|
-
|
93
|
-
#10 6.017 Installing erubi 1.10.0
|
94
|
-
|
95
|
-
#10 6.065 Fetching mini_portile2 2.6.1
|
96
|
-
|
97
|
-
#10 6.092 Fetching racc 1.5.2
|
98
|
-
|
99
|
-
#10 6.115 Fetching crass 1.0.6
|
100
|
-
|
101
|
-
#10 6.184 Installing mini_portile2 2.6.1
|
102
|
-
|
103
|
-
#10 6.203 Fetching rack 2.2.3
|
104
|
-
|
105
|
-
#10 6.269 Installing crass 1.0.6
|
106
|
-
|
107
|
-
#10 6.293 Fetching nio4r 2.5.8
|
108
|
-
|
109
|
-
#10 6.381 Installing racc 1.5.2 with native extensions
|
110
|
-
|
111
|
-
#10 6.477 Installing rack 2.2.3
|
112
|
-
|
113
|
-
#10 6.502 Installing nio4r 2.5.8 with native extensions
|
114
|
-
|
115
|
-
#10 10.19 Fetching mini_mime 1.1.1
|
116
|
-
|
117
|
-
#10 10.19 Fetching websocket-extensions 0.1.5
|
118
|
-
|
119
|
-
#10 10.21 Using bundler 1.17.2
|
120
|
-
|
121
|
-
#10 10.22 Fetching method_source 1.0.0
|
122
|
-
|
123
|
-
#10 10.30 Installing websocket-extensions 0.1.5
|
124
|
-
|
125
|
-
#10 10.32 Installing method_source 1.0.0
|
126
|
-
|
127
|
-
#10 10.34 Installing mini_mime 1.1.1
|
128
|
-
|
129
|
-
#10 10.34 Fetching thor 1.1.0
|
130
|
-
|
131
|
-
#10 10.39 Fetching tzinfo 1.2.9
|
132
|
-
|
133
|
-
#10 10.40 Fetching i18n 1.8.10
|
134
|
-
|
135
|
-
#10 10.54 Installing thor 1.1.0
|
136
|
-
|
137
|
-
#10 10.55 Installing i18n 1.8.10
|
138
|
-
|
139
|
-
#10 10.61 Installing tzinfo 1.2.9
|
140
|
-
|
141
|
-
#10 10.77 Fetching nokogiri 1.12.5 (x86_64-linux)
|
142
|
-
|
143
|
-
#10 10.79 Fetching rack-test 1.1.0
|
144
|
-
|
145
|
-
#10 10.84 Fetching sprockets 4.0.2
|
146
|
-
|
147
|
-
#10 10.93 Installing rack-test 1.1.0
|
148
|
-
|
149
|
-
#10 10.95 Fetching websocket-driver 0.7.5
|
150
|
-
|
151
|
-
#10 11.01 Installing sprockets 4.0.2
|
152
|
-
|
153
|
-
#10 11.10 Fetching mail 2.7.1
|
154
|
-
|
155
|
-
#10 11.30 Installing websocket-driver 0.7.5 with native extensions
|
156
|
-
|
157
|
-
#10 11.63 Fetching activesupport 6.0.3
|
158
|
-
|
159
|
-
#10 11.72 Installing nokogiri 1.12.5 (x86_64-linux)
|
160
|
-
|
161
|
-
#10 11.94 Installing mail 2.7.1
|
162
|
-
|
163
|
-
#10 11.95 Installing activesupport 6.0.3
|
164
|
-
|
165
|
-
#10 12.97 Fetching activemodel 6.0.3
|
166
|
-
|
167
|
-
#10 12.97 Fetching globalid 0.5.2
|
168
|
-
|
169
|
-
#10 13.10 Fetching rails-dom-testing 2.0.3
|
170
|
-
|
171
|
-
#10 13.11 Installing globalid 0.5.2
|
172
|
-
|
173
|
-
#10 13.13 Installing activemodel 6.0.3
|
174
|
-
|
175
|
-
#10 13.15 Fetching loofah 2.12.0
|
176
|
-
|
177
|
-
#10 13.19 Fetching mimemagic 0.3.10
|
178
|
-
|
179
|
-
#10 13.24 Installing rails-dom-testing 2.0.3
|
180
|
-
|
181
|
-
#10 13.28 Fetching activejob 6.0.3
|
182
|
-
|
183
|
-
#10 13.31 Installing loofah 2.12.0
|
184
|
-
|
185
|
-
#10 13.32 Installing mimemagic 0.3.10 with native extensions
|
186
|
-
|
187
|
-
#10 13.48 Fetching activerecord 6.0.3
|
188
|
-
|
189
|
-
#10 13.48 Fetching rails-html-sanitizer 1.4.2
|
190
|
-
|
191
|
-
#10 13.60 Installing activejob 6.0.3
|
192
|
-
|
193
|
-
#10 13.71 Installing rails-html-sanitizer 1.4.2
|
194
|
-
|
195
|
-
#10 13.73 Fetching actionview 6.0.3
|
196
|
-
|
197
|
-
#10 13.85 Installing activerecord 6.0.3
|
198
|
-
|
199
|
-
#10 13.94 Installing actionview 6.0.3
|
200
|
-
|
201
|
-
#10 14.28 Fetching actionpack 6.0.3
|
202
|
-
|
203
|
-
#10 14.54 Installing actionpack 6.0.3
|
204
|
-
|
205
|
-
#10 14.66 Fetching actioncable 6.0.3
|
206
|
-
|
207
|
-
#10 14.66 Fetching actionmailer 6.0.3
|
208
|
-
|
209
|
-
#10 14.66 Fetching railties 6.0.3
|
210
|
-
|
211
|
-
#10 14.86 Installing actionmailer 6.0.3
|
212
|
-
|
213
|
-
#10 14.86 Installing actioncable 6.0.3
|
214
|
-
|
215
|
-
#10 14.95 Fetching sprockets-rails 3.2.2
|
216
|
-
|
217
|
-
#10 15.05 Installing railties 6.0.3
|
218
|
-
|
219
|
-
#10 15.09 Installing sprockets-rails 3.2.2
|
220
|
-
|
221
|
-
#10 15.27 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
|
222
|
-
|
223
|
-
#10 15.27
|
224
|
-
|
225
|
-
#10 15.27 current directory: /usr/local/bundle/gems/mimemagic-0.3.10/ext/mimemagic
|
226
|
-
|
227
|
-
#10 15.27 /usr/local/bin/ruby -rrubygems /usr/local/bundle/gems/rake-13.0.6/exe/rake
|
228
|
-
|
229
|
-
#10 15.27 RUBYARCHDIR\=/usr/local/bundle/extensions/x86_64-linux/2.6.0/mimemagic-0.3.10
|
230
|
-
|
231
|
-
#10 15.27 RUBYLIBDIR\=/usr/local/bundle/extensions/x86_64-linux/2.6.0/mimemagic-0.3.10
|
232
|
-
|
233
|
-
#10 15.27 rake aborted!
|
234
|
-
|
235
|
-
#10 15.27 Could not find MIME type database in the following locations:
|
236
|
-
|
237
|
-
#10 15.27 ["/usr/local/share/mime/packages/freedesktop.org.xml",
|
238
|
-
|
239
|
-
#10 15.27 "/opt/homebrew/share/mime/packages/freedesktop.org.xml",
|
240
|
-
|
241
|
-
#10 15.27 "/opt/local/share/mime/packages/freedesktop.org.xml",
|
242
|
-
|
243
|
-
#10 15.27 "/usr/share/mime/packages/freedesktop.org.xml"]
|
244
|
-
|
245
|
-
#10 15.27
|
246
|
-
|
247
|
-
#10 15.27 Ensure you have either installed the shared-mime-info package for your
|
248
|
-
|
249
|
-
#10 15.27 distribution, or
|
250
|
-
|
251
|
-
#10 15.27 obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to
|
252
|
-
|
253
|
-
#10 15.27 the location
|
254
|
-
|
255
|
-
#10 15.27 of that file.
|
256
|
-
|
257
|
-
#10 15.27
|
258
|
-
|
259
|
-
#10 15.27 This gem might be installed as a dependency of some bigger package, such as
|
260
|
-
|
261
|
-
#10 15.27 rails, activestorage,
|
262
|
-
|
263
|
-
#10 15.27 axlsx or cucumber. While most of these packages use the functionality of this
|
264
|
-
|
265
|
-
#10 15.27 gem, some gems have
|
266
|
-
|
267
|
-
#10 15.27 included this gem by accident. Set USE_FREEDESKTOP_PLACEHOLDER=true if you are
|
268
|
-
|
269
|
-
#10 15.27 certain that you
|
270
|
-
|
271
|
-
#10 15.27 do not need this gem, and wish to skip the inclusion of freedesktop.org.xml.
|
272
|
-
|
273
|
-
#10 15.27
|
274
|
-
|
275
|
-
#10 15.27 The FREEDESKTOP_PLACEHOLDER option is meant as a transitional feature, and will
|
276
|
-
|
277
|
-
#10 15.27 be deprecated in
|
278
|
-
|
279
|
-
#10 15.27 the next release.
|
280
|
-
|
281
|
-
#10 15.27 /usr/local/bundle/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:15:in
|
282
|
-
|
283
|
-
#10 15.27 `locate_mime_database'
|
284
|
-
|
285
|
-
#10 15.27 /usr/local/bundle/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:39:in `block in
|
286
|
-
|
287
|
-
#10 15.27 <top (required)>'
|
288
|
-
|
289
|
-
#10 15.27 /usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in `<main>'
|
290
|
-
|
291
|
-
#10 15.27 Tasks: TOP => default
|
292
|
-
|
293
|
-
#10 15.27 (See full trace by running task with --trace)
|
294
|
-
|
295
|
-
#10 15.27
|
296
|
-
|
297
|
-
#10 15.27 rake failed, exit code 1
|
298
|
-
|
299
|
-
#10 15.27
|
300
|
-
|
301
|
-
#10 15.27 Gem files will remain installed in /usr/local/bundle/gems/mimemagic-0.3.10 for
|
302
|
-
|
303
|
-
#10 15.27 inspection.
|
304
|
-
|
305
|
-
#10 15.27 Results logged to
|
306
|
-
|
307
|
-
#10 15.27 /usr/local/bundle/extensions/x86_64-linux/2.6.0/mimemagic-0.3.10/gem_make.out
|
308
|
-
|
309
|
-
#10 15.27
|
310
|
-
|
311
|
-
#10 15.27 An error occurred while installing mimemagic (0.3.10), and Bundler cannot
|
312
|
-
|
313
|
-
#10 15.27 continue.
|
314
|
-
|
315
|
-
#10 15.27 Make sure that `gem install mimemagic -v '0.3.10' --source
|
316
|
-
|
317
|
-
#10 15.27 'https://rubygems.org/'` succeeds before bundling.
|
318
|
-
|
319
|
-
#10 15.27
|
320
|
-
|
321
|
-
#10 15.27 In Gemfile:
|
322
|
-
|
323
|
-
#10 15.27 rails was resolved to 6.0.3, which depends on
|
324
|
-
|
325
|
-
#10 15.27 actionmailbox was resolved to 6.0.3, which depends on
|
326
|
-
|
327
|
-
#10 15.27 activestorage was resolved to 6.0.3, which depends on
|
328
|
-
|
329
341
|
#10 15.27 marcel was resolved to 0.3.3, which depends on
|
330
342
|
|
331
343
|
#10 15.27 mimemagic
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
#やりたい事
|
2
|
+
|
3
|
+
rails newをしたいけど、エラーになるので、解決策が知りたい。
|
4
|
+
|
1
5
|
#使用している環境
|
2
6
|
|
3
7
|
windows10 64bit
|