Last active
February 2, 2019 10:17
-
-
Save madogiwa0124/978142b0118e7501fd3bd89b8782a3c9 to your computer and use it in GitHub Desktop.
rails + posgresql + node + yarnの環境を作るDocker関連ファイル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ベースイメージの設定 | |
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