質問編集履歴

2

修正

2020/09/10 00:05

投稿

tomsuma
tomsuma

スコア38

test CHANGED
File without changes
test CHANGED
@@ -260,7 +260,7 @@
260
260
 
261
261
 
262
262
 
263
- ```docker-compose.yml
263
+ ```dockercompose
264
264
 
265
265
  version: '3'
266
266
 
@@ -368,4 +368,68 @@
368
368
 
369
369
 
370
370
 
371
+ ```database
372
+
373
+
374
+
375
+
376
+
377
+ default: &default
378
+
379
+ adapter: mysql2
380
+
381
+ encoding: utf8
382
+
383
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
384
+
385
+ username: root
386
+
387
+ password: example
388
+
389
+ # socket: /tmp/mysql.sock
390
+
391
+
392
+
393
+ host: db
394
+
395
+
396
+
397
+ development:
398
+
399
+ <<: *default
400
+
401
+ database: Books_development
402
+
403
+
404
+
405
+ test:
406
+
407
+ <<: *default
408
+
409
+ database: Books_test
410
+
411
+
412
+
413
+ production:
414
+
415
+ <<: *default
416
+
417
+ database: Books_production
418
+
419
+
420
+
421
+ username: root
422
+
423
+ password: <%= ENV['DATABASE_PASSWORD'] %>
424
+
425
+ socket: /var/lib/mysql/mysql.sock
426
+
427
+
428
+
429
+ ```
430
+
431
+
432
+
433
+
434
+
371
435
  どこか怪しい所があればご指摘お願いします。。

1

修正

2020/09/10 00:05

投稿

tomsuma
tomsuma

スコア38

test CHANGED
File without changes
test CHANGED
@@ -260,4 +260,112 @@
260
260
 
261
261
 
262
262
 
263
+ ```docker-compose.yml
264
+
265
+ version: '3'
266
+
267
+ services:
268
+
269
+ db:
270
+
271
+ image: mysql:5.6 #既存アプリとあわせる。ターミナルに「mysqladmin version」で確認
272
+
273
+ environment:
274
+
275
+ MYSQL_ROOT_PASSWORD: example
276
+
277
+ MYSQL_DATABASE: root
278
+
279
+ ports:
280
+
281
+ - "4306:3306" #Sequel ProでDBを確認する為、4306としておく
282
+
283
+ volumes:
284
+
285
+ - mysql-data:/var/lib/mysql
286
+
287
+ web:
288
+
289
+ build: .
290
+
291
+ command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
292
+
293
+ volumes:
294
+
295
+ - .:/Books
296
+
297
+ ports:
298
+
299
+ - 3000:3000
300
+
301
+ depends_on:
302
+
303
+ - db
304
+
305
+ tty: true
306
+
307
+ stdin_open: true
308
+
309
+ volumes:
310
+
311
+ mysql-data:
312
+
313
+ ```
314
+
315
+ ```dockerfile
316
+
317
+
318
+
319
+ FROM ruby:2.6
320
+
321
+
322
+
323
+ # APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
324
+
325
+
326
+
327
+ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
328
+
329
+ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
330
+
331
+
332
+
333
+ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs yarn
334
+
335
+
336
+
337
+ WORKDIR /Books/
338
+
339
+ COPY Gemfile ./Gemfile
340
+
341
+ COPY Gemfile.lock ./Gemfile.lock
342
+
343
+ RUN gem install bundler
344
+
345
+ RUN bundle install
346
+
347
+ COPY . /Books/
348
+
349
+
350
+
351
+ # Add a script to be executed every time the container starts.
352
+
353
+ COPY entrypoint.sh /usr/bin/
354
+
355
+ RUN chmod +x /usr/bin/entrypoint.sh
356
+
357
+ ENTRYPOINT ["entrypoint.sh"]
358
+
359
+ EXPOSE 3000
360
+
361
+
362
+
363
+ # Start the main process.
364
+
365
+ CMD ["rails", "server", "-b", "0.0.0.0"]
366
+
367
+ ```
368
+
369
+
370
+
263
371
  どこか怪しい所があればご指摘お願いします。。