Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomoki171923/docker-rails7

Ruby on Rails 7 on docker-compose
https://github.com/tomoki171923/docker-rails7

docker-compose rails7

Last synced: 18 days ago
JSON representation

Ruby on Rails 7 on docker-compose

Awesome Lists containing this project

README

        

**Table of Contents**

- [docker-rails7](#docker-rails7)
- [version](#version)
- [setup pre-commit](#setup-pre-commit)
- [setup development environment](#setup-development-environment)
- [create rails application](#create-rails-application)
- [build docker container](#build-docker-container)
- [create database](#create-database)
- [access rails application](#access-rails-application)
- [db migrate & insert data](#db-migrate--insert-data)

# docker-rails7

ruby on rais7 api mode on docker.

## version

Ruby : 3.1.2

Rails : 7.0.3

Postgres : 14.5

## setup pre-commit

install rbenv & pre-commit

```
brew install rbenv ruby-build
brew install pre-commit
```

install ruby & rubocop (for pre-commit)

```
rbenv install 3.1.2
rbenv local 3.1.2
rbenv exec gem install rubocop
rbenv exec gem install rubocop-performance
rbenv exec gem install rubocop-rails
```

apply pre-commit config

```
pre-commit install
```

## setup development environment

### create rails application

```
docker-compose run --rm --no-deps api rails new . --force --database=postgresql --api
```

### build docker container

```
cp -p local/rails/database.yml.org config/database.yml
docker-compose up -d --build
```

### create database

```
docker exec local_rails_api rake db:create
```

### access rails application

(it will take some time.)

access



### db migrate & insert data

```
docker exec local_rails_api rails generate scaffold user name:string age:integer area:string
docker exec local_rails_api rake db:migrate
```

write the following into db/seeds.rb

```
User.create(:name => 'Test', :age => '20', :area => 'Tokyo')
```

```
docker exec local_rails_api rails db:seed
```

access