Giter Club home page Giter Club logo

docker_tmp's Introduction

事前準備

  • Docker
  • Git
  • エディタ

Docker

Mac

Windows

git

Mac

ターミナルを開いて、

$ brew install git

エディタ

必要に応じて、以下よりダウンロードしてください。

https://atom.io/

環境構築

  • リポジトリをクローンする
  • ディレクトリ名を変更し、ディレクトリに移動する
  • プロジェクト名を設定する
  • サーバ構築、 bundle install
  • Rails new
  • bundle install
  • データベースの接続設定
  • データベースを作成する
  • 起動確認
  • github でに push する

リポジトリをクローンする

$ git clone https://github.com/GuildWorks/docker-titech.git

ディレクトリ名を変更し、ディレクトリに移動する

ディレクトリ名は自由

$ mv docker-titech example
$ cd example

プロジェクト名(フォルダ名)を設定する

Dockerfile の 18 行目にフォルダ名を設定する

ENV app_name docker-titech

↑ を変更する

ENV app_name example

docker-compose.yml の 9 行目、 21 行目を編集する

9 行目

    - .:/docker-titech

↑ を変更する

    - .:/example

21 行目

  image: dockertitech_web

↑ を変更する

  image: example_web

サーバ構築、 bundle install

下記のコマンドで、サーバを作成し、Bundle インストール

$ docker-compose build
$ docker-compose run web bundle install

Rails プロジェクトを作る

$ docker-compose run web bundle exec rails new . --force -B --database=postgresql -T -S --no-rc

bundle install

Gemfile が生成され、上書きされるので、再度 Bundle インストール

$ docker-compose run web bundle install

データベースの接続設定

config/database.yml を編集し、接続情報を環境変数で設定する

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 } %>
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  host: <%= ENV['DB_HOST'] %>

データベースを作成する

DB の生成、マイグレーションを行う

$ docker-compose run web bundle exec rails db:create db:migrate db:seed

起動確認

サーバを起動する

$ docker-compose up

サーバが起動したら

http://localhost:3000/

へアクセスして、起動を確認する

github へ push する

github にリポジトリを作成し、 push する

$ git remote set-url origin [email protected]:GuildWorks/xxxxxxxxxx.git
$ git add .
$ git commit -m 'new project'
$ git push -u origin master

docker_tmp's People

Contributors

hirotaka avatar tskst avatar chachaki avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.