Skip to content

This repository provides rails environment based on docker and a api document based on swagger definition.

License

Notifications You must be signed in to change notification settings

yusa-n/rails-docker-boilerplate

Repository files navigation

Rails Docker Boilerplate

System Configuration

Item Content
Framework Ruby on Rails 5.2.0
Ruby Version 2.5.1
Database MySQL 5.7.22
API Document Swagger(OpenAPI 2.0)
Required Middleware Docker version 18.03.0-ce
Bug report / feature requests GitHub Issue

Getting Started

# Clone
https://github.com/ujway/rails-docker-boilerplate.git
cd rails-docker-boilerplate

# Docker container create, install bundle and run a rails server
docker -v # out> Docker version 17.12.0-ce, build c97c6d6
docker-compose build
docker-compose up -d

# Setup rails database
docker-compose exec web ruby -v # out> ruby 2.5.0p0 ...
docker-compose exec web rails -v # out> Rails 5.1.5
docker-compose exec web rails db:create
docker-compose exec web rails db:migrate

#### Remove all containers and images defined in docker-compose
# docker-compose down -v --rmi all

example:

  1. Rails
  1. Swagger UI(./doc/swagger.yamlの内容を表示)

Development Memos

docker-compose exec web [Command]でコンテナ外でコマンドが実行可能ですが、
docker-compose exec -it web bashでコンテナ内部に入ってコマンドを実行することもできます。
docker-compose exec webdocker exec rails_api_webとして実行可能です。

Docker

  • 起動中のdockerコンテナのシェルに入る
    • docker-compose exec -it web bash
  • dockerコンテナでコマンドを実行する
    • docker-compose exec web [Command]

Rails

  • Model or Controllerを作成する
    • docker-compose exec web rails g [model|controller] [ModelName|ControllerName]を実行する
  • Migrationを作成する
    • docker-compose exec web rails g migration [MigrationName]を実行する
    • 生成されたdb/migrate/{yyyymmddhhmmss}_{migration_name}.rbにchange/up/downを記載する
    • docker-compose exec web rails db:migrateを実行する
  • Migrationをリセットする
    • docker-compose exec web rails db:migrate:resetを実行する

API Definition

  • Swaggerの定義を編集する
    • doc/swagger.yaml

License

This software is released under the MIT License, see LICENSE.txt.

About

This repository provides rails environment based on docker and a api document based on swagger definition.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published