Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/dockerizeの修正 #340

Merged
merged 6 commits into from
May 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
DATABASE_USER=root
DATABASE_PASSWORD=
DATABASE_HOST=localhost
DATABASE_SOCKET=/tmp/mysql.sock

EC2_PRODUCTION_HOST=52.199.95.54
EC2_PRODUCTION_PROTOCOL=http

Expand Down
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,54 @@
[![Test Coverage](https://api.codeclimate.com/v1/badges/cef3c1298621fa26dd1c/test_coverage)](https://codeclimate.com/github/kure-kosen/cho_kure_web/test_coverage)

## Ruby version
```

```bash
% ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
```

## Setup

以下を実行すればセットアップは完了するはず。
mysqlに接続できなければ `.env` を編集して自分の環境に合わせてください。

```bash
% git clone [email protected]:kure-kosen/cho_kure_web.git
% cd cho_kure_web
% bin/setup
```
git clone [email protected]:kure-kosen/cho_kure_web.git
cd cho_kure_web
bin/setup

## Setup with Docker

### Common

```bash
% git clone [email protected]:kure-kosen/cho_kure_web.git
% cd cho_kure_web
```

### Backend

```bash
... installed docker-compose
% docker-compose build
% docker-compose up
% docker-compose run backend bin/rails db:create db:schema:load db:seed_fu
```

### Frontend

```bash
% cd ./frontend
% yarn install

# Commands
% yarn start # Start webpack-dev-server
% yarn build # Build to dist/
% yarn lint # Check type and syntax, auto fix
```

## その他

* 開発中にアプリケーションが送信したメールは `/letter_opener` で確認できます。
* `bundle exec rubocop` でコードの静的チェックが走ります。指摘箇所を修正してPRを出してください。
27 changes: 2 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
image: mysql:5.7.25
environment:
MYSQL_DATABASE: cho_kure_web_development
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: root
MYSQL_PASSWORD: root
MYSQL_PORT: 3306
Expand All @@ -15,38 +14,16 @@ services:
build:
context: .
dockerfile: ./docker/backend/Dockerfile.dev
command: rails s -p 3000 -b '0.0.0.0'
command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- ./:/code
ports:
- "3000:3000"
links:
- "db"
env_file: .env
environment:
DATABASE_PASSWORD: root
DATABASE_USER: root
DATABASE_HOST: db
# DATABASE_PASSWORD: homepage
# DATABASE_USER: homepage
# DATABASE_HOST: db
DATABASE_SOCKET: /tmp/mysql.sock
EC2_PRODUCTION_HOST: 52.199.95.54
EC2_PRODUCTION_PROTOCOL: http
# frontend:
# build:
# context: .
# dockerfile: ./docker/frontend/Dockerfile.local
# command: echo "frontend command"
# volumes:
# - ./:/code
# ports:
# - "3000:3000"
# links:
# - "db"
# environment:
# DATABASE_PASSWORD: homepage
# DATABASE_USER: homepage
# DATABASE_HOST: db
# DATABASE_SOCKET: /tmp/mysql.sock
# EC2_PRODUCTION_HOST: 52.199.95.54
# EC2_PRODUCTION_PROTOCOL: http
42 changes: 15 additions & 27 deletions docker/backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
FROM ruby:2.4.5
LABEL maintainer="Kobatake Kazuhiro<@kobakazu0429>"

ENV LANG C.UTF-8

# noninteractive: インストール時にインタラクティブな入力待ちが発生しなくなる
ENV DEBIAN_FRONTEND noninteractive

RUN mkdir /code/

WORKDIR /code

ENV RUNTIME_PACKAGES="bash git perl libxml2-dev libxslt-dev libstdc++ tzdata mariadb-client"\
DEV_PACKAGES="mysql-client"

RUN apt-get update -qq
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils
RUN apt-get install -y libpq-dev graphviz imagemagick
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y nodejs build-essential
RUN npm install -g yarn

RUN gem install bundler
RUN gem update
# apt-get [-qq]: エラー以外は表示しない
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends apt-utils && \
apt-get install -y libpq-dev graphviz imagemagick && \
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get install -y nodejs build-essential && \
gem install bundler --no-document --conservative && \
gem update

ADD Gemfile* /code/
ADD .env /code/

RUN bundle install

ADD ./frontend/package.json /code/
ADD ./frontend/yarn.lock /code/
RUN yarn install

RUN bundle exec rails assets:precompile

# RUN apt-get update -qq &&\
# apt-get install -y $RUNTIME_PACKAGES &&\
# apt-get install -y $DEV_PACKAGES &&\
# gem install bundler --no-document &&\
# bundle config build.nokogiri --use-system-libraries &&\
# bundle install

CMD bundle exec rails s -p 3000 -b '0.0.0.0'
RUN bundle install -j4