Correções para funcionamento do Docker

This commit is contained in:
2026-06-11 19:30:40 -03:00
parent 3b07e72d6e
commit b59fedec5c
25 changed files with 203 additions and 1 deletions

27
config/application.rb Normal file
View File

@@ -0,0 +1,27 @@
require_relative "boot"
require "rails/all"
Bundler.require(*Rails.groups)
require "dotenv/load" if defined?(Dotenv)
module GadeLogistica
class Application < Rails::Application
config.load_defaults 7.1
# Timezone e idioma Brasil
config.time_zone = "America/Sao_Paulo"
config.i18n.default_locale = :'pt-BR'
config.i18n.available_locales = [:'pt-BR', :en]
config.i18n.fallbacks = [:en]
# Autoload de services
config.autoload_paths += %W[#{config.root}/app/services]
# Não gerar specs/helpers desnecessários
config.generators do |g|
g.test_framework :rspec
g.helper false
g.stylesheets false
end
end
end

2
config/boot.rb Normal file
View File

@@ -0,0 +1,2 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup"

2
config/environment.rb Normal file
View File

@@ -0,0 +1,2 @@
require_relative "application"
Rails.application.initialize!

View File

@@ -0,0 +1,22 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = true
config.eager_load = false
config.consider_all_requests_local = true
config.server_timing = true
config.cache_store = :memory_store
config.active_storage.service = :local if defined?(ActiveStorage)
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST", "localhost:3000") }
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.active_record.verbose_query_logs = true
config.assets.quiet = true if config.respond_to?(:assets)
config.hosts.clear # aceita qualquer host em dev (Docker/IP local)
end

View File

@@ -0,0 +1,27 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = false
config.eager_load = true
config.consider_all_requests_local = false
config.force_ssl = false # mude para true quando tiver HTTPS
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
config.log_tags = [:request_id]
config.logger = ActiveSupport::Logger.new(STDOUT).tap { |l| l.formatter = ::Logger::Formatter.new }
.then { |l| ActiveSupport::TaggedLogging.new(l) }
config.cache_store = :memory_store
config.active_storage.service = :local if defined?(ActiveStorage)
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST", "localhost:3000") }
config.i18n.fallbacks = true
config.active_support.report_deprecations = false
config.active_record.dump_schema_after_migration = false
# Aceita o host configurado no .env
config.hosts << ENV["APP_HOST"]&.split(":")&.first if ENV["APP_HOST"].present?
config.hosts.clear if ENV["RAILS_ALLOW_ALL_HOSTS"] == "true"
end

View File

@@ -0,0 +1,10 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = false
config.eager_load = ENV["CI"].present?
config.consider_all_requests_local = true
config.cache_store = :null_store
config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr
end

6
config/importmap.rb Normal file
View File

@@ -0,0 +1,6 @@
# Pin npm packages by running ./bin/importmap
pin "application"
pin "@hotwired/turbo-rails", to: "turbo.min.js"
pin "@hotwired/stimulus", to: "stimulus.min.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
pin_all_from "app/javascript/controllers", under: "controllers"

View File

@@ -0,0 +1,16 @@
Devise.setup do |config|
config.mailer_sender = ENV.fetch('SMTP_USERNAME', 'noreply@gade.com.br')
require 'devise/orm/active_record'
config.case_insensitive_keys = [:email]
config.strip_whitespace_keys = [:email]
config.skip_session_storage = [:http_auth]
config.stretches = Rails.env.test? ? 1 : 12
config.reconfirmable = true
config.expire_all_remember_me_on_sign_out = true
config.password_length = 6..128
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
config.reset_password_within = 6.hours
config.sign_out_via = :delete
config.responder.error_status = :unprocessable_entity
config.responder.redirect_status = :see_other
end

9
config/locales/pt-BR.yml Normal file
View File

@@ -0,0 +1,9 @@
pt-BR:
date:
formats:
default: "%d/%m/%Y"
short: "%d/%m/%Y"
time:
formats:
default: "%d/%m/%Y %H:%M"
short: "%d/%m %H:%M"

9
config/puma.rb Normal file
View File

@@ -0,0 +1,9 @@
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
plugin :tmp_restart

View File

@@ -1,7 +1,9 @@
# config/routes.rb
Rails.application.routes.draw do
# Devise — login padrão para admin/gerente/operador
devise_for :users, path: 'auth', path_names: {
devise_for :users, path: 'auth',
controllers: { sessions: 'users/sessions' },
path_names: {
sign_in: 'login',
sign_out: 'logout',
password: 'senha'