Skip to content

Instantly share code, notes, and snippets.

@mgtsuzuki
mgtsuzuki / database.yml
Created December 7, 2020 14:56
Arquivo config/database.yml
default: &default
adapter: <%= ENV['DB_ADAPTER'] ||= 'postgresql' %>
encoding: unicode
host: <%= ENV['DB_ADAPTER'] == 'postgresql' ? ENV.fetch('DATABASE_HOST') : nil %>
username: <%= ENV['DB_ADAPTER'] == 'postgresql' ? ENV.fetch('POSTGRES_USER') : nil %>
password: <%= ENV['DB_ADAPTER'] == 'postgresql' ? ENV.fetch('POSTGRES_PASSWORD') : nil %>
database: <%= ENV['DB_ADAPTER'] == 'postgresql' ? ENV.fetch('POSTGRES_DB') : nil %>
pool: 5
variables:
statement_timeout: 5000
@mgtsuzuki
mgtsuzuki / Gemfile
Last active December 7, 2020 13:46
Arquivo Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.6'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3', '~> 1.4'
gem 'pg', '~> 1.0'
@mgtsuzuki
mgtsuzuki / docker-stack.yml
Last active December 7, 2020 15:50
Arquivo docker-stack.yml
version: '3'
services:
web:
image: mgtsuzuki/livra_web:prod
ports:
- "80:3000"
env_file:
- .env/production/database
- .env/production/web
redis:
@mgtsuzuki
mgtsuzuki / Dockerfile.prod
Last active December 7, 2020 15:51
Arquivo Dockerfile.prod
FROM ruby:2.6-stretch
LABEL maintener='mtsuzuki@usp.br'
ARG DB_ADAPTER=nulldb
# Permite que o apt opere com fontes baseadas em https
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends apt-transport-https
# Assegure-se de instalar uma versao corrente para o Node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
@mgtsuzuki
mgtsuzuki / production.rb
Last active December 3, 2020 19:10
Arquivo config/environments/production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
@mgtsuzuki
mgtsuzuki / cable.yml
Created December 3, 2020 19:04
Arquivo config/cable.yml
development:
adapter: async
test:
adapter: test
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://redis:6379/1" } %>
channel_prefix: livra_production
@mgtsuzuki
mgtsuzuki / application.html.erb
Created December 2, 2020 12:19
Arquivo app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Meca</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
@mgtsuzuki
mgtsuzuki / Gemfile
Created November 30, 2020 13:28
Arquivo Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.6'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3', '~> 1.4'
gem 'pg', '~> 1.0'
@mgtsuzuki
mgtsuzuki / Dockerfile.prod
Created November 30, 2020 13:26
Arquivo Dockerfile.prod
FROM ruby:2.6-stretch
LABEL maintener='mtsuzuki@usp.br'
ENV BUNDLE_BUILD__SASSC=--disable-march-tune-native
ENV RAILS_ENV production
ENV DATABASE_HOST=database
ENV RAILS_ENV=production
ENV SECRET_KEY_BASE=4e109b7f983594649e474243e76037e2a3c3faed2d1c6f1b797df338d435b1785157e81a513c2163c85a11ce47b61fc6a80134ea5e66e37e3249be4cfa5ad25b
ENV RAILS_LOG_TO_STDOUT=true
ENV RAILS_SERVE_STATIC_FILES=true
ENV POSTGRES_USER=postgres
@mgtsuzuki
mgtsuzuki / docker-stack.yml
Last active December 7, 2020 15:50
Arquivo docker-stack.yml
version: '3'
services:
web:
image: mgtsuzuki/meca_web:prod
ports:
- "80:3000"
env_file:
- .env/production/database
- .env/production/web
redis: