Skip to content
Iniciando um projeto Rails usando docker-compose
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Dockerfile
Procfile.dev
README.md
docker-compose.yml

README.md

Iniciando um novo projeto utilizando o docker-compose

  1. Remover git init
$ rm -rf .git
  1. Instalar ambiente
$ docker-compose build
  1. Instalar o Rails
$ docker-compose run --rm web bash
$ gem install rails -v 5.2.0
  1. Construir o projeto
$ docker-compose run --rm web rails new . -T --force --database=postgresql --webpack --skip-coffee

# optional
$ docker-compose run --rm web rails webpacker:install
$ docker-compose run --rm web rails webpacker:install:react
  1. Editar o arquivo config/database.yml
development: &default
  adapter: postgresql
  database: myapp_development
  encoding: unicode
  username: user
  password:
  pool: 5

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  database: myapp_production
  1. Criar banco de dados
$ docker-compose run --rm web rails db:create
  1. Instalar a gem foreman Gemfile
gem 'foreman'
  1. Editar o arquivo config/webpacker.yml
dev_server:
  host: 0.0.0.0
  1. Editar o arquivo config/environments/development.rb (inserir no inicio do código)
# Add to whitelist the '172.18.0.1' network space in the Web Console config.
config.web_console.whitelisted_ips = ['192.168.0.0/16', '172.0.0.0/8']

# Level of logs

config.log_level = :warn
# config.log_level = :debug
  1. Criar home page
rails generate controller home index  --no-helper --no-assets --no-controller-specs --no-view-specs
  1. Inserir a tag no arquivo app/views/home/index.html.erb
<%= javascript_pack_tag 'hello_react' %>
  1. Subir aplicação
$ docker-compose up web

# bash:
$ docker-compose run --rm web bash
  1. Acessar a página localhost

http://localhost:3000

You can’t perform that action at this time.