Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbwl/96c92561bb35edcc11a94c41e8cb8754 to your computer and use it in GitHub Desktop.
Save jbwl/96c92561bb35edcc11a94c41e8cb8754 to your computer and use it in GitHub Desktop.
how to introduced mutagen in rails
  • mutagen をインストールする
$ brew install mutagen-io/mutagen/mutagen
  • mutagen.yml をプロジェクトルートへ作成する
sync:
  # 任意の名前でOK
  rails_development:
    alpha: "."
    beta: "docker://your-product-name-mutagen-vol-container/data"
    ignore:
      vcs: true
      # この辺はお好みで
      paths:
        - "ignore/sync/path"
  • docker-compose.override.yml に以下を記載する
version: '3'
services:
  rails:
    # 既存のrailsのコンテナをmutagenのコンテナのデータ領域で丸ごとマウントする
    volumes:
      - mutagen_vol:/your-rails-directory
    depends_on:
      - mutagen-vol
  mutagen-vol:
    image: alpine:latest
    command: tail -f /dev/null
    # docker-compose upや run で複数インスタンス立ち上がらないように固定のコンテナ名にする
    container_name: your-product-name-mutagen-vol-container
    volumes:
      - mutagen_vol:/data:nocopy

volumes:
  mutagen_vol:
    driver: local
  • 一度起動中のコンテナを停止する
$ docker-compose down

$ mutagen daemon start

// 初回はローカルとフル同期をする必要があり少し時間がかかるのでmutagen用のボリュームコンテナだけ立ち上げ
$ docker-compose up -d mutagen-vol
$ mutagen project start

$ mutagen monitor
--------------------------------------
// こんな画面が出てくる 
Name: rails_development
Identifier: xxxxxxxxxxxxxxxxxxxxx
Labels:
        io.mutagen.project: xxxxxxxxxxxxxxxxxxxxx
Alpha: /your/local_machine/rails/path
Beta: docker://your-product-name-mutagen-vol-container/data
        DOCKER_HOST=
        DOCKER_TLS_VERIFY=
        DOCKER_CERT_PATH=
Status: Watching for changes  <---- この表示がでれば同期OK Ctrl+Cで抜ける
--------------------------------------

// データ用のコンテナの同期が完了したら残りのコンテナを立ち上げ
$ docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment