docker-compose.yml
web: &web
build: .
# command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/app
- gem_data:/usr/local/bundle
ports:
- "3000:3000"
environment:
WEBPACKER_DEV_SERVER_HOST: webpacker
WEBPACKER_DEV_SERVER_PUBLIC: 0.0.0.0:3035
TZ: Asia/Tokyo ← こいつを記載
application.rb
module App
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
# config.active_record.default_timezone = :local
config.i18n.default_locale = :ja # デフォルトのlocaleを日本語(:ja)にする
config.time_zone = 'Asia/Tokyo' ← 追加
config.active_record.default_timezone = :local ← 追加
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
initializer(:remove_action_mailbox_and_activestorage_routes, after: :add_routing_paths) { |app|
app.routes_reloader.paths.delete_if {|path| path =~ /activestorage/}
app.routes_reloader.paths.delete_if {|path| path =~ /actionmailbox/ }
}
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
config.paths.add 'lib', eager_load: true
end
end
これだけで日本時間に変更可能。
#dockerfileは書き換えたら docker-compose down、docker-compose upの手順踏まないと反映されません。