Ruby on rails with recent ruby:2.7.1-alpine
container, breaks timezone daylight-saving support:
irb(main):004:0> Time.zone.to_s
=> "(GMT+01:00) Europe/Berlin"
irb(main):005:0> Time.zone.parse("2020-08-27").zone
=> "CEST"
irb(main):006:0> Time.zone.parse("2020-12-27").zone
=> "CEST"
2020-12-27 should actually be CET because of daylight saving. On local ruby installation and previous container builds it used to work and would returns:
irb(main):006:0> Time.zone.to_s
=> "(GMT+01:00) Europe/Berlin"
irb(main):007:0> Time.zone.parse("2020-08-27").zone
=> "CEST"
irb(main):008:0> Time.zone.parse("2020-12-27").zone
=> "CET"
The Dockerfile looks as follows:
FROM ruby:2.7.1-alpine
# Add basic packages
RUN apk add --update --no-cache \
build-base \
python2 \
postgresql-dev \
git \
nodejs \
yarn \
tzdata \
file \
# Image processing resources
gobject-introspection-dev \
poppler-dev \
# Test Resources
chromium-chromedriver \
chromium \
harfbuzz \
nss
WORKDIR /app
# Install standard gems
COPY Gemfile* /app/
RUN gem install bundler && \
bundle config --global frozen 1 && \
bundle config --local build.sassc --disable-march-tune-native && \
bundle install -j4 --retry 3
# Install standard Node modules
COPY package.json yarn.lock /app/
RUN yarn install
ONBUILD COPY . ./
Does anybody knows more about the internals? Is this a rails or ruby or alpine package problem. Any help would be great!
UPDATE
I could reproduce the behavior with a clean docker like:
docker run -it ruby:2.7.1-alpine /bin/sh
0 apk add --update --no-cache build-base sqlite-dev nano nodejs yarn tzdata
1 gem install rails
2 rails new timzone_test
3 rails webpacker:install
4 nano config/application.rb # add config.time_zone = 'Europe/Berlin'
5 rails console
I have the same issue on this clean install
Loading development environment (Rails 6.0.3.4)
irb(main):001:0> Time.zone.parse("2020-12-27").zone
=> "CEST"
After adding gem 'tzinfo-data'
to the Gemfile, everything worked as expected:
Loading development environment (Rails 6.0.3.4)
irb(main):001:0> Time.zone.parse("2020-12-27").zone
=> "CET"