質問編集履歴

2

ディレクトリ配置のdocker-compose.yml、Dockerfileの内容の追加

2021/07/17 01:23

投稿

otyaotya
otyaotya

スコア1

test CHANGED
File without changes
test CHANGED
@@ -322,7 +322,7 @@
322
322
 
323
323
  MYSQL_ROOT_PASSWORD: 'password'
324
324
 
325
- MYSQL_USER: sayaka
325
+ MYSQL_USER: hoge
326
326
 
327
327
  MYSQL_PASSWORD: 'password'
328
328
 
@@ -380,7 +380,7 @@
380
380
 
381
381
  <<: *default
382
382
 
383
- username: sayaka
383
+ username: hoge
384
384
 
385
385
  password: password
386
386
 

1

ディレクトリ配置のdocker-compose.yml、Dockerfileの内容の追加

2021/07/17 01:23

投稿

otyaotya
otyaotya

スコア1

test CHANGED
File without changes
test CHANGED
@@ -282,6 +282,124 @@
282
282
 
283
283
 
284
284
 
285
+ ```Dockerfile
286
+
287
+ FROM ruby:2.6.6
288
+
289
+ RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*
290
+
291
+ RUN apt-get update && apt-get install -y default-mysql-client --no-install-recommends && rm -rf /var/lib/apt/lists/*
292
+
293
+ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
294
+
295
+ RUN mkdir /workdir
296
+
297
+ WORKDIR /workdir
298
+
299
+ ADD Gemfile /workdir/Gemfile
300
+
301
+ ADD Gemfile.lock /workdir/Gemfile.lock
302
+
303
+ RUN bundle install
304
+
305
+ ADD . /workdir
306
+
307
+ ```
308
+
309
+ ```docker-compose.yml
310
+
311
+ version: '3'
312
+
313
+ services:
314
+
315
+ db:
316
+
317
+ image: mysql:5.7
318
+
319
+ environment:
320
+
321
+ MYSQL_DATABASE: docker_development
322
+
323
+ MYSQL_ROOT_PASSWORD: 'password'
324
+
325
+ MYSQL_USER: sayaka
326
+
327
+ MYSQL_PASSWORD: 'password'
328
+
329
+ ports:
330
+
331
+ - "4306:3306"
332
+
333
+ web:
334
+
335
+ build:
336
+
337
+ context: .
338
+
339
+ dockerfile: Dockerfile
340
+
341
+ command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'
342
+
343
+ tty: true
344
+
345
+ stdin_open: true
346
+
347
+ depends_on:
348
+
349
+ - db
350
+
351
+ ports:
352
+
353
+ - "3000:3000"
354
+
355
+ volumes:
356
+
357
+ - .:/workdir
358
+
359
+ ```
360
+
361
+
362
+
363
+ ```database.yml
364
+
365
+
366
+
367
+ default: &default
368
+
369
+ adapter: mysql2
370
+
371
+ encoding: utf8
372
+
373
+ pool: 5
374
+
375
+ host: db
376
+
377
+
378
+
379
+ development:
380
+
381
+ <<: *default
382
+
383
+ username: sayaka
384
+
385
+ password: password
386
+
387
+ database: docker_development
388
+
389
+
390
+
391
+ production:
392
+
393
+ <<: *default
394
+
395
+ database: docker_production
396
+
397
+ username: docker
398
+
399
+ password: <%= ENV['DOCKER_DATABASE_PASSWORD'] %>
400
+
401
+ ```
402
+
285
403
 
286
404
 
287
405
  なお、私の環境は以下の通りです。