0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

docker-composeでRails5.2+MySQL開発環境

Posted at

(社内の特殊な環境を移行した際のメモです)

rubyのイメージでうまく環境を構築できなかった(=既存のrails環境のGemfileと一致するバージョンのgemが揃わなかった)ため、Ubuntuのイメージから出発してRailsの環境を構築した際の設定です。

docker-compose.yml
version: '3'
services:
  db:
    image: mysql:5.7
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    volumes:
      - ./tmp/mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=secret
  web:
    build: .
    command: "rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - ./:/railsapp
    ports:
      - "3000:3000"
    depends_on:
      - db
Dockerfile
FROM ubuntu:18.04

RUN apt-get update && apt-get upgrade && apt-get install -y \
  ruby-dev libmysqlclient-dev libmagick++-dev libcurl4-openssl-dev libssl-dev nodejs \
  && gem install rails -v "~> 5.2" -N && gem install bundler -v "~> 1.16"

RUN mkdir /railsapp
WORKDIR /railsapp
COPY ./ /railsapp
RUN bundle install
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?