Add env variable driven timezone

This commit is contained in:
Adrien Ferrand 2017-08-02 10:15:42 +02:00
parent d6924d1f5a
commit 17aa3d5b31
4 changed files with 36 additions and 3 deletions

View File

@ -11,7 +11,7 @@ RUN apk --no-cache add \
# Install backuppc build dependencies
gcc g++ autoconf automake make git patch perl perl-dev perl-cgi expat expat-dev curl wget \
# Install backuppc runtime dependencies
supervisor rsync samba-client iputils openssh openssl rrdtool msmtp lighttpd lighttpd-mod_auth gzip apache2-utils \
supervisor rsync samba-client iputils openssh openssl rrdtool msmtp lighttpd lighttpd-mod_auth gzip apache2-utils tzdata \
# Compile and install needed perl modules
&& cpan App::cpanminus \
&& cpanm -n Archive::Zip XML::RSS File::Listing \

View File

@ -17,7 +17,9 @@
* [Advanced SMTP configuration](#advanced-smtp-configuration)
* [Upgrading](#upgrading)
* [Dockerising an existing BackupPC v3.x](#dockerising-an-existing-backuppc-v3x)
* [Shell access](#shell-access)
* [Miscellaneous](#miscellaneous)
* [Timezone](#timezone)
* [Shell access](#shell-access)
## Introduction
@ -222,6 +224,32 @@ docker run \
The configure.pl script will detect a v3.x version under /etc/backuppc, and will run appropriate upgrade operations (in particular enabling legacy v3.x pool to access it from a BackupPC v4.x).
## Miscellaneous
### Timezone
By default the timezone of this docker is set to UTC. To modify it, you can specify a tzdata-compatible timezone in the environment variable `TZ`.
```bash
# For Paris time (including daylight)
docker run \
--name backuppc \
--publish 80:8080 \
--env TZ=Europe/Paris \
adferrand/backuppc
```
Alternatively, you can sync the container timezone to its host by mounting the host file `/etc/localtime` to the container path `/etc/localtime`.
```bash
# For Paris time (including daylight)
docker run \
--name backuppc \
--publish 80:8080 \
--mount /etc/localtime:/etc/localtime:ro \
adferrand/backuppc
```
## Shell access
For debugging and maintenance purpose, you may need to start a shell in your running container. With a Docker of version 1.3.0 or higher, you can do:

View File

@ -1 +1 @@
4.1.3-5
4.1.3-6

View File

@ -5,6 +5,11 @@ if [ -f /firstrun ]; then
echo 'First run of the container. BackupPC will be installed.'
echo 'If exist, configuration and data will be reused and upgraded as needed.'
# Configure timezone if needed
if [ -z "$TZ" ]; then
cp /usr/share/zoneinfo/$TZ /etc/localtime
fi
# Create backuppc user
addgroup -S -g ${BACKUPPC_GUID:-1000} backuppc
adduser -D -S -h /home/backuppc -G backuppc -u ${BACKUPPC_UUID:-1000} backuppc