Skip to content

Commit a716639

Browse files
committed
Implement time zone support.
1 parent 94ec38a commit a716639

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

Diff for: CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# dora changelog
22

3+
## Version 1.2.0 (2020-03-06)
4+
5+
### New feature
6+
7+
- Configure the container's time zone using the `$TIMEZONE` environment
8+
variable.
9+
310
## Version 1.1.0 (2020-03-06)
411

512
### New feature

Diff for: Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ENV RAILS_DB_HOST ""
1717
ENV RAILS_DB_NAME ${APP_NAME}
1818
ENV RAILS_DB_USER ${APP_NAME}
1919
ENV RAILS_DB_PASS ""
20+
ENV TIMEZONE="UCT"
2021
ENV WKHTMLTOPDF ""
2122
ENV WKHTMLTOPDF_URL "https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb"
2223
ENV WKHTMLTOPDF_SUM "db48fa1a043309c4bfe8c8e0e38dc06c183f821599dd88d4e3cea47c5a5d4cd3"
@@ -30,7 +31,8 @@ RUN /pd_build/nodejs.sh
3031
# Install yarn
3132
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
3233
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list &&\
33-
apt-get update && apt-get install yarn
34+
apt-get update &&\
35+
apt-get install -y --no-install-recommends yarn tzdata
3436

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

6165
RUN mkdir -p /etc/service/sidekiq
6266
ADD run-sidekiq.sh /etc/service/sidekiq/run

Diff for: README.md

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Customization is mostly done with environment variables.
4242
| `RAILS_SMTP_USER` | SMTP user name | `$APP_NAME`
4343
| `RAILS_SMTP_PASS` | SMTP password |
4444
| `SECRET_KEY_BASE` | Rails' secret key base |
45+
| `TIMEZONE` | Time zone of the container | `UCT`
4546
| `NO_WKHTMLTOPDF` | Do not attempt to install [wkhtmltopdf][] | (empty)
4647
| `WKHTMLTOPDF_URL` | Download URL for [wkhtmltopdf][] |
4748

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

336+
## Container time zone
337+
338+
`passenger-docker` does not configure a time zone for the container. Dora does
339+
do it by installing the `tzdata` package and supporting a `$TIMEZONE` variable.
340+
This variable _must_ be set to a directory and file unter `/usr/share/zoneinfo`,
341+
e.g. `Europe/Berlin`.
342+
343+
To see all possible values for `$TIMEZONE`, issue:
344+
345+
```bash
346+
find /usr/share/zoneinfo -follow | sed -E 's_(/[^/]+){3}/__'
347+
```
348+
335349
## Troubleshooting
336350

337351
### Sending mail

Diff for: docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ services:
2424
- RAILS_DB_NAME
2525
- RAILS_DB_USER
2626
- RAILS_DB_PASS
27+
- TIMEZONE
2728
depends_on:
2829
- db
2930
- redis

Diff for: dora-banner.sh

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ echo "= RAILS_DB_PASS: $RAILS_DB_PASS"
2929
echo "= RAILS_SMTP_HOST: $RAILS_SMTP_HOST"
3030
echo "= RAILS_SMTP_USER: $RAILS_SMTP_USER"
3131
echo "= RAILS_SMTP_PASS: $RAILS_SMTP_PASS"
32+
echo "= TIMEZONE: $TIMEZONE"
3233
echo "= NO_WKHTMLTOPDF: $NO_WKHTMLTOPDF"
3334
echo "= \`which wkhtmltopdf\`: $(which wkhtmltopdf)"
3435
echo

Diff for: set-timezone.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$TIMEZONE" != "" ]; then
4+
echo "Setting time zone to $TIMEZONE"
5+
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
6+
fi

0 commit comments

Comments
 (0)