質問編集履歴
6
ソースコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -224,6 +224,102 @@
|
|
224
224
|
|
225
225
|
|
226
226
|
|
227
|
+
nginx/Dockerfile
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
```
|
232
|
+
|
233
|
+
FROM nginx:latest
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
# インクルード用のディレクトリ内を削除
|
238
|
+
|
239
|
+
RUN rm -f /etc/nginx/conf.d/*
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
# Nginxの設定ファイルをコンテナにコピー
|
244
|
+
|
245
|
+
ADD nginx.conf /etc/nginx/hondaapp.conf
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
# ビルド完了後にNginxを起動
|
250
|
+
|
251
|
+
CMD /usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/hondaapp.conf
|
252
|
+
|
253
|
+
```
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
nginx/nginx.conf
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
```
|
262
|
+
|
263
|
+
user root;
|
264
|
+
|
265
|
+
worker_processes 1;
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
events{
|
270
|
+
|
271
|
+
worker_connections 512;
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
# ソケット接続
|
278
|
+
|
279
|
+
http {
|
280
|
+
|
281
|
+
upstream hondaapp{
|
282
|
+
|
283
|
+
server unix:///hondaapp/tmp/sockets/puma.sock;
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
server { # simple load balancing
|
288
|
+
|
289
|
+
listen 80;
|
290
|
+
|
291
|
+
server_name localhost;
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
#ログを記録しようとするとエラーが生じます
|
296
|
+
|
297
|
+
#root /hondaapp/public;
|
298
|
+
|
299
|
+
#access_log logs/access.log;
|
300
|
+
|
301
|
+
#error_log logs/error.log;
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
location / {
|
306
|
+
|
307
|
+
proxy_pass http://hondaapp;
|
308
|
+
|
309
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
310
|
+
|
311
|
+
proxy_set_header Host $http_host;
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
|
227
323
|
#やってみたこと
|
228
324
|
|
229
325
|
|
5
タイトルの修正と該当するコードの修正をしました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
既存のDocker + Railsのアプリにnginxの環境構築をしたいのだが、
|
1
|
+
既存のDocker + Railsのアプリにnginxの環境構築をしたいのだが、imageにnginxが入っていない
|
test
CHANGED
@@ -1,20 +1,8 @@
|
|
1
|
-
herokuにWebアプリケーションをデプロイして、S3を使っていくためにnginxを入れたい
|
1
|
+
herokuにWebアプリケーションをデプロイして、S3を使っていくためにnginxを入れたいです。
|
2
|
-
|
2
|
+
|
3
|
-
|
3
|
+
ですが、DockerのGUIを見てみると、Nginxが入っていないので、おそらくbuildしても入っていないのだと思います。
|
4
|
-
|
5
|
-
|
4
|
+
|
6
|
-
|
7
|
-
#エラー文
|
8
|
-
|
9
|
-
```
|
10
|
-
|
11
|
-
|
5
|
+
前回の質問内容だと入っていルト回答していまいsたが、一度dockerのimageを全部削除しているので、入っていません。
|
12
|
-
|
13
|
-
in "./docker-compose.yml", line 2, column 14
|
14
|
-
|
15
|
-
```
|
16
|
-
|
17
|
-
|
18
6
|
|
19
7
|
#問題のソースコード
|
20
8
|
|
@@ -22,14 +10,6 @@
|
|
22
10
|
|
23
11
|
```
|
24
12
|
|
25
|
-
networks:
|
26
|
-
|
27
|
-
hondaapp-network:
|
28
|
-
|
29
|
-
external: true
|
30
|
-
|
31
|
-
name: hondaapp-network
|
32
|
-
|
33
13
|
services:
|
34
14
|
|
35
15
|
app:
|
@@ -38,7 +18,7 @@
|
|
38
18
|
|
39
19
|
context: /Users/taka/hondaapp
|
40
20
|
|
41
|
-
command: bundle exec puma -C config/puma.rb
|
21
|
+
command: bash -c "rm -f tmp/pids/server.pid && bundle exec puma -C config/puma.rb"
|
42
22
|
|
43
23
|
depends_on:
|
44
24
|
|
@@ -46,70 +26,52 @@
|
|
46
26
|
|
47
27
|
condition: service_started
|
48
28
|
|
49
|
-
networks:
|
50
|
-
|
51
|
-
hondaapp-network: null
|
52
|
-
|
53
29
|
volumes:
|
54
30
|
|
55
|
-
- /Users/taka/hondaapp:/
|
31
|
+
- /Users/taka/hondaapp:/mysql:rw
|
32
|
+
|
33
|
+
- public-data:/mysql/public:rw
|
34
|
+
|
35
|
+
- tmp-data:/mysql/tmp:rw
|
36
|
+
|
37
|
+
- log-data:/mysql/log:rw
|
38
|
+
|
39
|
+
db:
|
40
|
+
|
41
|
+
environment:
|
42
|
+
|
43
|
+
MYSQL_PASSWORD: password
|
44
|
+
|
45
|
+
image: mysql:5.7
|
46
|
+
|
47
|
+
volumes:
|
48
|
+
|
49
|
+
- /Users/taka/hondaapp/tmp/db:/var/lib/mysql/data:rw
|
50
|
+
|
51
|
+
web:
|
52
|
+
|
53
|
+
build:
|
54
|
+
|
55
|
+
context: /Users/taka/hondaapp/nginx
|
56
|
+
|
57
|
+
depends_on:
|
58
|
+
|
59
|
+
app:
|
60
|
+
|
61
|
+
condition: service_started
|
62
|
+
|
63
|
+
ports:
|
64
|
+
|
65
|
+
- published: 80
|
66
|
+
|
67
|
+
target: 80
|
68
|
+
|
69
|
+
volumes:
|
56
70
|
|
57
71
|
- public-data:/hondaapp/public:rw
|
58
72
|
|
59
73
|
- tmp-data:/hondaapp/tmp:rw
|
60
74
|
|
61
|
-
- log-data:/hondaapp/log:rw
|
62
|
-
|
63
|
-
db:
|
64
|
-
|
65
|
-
environment:
|
66
|
-
|
67
|
-
MYSQL_DATABASE: hondaapp_development
|
68
|
-
|
69
|
-
MYSQL_PASSWORD: password
|
70
|
-
|
71
|
-
MYSQL_ROOT_PASSWORD: password
|
72
|
-
|
73
|
-
MYSQL_USER: user
|
74
|
-
|
75
|
-
image: mysql:5.7
|
76
|
-
|
77
|
-
networks:
|
78
|
-
|
79
|
-
hondaapp-network: null
|
80
|
-
|
81
|
-
volumes:
|
82
|
-
|
83
|
-
- db-data:/var/lib/mysql:rw
|
84
|
-
|
85
|
-
web:
|
86
|
-
|
87
|
-
build:
|
88
|
-
|
89
|
-
context: /Users/taka/hondaapp/nginx_docker
|
90
|
-
|
91
|
-
depends_on:
|
92
|
-
|
93
|
-
app:
|
94
|
-
|
95
|
-
condition: service_started
|
96
|
-
|
97
|
-
networks:
|
98
|
-
|
99
|
-
hondaapp-network: null
|
100
|
-
|
101
|
-
ports:
|
102
|
-
|
103
|
-
- published: 80
|
104
|
-
|
105
|
-
target: 80
|
106
|
-
|
107
|
-
volumes:
|
108
|
-
|
109
|
-
- public-data:/hondaapp/public:rw
|
110
|
-
|
111
|
-
- tmp-data:/hondaapp/tmp:rw
|
112
|
-
|
113
75
|
version: '3'
|
114
76
|
|
115
77
|
volumes:
|
@@ -222,49 +184,43 @@
|
|
222
184
|
|
223
185
|
RUN apt-get update -qq && \
|
224
186
|
|
225
|
-
apt-get install -y build-essential \
|
187
|
+
apt-get install -y build-essential \
|
188
|
+
|
226
|
-
|
189
|
+
libpq-dev \
|
190
|
+
|
191
|
+
yarn \
|
192
|
+
|
227
|
-
nodejs
|
193
|
+
nodejs
|
228
|
-
|
194
|
+
|
195
|
+
|
196
|
+
|
229
|
-
|
197
|
+
# 作業ディレクトリの作成、設定
|
230
|
-
|
231
|
-
|
198
|
+
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
199
|
+
RUN mkdir /app_name
|
200
|
+
|
240
|
-
|
201
|
+
##作業ディレクトリ名をAPP_ROOTに割り当てて、以下$APP_ROOTで参照
|
202
|
+
|
241
|
-
|
203
|
+
ENV APP_ROOT /app_name
|
204
|
+
|
242
|
-
|
205
|
+
WORKDIR $APP_ROOT
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
# ホスト側(ローカル)のGemfileを追加する(ローカルのGemfileは【3】で作成)
|
210
|
+
|
243
|
-
|
211
|
+
ADD ./Gemfile $APP_ROOT/Gemfile
|
244
|
-
|
212
|
+
|
245
|
-
|
213
|
+
ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
|
246
|
-
|
247
|
-
|
248
|
-
|
214
|
+
|
215
|
+
|
216
|
+
|
249
|
-
|
217
|
+
# Gemfileのbundle install
|
250
218
|
|
251
219
|
RUN bundle install
|
252
220
|
|
253
|
-
|
254
|
-
|
255
|
-
|
221
|
+
ADD . $APP_ROOT
|
256
|
-
|
257
|
-
|
258
|
-
|
222
|
+
|
259
|
-
```
|
223
|
+
```
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
Dockerのイメージの中にはnginxはlatestで入っています。そして、RUNと表示されています。
|
264
|
-
|
265
|
-
参考にしたサイト
|
266
|
-
|
267
|
-
[既存のRailsアプリにNginxを導入しよう!(Docker, docker-compose)](https://laptrinhx.com/ji-cunnorailsapurininginxwo-dao-rushiyou-docker-docker-compose-4072638532/)
|
268
224
|
|
269
225
|
|
270
226
|
|
@@ -272,76 +228,4 @@
|
|
272
228
|
|
273
229
|
|
274
230
|
|
275
|
-
`docker-compose config`を
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
```
|
280
|
-
|
281
|
-
db uses an image, skipping
|
282
|
-
|
283
|
-
Building app
|
284
|
-
|
285
|
-
[+] Building 6.4s (7/13)
|
286
|
-
|
287
|
-
=> [internal] load build definition from Dockerfile 0.0s
|
288
|
-
|
289
|
-
=> => transferring dockerfile: 343B 0.0s
|
290
|
-
|
291
|
-
=> [internal] load .dockerignore 0.0s
|
292
|
-
|
293
|
-
=> => transferring context: 2B 0.0s
|
294
|
-
|
295
|
-
=> [internal] load metadata for docker.io/library/ruby:2.6.5 1.8s
|
296
|
-
|
297
|
-
=> [auth] library/ruby:pull token for registry-1.docker.io 0.0s
|
298
|
-
|
299
|
-
=> [internal] load build context 0.0s
|
300
|
-
|
301
|
-
=> => transferring context: 61B 0.0s
|
302
|
-
|
303
|
-
=> CACHED [1/8] FROM docker.io/library/ruby:2.6.5@sha256:651078e89471c30567685dce4caa321adf1f846b353e05c327b55d76a84acc50 0.0s
|
304
|
-
|
305
|
-
=> ERROR [2/8] RUN apt-get update -qq && apt-get install -y build-essential nodejs mysql-server mysql-client 4.5s
|
306
|
-
|
307
|
-
------
|
308
|
-
|
309
|
-
> [2/8] RUN apt-get update -qq && apt-get install -y build-essential nodejs mysql-server mysql-client:
|
310
|
-
|
311
|
-
#5 3.207 Reading package lists...
|
312
|
-
|
313
|
-
#5 4.051 Building dependency tree...
|
314
|
-
|
315
|
-
#5 4.240 Reading state information...
|
316
|
-
|
317
|
-
#5 4.277 Package mysql-client is not available, but is referred to by another package.
|
318
|
-
|
319
|
-
#5 4.277 This may mean that the package is missing, has been obsoleted, or
|
320
|
-
|
321
|
-
#5 4.277 is only available from another source
|
322
|
-
|
323
|
-
#5 4.277
|
324
|
-
|
325
|
-
#5 4.277 Package mysql-server is not available, but is referred to by another package.
|
326
|
-
|
327
|
-
#5 4.277 This may mean that the package is missing, has been obsoleted, or
|
328
|
-
|
329
|
-
#5 4.277 is only available from another source
|
330
|
-
|
331
|
-
#5 4.277
|
332
|
-
|
333
|
-
#5 4.384 E: Package 'mysql-server' has no installation candidate
|
334
|
-
|
335
|
-
#5 4.384 E: Package 'mysql-client' has no installation candidate
|
336
|
-
|
337
|
-
------
|
338
|
-
|
339
|
-
executor failed running [/bin/sh -c apt-get update -qq && apt-get install -y build-essential nodejs mysql-server mysql-client]: exit code: 100
|
340
|
-
|
341
|
-
ERROR: Service 'app' failed to build
|
342
|
-
|
343
|
-
```
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
となってしまいました。エラー分は変わったのですが、どうしてビルドできないのかわからないです。
|
231
|
+
一度`docker-compose config`をしてみて、出てきたソースコードを貼り付けてみたのですが、
|
4
何をしたいのかを修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
herokuにWebアプリケーションをデプロイして、S3を使っていくためにnginxを入れたいのですが、
|
2
2
|
|
3
3
|
`docker-compose build`をしようとすると以下のようなエラーになってしまいます
|
4
4
|
|
3
タイトルを修正しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
既存のDocker + Railsのアプリにnginxの環境構築をしたいのだが、yaml.scanner.ScannerError: mapping values areになってしまう。
|
1
|
+
既存のDocker + Railsのアプリにnginxの環境構築をしたいのだが、ERROR: yaml.scanner.ScannerError: mapping values areになってしまう。
|
test
CHANGED
File without changes
|
2
やってみたことの追記とコードの修正をしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,93 +22,105 @@
|
|
22
22
|
|
23
23
|
```
|
24
24
|
|
25
|
+
networks:
|
26
|
+
|
27
|
+
hondaapp-network:
|
28
|
+
|
29
|
+
external: true
|
30
|
+
|
31
|
+
name: hondaapp-network
|
32
|
+
|
33
|
+
services:
|
34
|
+
|
35
|
+
app:
|
36
|
+
|
37
|
+
build:
|
38
|
+
|
39
|
+
context: /Users/taka/hondaapp
|
40
|
+
|
41
|
+
command: bundle exec puma -C config/puma.rb
|
42
|
+
|
43
|
+
depends_on:
|
44
|
+
|
45
|
+
db:
|
46
|
+
|
47
|
+
condition: service_started
|
48
|
+
|
49
|
+
networks:
|
50
|
+
|
51
|
+
hondaapp-network: null
|
52
|
+
|
53
|
+
volumes:
|
54
|
+
|
55
|
+
- /Users/taka/hondaapp:/hondaapp:rw
|
56
|
+
|
57
|
+
- public-data:/hondaapp/public:rw
|
58
|
+
|
59
|
+
- tmp-data:/hondaapp/tmp:rw
|
60
|
+
|
61
|
+
- log-data:/hondaapp/log:rw
|
62
|
+
|
63
|
+
db:
|
64
|
+
|
65
|
+
environment:
|
66
|
+
|
67
|
+
MYSQL_DATABASE: hondaapp_development
|
68
|
+
|
69
|
+
MYSQL_PASSWORD: password
|
70
|
+
|
71
|
+
MYSQL_ROOT_PASSWORD: password
|
72
|
+
|
73
|
+
MYSQL_USER: user
|
74
|
+
|
75
|
+
image: mysql:5.7
|
76
|
+
|
77
|
+
networks:
|
78
|
+
|
79
|
+
hondaapp-network: null
|
80
|
+
|
81
|
+
volumes:
|
82
|
+
|
83
|
+
- db-data:/var/lib/mysql:rw
|
84
|
+
|
85
|
+
web:
|
86
|
+
|
87
|
+
build:
|
88
|
+
|
89
|
+
context: /Users/taka/hondaapp/nginx_docker
|
90
|
+
|
91
|
+
depends_on:
|
92
|
+
|
93
|
+
app:
|
94
|
+
|
95
|
+
condition: service_started
|
96
|
+
|
97
|
+
networks:
|
98
|
+
|
99
|
+
hondaapp-network: null
|
100
|
+
|
101
|
+
ports:
|
102
|
+
|
103
|
+
- published: 80
|
104
|
+
|
105
|
+
target: 80
|
106
|
+
|
107
|
+
volumes:
|
108
|
+
|
109
|
+
- public-data:/hondaapp/public:rw
|
110
|
+
|
111
|
+
- tmp-data:/hondaapp/tmp:rw
|
112
|
+
|
25
113
|
version: '3'
|
26
114
|
|
27
|
-
services: app:
|
28
|
-
|
29
|
-
build: .
|
30
|
-
|
31
|
-
|
115
|
+
volumes:
|
32
|
-
|
33
|
-
|
116
|
+
|
34
|
-
|
35
|
-
- tmp-data:/rails_test/tmp
|
36
|
-
|
37
|
-
- public-data:/rails_test/public
|
38
|
-
|
39
|
-
command: puma -C config/puma.rb
|
40
|
-
|
41
|
-
environment:
|
42
|
-
|
43
|
-
WEBPACKER_DEV_SERVER_HOST: webpacker
|
44
|
-
|
45
|
-
env_file:
|
46
|
-
|
47
|
-
- ./environments/db.env
|
48
|
-
|
49
|
-
depends_on:
|
50
|
-
|
51
|
-
- db
|
52
|
-
|
53
|
-
webpacker:
|
54
|
-
|
55
|
-
|
117
|
+
db-data: {}
|
56
|
-
|
57
|
-
|
118
|
+
|
58
|
-
|
59
|
-
NODE_ENV: development
|
60
|
-
|
61
|
-
RAILS_ENV: development
|
62
|
-
|
63
|
-
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
|
64
|
-
|
65
|
-
volumes:
|
66
|
-
|
67
|
-
- .:/rails_test
|
68
|
-
|
69
|
-
command: ./bin/webpack-dev-server
|
70
|
-
|
71
|
-
ports:
|
72
|
-
|
73
|
-
- 3035:3035
|
74
|
-
|
75
|
-
web:
|
76
|
-
|
77
|
-
build:
|
78
|
-
|
79
|
-
context: containers/nginx
|
80
|
-
|
81
|
-
volumes:
|
82
|
-
|
83
|
-
- public-data:/rails_test/public
|
84
|
-
|
85
|
-
- tmp-data:/rails_test/tmp
|
86
|
-
|
87
|
-
ports:
|
88
|
-
|
89
|
-
- 80:80
|
90
|
-
|
91
|
-
depends_on:
|
92
|
-
|
93
|
-
- app
|
94
|
-
|
95
|
-
db:
|
96
|
-
|
97
|
-
image: mysql:5.7
|
98
|
-
|
99
|
-
volumes:
|
100
|
-
|
101
|
-
- rails-db:/var/lib/mysql
|
102
|
-
|
103
|
-
env_file:
|
104
|
-
|
105
|
-
- ./environments/db.env
|
106
|
-
|
107
|
-
volumes: rails-db:
|
108
|
-
|
109
|
-
|
119
|
+
log-data: {}
|
110
|
-
|
120
|
+
|
111
|
-
public-data:
|
121
|
+
public-data: {}
|
122
|
+
|
123
|
+
tmp-data: {}
|
112
124
|
|
113
125
|
```
|
114
126
|
|
@@ -206,64 +218,40 @@
|
|
206
218
|
|
207
219
|
FROM ruby:2.6.5
|
208
220
|
|
221
|
+
|
222
|
+
|
209
223
|
RUN apt-get update -qq && \
|
210
224
|
|
211
|
-
|
225
|
+
apt-get install -y build-essential \
|
212
|
-
|
226
|
+
|
213
|
-
|
227
|
+
nodejs\
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
228
|
+
|
218
|
-
|
219
|
-
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
|
220
|
-
|
221
|
-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
222
|
-
|
223
|
-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
224
|
-
|
225
|
-
apt-get update && apt-get install -y yarn
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
229
|
+
mysql-server\
|
230
|
-
|
231
|
-
|
230
|
+
|
232
|
-
|
233
|
-
|
231
|
+
mysql-client
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
232
|
+
|
238
|
-
|
239
|
-
|
233
|
+
|
240
|
-
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
241
|
-
WORKDIR /
|
239
|
+
WORKDIR /hondaapp
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
240
|
+
|
246
|
-
|
241
|
+
|
242
|
+
|
247
|
-
|
243
|
+
COPY Gemfile /hondaapp/Gemfile
|
248
|
-
|
244
|
+
|
249
|
-
|
245
|
+
COPY Gemfile.lock /hondaapp/Gemfile.lock
|
250
|
-
|
251
|
-
|
252
|
-
|
246
|
+
|
247
|
+
|
248
|
+
|
253
|
-
|
249
|
+
RUN gem install bundler
|
254
250
|
|
255
251
|
RUN bundle install
|
256
252
|
|
257
253
|
|
258
254
|
|
259
|
-
# ホストのアプリケーションディレクトリ内をすべてコンテナにコピー
|
260
|
-
|
261
|
-
ADD . /webapp
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
# puma.sockを配置するディレクトリを作成
|
266
|
-
|
267
255
|
RUN mkdir -p tmp/sockets
|
268
256
|
|
269
257
|
|
@@ -277,3 +265,83 @@
|
|
277
265
|
参考にしたサイト
|
278
266
|
|
279
267
|
[既存のRailsアプリにNginxを導入しよう!(Docker, docker-compose)](https://laptrinhx.com/ji-cunnorailsapurininginxwo-dao-rushiyou-docker-docker-compose-4072638532/)
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
#やってみたこと
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
`docker-compose config`を実行してみた結果、
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
db uses an image, skipping
|
282
|
+
|
283
|
+
Building app
|
284
|
+
|
285
|
+
[+] Building 6.4s (7/13)
|
286
|
+
|
287
|
+
=> [internal] load build definition from Dockerfile 0.0s
|
288
|
+
|
289
|
+
=> => transferring dockerfile: 343B 0.0s
|
290
|
+
|
291
|
+
=> [internal] load .dockerignore 0.0s
|
292
|
+
|
293
|
+
=> => transferring context: 2B 0.0s
|
294
|
+
|
295
|
+
=> [internal] load metadata for docker.io/library/ruby:2.6.5 1.8s
|
296
|
+
|
297
|
+
=> [auth] library/ruby:pull token for registry-1.docker.io 0.0s
|
298
|
+
|
299
|
+
=> [internal] load build context 0.0s
|
300
|
+
|
301
|
+
=> => transferring context: 61B 0.0s
|
302
|
+
|
303
|
+
=> CACHED [1/8] FROM docker.io/library/ruby:2.6.5@sha256:651078e89471c30567685dce4caa321adf1f846b353e05c327b55d76a84acc50 0.0s
|
304
|
+
|
305
|
+
=> ERROR [2/8] RUN apt-get update -qq && apt-get install -y build-essential nodejs mysql-server mysql-client 4.5s
|
306
|
+
|
307
|
+
------
|
308
|
+
|
309
|
+
> [2/8] RUN apt-get update -qq && apt-get install -y build-essential nodejs mysql-server mysql-client:
|
310
|
+
|
311
|
+
#5 3.207 Reading package lists...
|
312
|
+
|
313
|
+
#5 4.051 Building dependency tree...
|
314
|
+
|
315
|
+
#5 4.240 Reading state information...
|
316
|
+
|
317
|
+
#5 4.277 Package mysql-client is not available, but is referred to by another package.
|
318
|
+
|
319
|
+
#5 4.277 This may mean that the package is missing, has been obsoleted, or
|
320
|
+
|
321
|
+
#5 4.277 is only available from another source
|
322
|
+
|
323
|
+
#5 4.277
|
324
|
+
|
325
|
+
#5 4.277 Package mysql-server is not available, but is referred to by another package.
|
326
|
+
|
327
|
+
#5 4.277 This may mean that the package is missing, has been obsoleted, or
|
328
|
+
|
329
|
+
#5 4.277 is only available from another source
|
330
|
+
|
331
|
+
#5 4.277
|
332
|
+
|
333
|
+
#5 4.384 E: Package 'mysql-server' has no installation candidate
|
334
|
+
|
335
|
+
#5 4.384 E: Package 'mysql-client' has no installation candidate
|
336
|
+
|
337
|
+
------
|
338
|
+
|
339
|
+
executor failed running [/bin/sh -c apt-get update -qq && apt-get install -y build-essential nodejs mysql-server mysql-client]: exit code: 100
|
340
|
+
|
341
|
+
ERROR: Service 'app' failed to build
|
342
|
+
|
343
|
+
```
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
となってしまいました。エラー分は変わったのですが、どうしてビルドできないのかわからないです。
|
1
ソースコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
`docker-compose build`をしようとすると以下のようなエラーになってしまいます
|
4
4
|
|
5
|
-
|
5
|
+
そして、mysqlの環境で動かしたいと考えています。
|
6
6
|
|
7
7
|
#エラー文
|
8
8
|
|
@@ -114,6 +114,166 @@
|
|
114
114
|
|
115
115
|
|
116
116
|
|
117
|
+
nginx_docker/Dockerfile
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
FROM nginx:latest
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
RUN rm -f /etc/nginx/conf.d/*
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
ADD nginx.conf /etc/nginx/conf.d/fitO2.conf
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
CMD /usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
ngix_docker/ngix.conf
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
upstream rails_test {
|
148
|
+
|
149
|
+
server unix:///rails_test/tmp/sockets/puma.sock;
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
server {
|
156
|
+
|
157
|
+
listen 80;
|
158
|
+
|
159
|
+
server_name localhost;
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
access_log /var/log/nginx/access.log main;
|
164
|
+
|
165
|
+
error_log /var/log/nginx/error.log debug;
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
root /rails_test/public;
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
client_max_body_size 100m;
|
174
|
+
|
175
|
+
error_page 404 /404.html;
|
176
|
+
|
177
|
+
error_page 505 502 503 504 /500.html;
|
178
|
+
|
179
|
+
try_files $uri/index.html $uri @rails_test;
|
180
|
+
|
181
|
+
keepalive_timeout 5;
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
location @rails_test {
|
186
|
+
|
187
|
+
proxy_set_header X-Real-IP $remote_addr;
|
188
|
+
|
189
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
190
|
+
|
191
|
+
proxy_set_header Host $http_host;
|
192
|
+
|
193
|
+
proxy_pass http://rails_test;
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
Dockerfile
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
FROM ruby:2.6.5
|
208
|
+
|
209
|
+
RUN apt-get update -qq && \
|
210
|
+
|
211
|
+
apt-get install -y build-essential \
|
212
|
+
|
213
|
+
nodejs
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
# yarnパッケージ管理ツールインストール
|
218
|
+
|
219
|
+
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
|
220
|
+
|
221
|
+
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
222
|
+
|
223
|
+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
224
|
+
|
225
|
+
apt-get update && apt-get install -y yarn
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
# Node.jsをインストール
|
230
|
+
|
231
|
+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
|
232
|
+
|
233
|
+
apt-get install -y nodejs
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
# ルート直下にwebappという名前で作業ディレクトリを作成(コンテナ内のアプリケーションディレクトリ)
|
238
|
+
|
239
|
+
RUN mkdir /webapp
|
240
|
+
|
241
|
+
WORKDIR /webapp
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
# ホストのGemfileとGemfile.lockをコンテナにコピー
|
246
|
+
|
247
|
+
ADD Gemfile /webapp/Gemfile
|
248
|
+
|
249
|
+
ADD Gemfile.lock /webapp/Gemfile.lock
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
# bundle installの実行
|
254
|
+
|
255
|
+
RUN bundle install
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
# ホストのアプリケーションディレクトリ内をすべてコンテナにコピー
|
260
|
+
|
261
|
+
ADD . /webapp
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
# puma.sockを配置するディレクトリを作成
|
266
|
+
|
267
|
+
RUN mkdir -p tmp/sockets
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
Dockerのイメージの中にはnginxはlatestで入っています。そして、RUNと表示されています。
|
276
|
+
|
117
277
|
参考にしたサイト
|
118
278
|
|
119
279
|
[既存のRailsアプリにNginxを導入しよう!(Docker, docker-compose)](https://laptrinhx.com/ji-cunnorailsapurininginxwo-dao-rushiyou-docker-docker-compose-4072638532/)
|