Skip to content

Commit

Permalink
Implement time zone support.
Browse files Browse the repository at this point in the history
  • Loading branch information
bovender committed Mar 6, 2020
1 parent 94ec38a commit a716639
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# dora changelog

## Version 1.2.0 (2020-03-06)

### New feature

- Configure the container's time zone using the `$TIMEZONE` environment
variable.

## Version 1.1.0 (2020-03-06)

### New feature
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV RAILS_DB_HOST ""
ENV RAILS_DB_NAME ${APP_NAME}
ENV RAILS_DB_USER ${APP_NAME}
ENV RAILS_DB_PASS ""
ENV TIMEZONE="UCT"
ENV WKHTMLTOPDF ""
ENV WKHTMLTOPDF_URL "https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb"
ENV WKHTMLTOPDF_SUM "db48fa1a043309c4bfe8c8e0e38dc06c183f821599dd88d4e3cea47c5a5d4cd3"
Expand All @@ -30,7 +31,8 @@ RUN /pd_build/nodejs.sh
# Install yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list &&\
apt-get update && apt-get install yarn
apt-get update &&\
apt-get install -y --no-install-recommends yarn tzdata

# This is from passenger-docker's README.
ENV HOME /root
Expand All @@ -57,6 +59,8 @@ ADD bootstrap-container.sh /etc/my_init.d/10_bootstrap_container.sh
RUN chmod +x /etc/my_init.d/10_bootstrap_container.sh
ADD install-wkhtmltopdf.sh /etc/my_init.d/90_install_wkhtmltopdf.sh
RUN chmod +x /etc/my_init.d/90_install_wkhtmltopdf.sh
ADD set-timezone.sh /etc/my_init.d/01_set_timezone.sh
RUN chmod +x /etc/my_init.d/01_set_timezone.sh

RUN mkdir -p /etc/service/sidekiq
ADD run-sidekiq.sh /etc/service/sidekiq/run
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Customization is mostly done with environment variables.
| `RAILS_SMTP_USER` | SMTP user name | `$APP_NAME`
| `RAILS_SMTP_PASS` | SMTP password |
| `SECRET_KEY_BASE` | Rails' secret key base |
| `TIMEZONE` | Time zone of the container | `UCT`
| `NO_WKHTMLTOPDF` | Do not attempt to install [wkhtmltopdf][] | (empty)
| `WKHTMLTOPDF_URL` | Download URL for [wkhtmltopdf][] |

Expand Down Expand Up @@ -332,6 +333,19 @@ via environment variables. A `.env` file lends itself well to this
configuration. The composition consists of the rails app, Postgres, and Redis.
See `sample.env` for usage instructions.

## Container time zone

`passenger-docker` does not configure a time zone for the container. Dora does
do it by installing the `tzdata` package and supporting a `$TIMEZONE` variable.
This variable _must_ be set to a directory and file unter `/usr/share/zoneinfo`,
e.g. `Europe/Berlin`.

To see all possible values for `$TIMEZONE`, issue:

```bash
find /usr/share/zoneinfo -follow | sed -E 's_(/[^/]+){3}/__'
```

## Troubleshooting

### Sending mail
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
- RAILS_DB_NAME
- RAILS_DB_USER
- RAILS_DB_PASS
- TIMEZONE
depends_on:
- db
- redis
Expand Down
1 change: 1 addition & 0 deletions dora-banner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ echo "= RAILS_DB_PASS: $RAILS_DB_PASS"
echo "= RAILS_SMTP_HOST: $RAILS_SMTP_HOST"
echo "= RAILS_SMTP_USER: $RAILS_SMTP_USER"
echo "= RAILS_SMTP_PASS: $RAILS_SMTP_PASS"
echo "= TIMEZONE: $TIMEZONE"
echo "= NO_WKHTMLTOPDF: $NO_WKHTMLTOPDF"
echo "= \`which wkhtmltopdf\`: $(which wkhtmltopdf)"
echo
Expand Down
6 changes: 6 additions & 0 deletions set-timezone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

if [ "$TIMEZONE" != "" ]; then
echo "Setting time zone to $TIMEZONE"
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi

0 comments on commit a716639

Please sign in to comment.