Skip to content

Instantly share code, notes, and snippets.

@madogiwa0124
Last active February 2, 2019 10:17
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 madogiwa0124/978142b0118e7501fd3bd89b8782a3c9 to your computer and use it in GitHub Desktop.
Save madogiwa0124/978142b0118e7501fd3bd89b8782a3c9 to your computer and use it in GitHub Desktop.
rails + posgresql + node + yarnの環境を作るDocker関連ファイル
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %>
host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %>
username: <%= ENV.fetch('DATABASE_USER') { 'root' } %>
password: <%= ENV.fetch('DATABASE_PASSWORD') { 'password' } %>
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
# DB用のコンテナ
db:
image: postgres
ports:
- "5432" # postgresqlのデフォルトのポートを公開
volumes:
- ./data/postgres:/var/lib/postgresql/data
# Web用のコンテナ
web:
# DockerFileの配置フォルダ
build: .
# localhost:3000とコンテナ:3000を紐付ける
ports:
- "3000:3000"
# dbとwebを関連付け
links:
- db
command: bash
# ローカルのルートディレクトリをコンテナ上の作業ディレクトリと関連付け
volumes:
- ./:/work
tty: true
# 環境変数
environment:
DATABASE_USER: postgres
DATABASE_PASSWORD:
DATABASE_PORT: 5432
DATABASE_HOST: db
# ベースイメージの設定
FROM ruby:2.5.3
# 環境変数の設定
ENV WORK_DIR /work
# コンテナ上で関連パッケージのインストール
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN npm install yarn -g
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client ssh
RUN gem install bundler
RUN gem install rails
# コンテナ上でフォルダを作成
RUN mkdir $WORK_DIR
WORKDIR $WORK_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment