Skip to content

Commit fb26035

Browse files
committed
Added timezone arguments to workspace build
1 parent 781f5ff commit fb26035

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
6161
- [Prepare LaraDock for Production](#LaraDock-for-Production)
6262
- [Setup Laravel and Docker on Digital Ocean](#Digital-Ocean)
6363
- [Misc](#Misc)
64+
- [Change the timezone](#Change-the-timezone)
6465
- [Cron jobs](#CronJobs)
6566
- [MySQL access from host](#MySQL-access-from-host)
6667
- [Use custom Domain](#Use-custom-Domain)
@@ -985,6 +986,24 @@ To learn more about how Docker publishes ports, please read [this excellent post
985986

986987
<br>
987988

989+
<a name="Change-the-timezone"></a>
990+
### Change the timezone
991+
992+
To change the timezone for the `workspace` container, modify the `TZ` build argument in the Docker Compose file to one in the [TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
993+
994+
For example, if I want the timezone to be `New York`:
995+
996+
```yml
997+
workspace:
998+
build:
999+
context: ./workspace
1000+
args:
1001+
- TZ=America/New_York
1002+
...
1003+
```
1004+
1005+
We also recommend [setting the timezone in Laravel](http://www.camroncade.com/managing-timezones-with-laravel/).
1006+
9881007
<a name="CronJobs"></a>
9891008
### Adding cron jobs
9901009

@@ -997,6 +1016,8 @@ You can add your cron jobs to `workspace/crontab/root` after the `php artisan` l
9971016
* * * * * root echo "Every Minute" > /var/log/cron.log 2>&1
9981017
```
9991018
1019+
Make sure you [change the timezone](#Change-the-timezone) if you don't want to use the default (UTC).
1020+
10001021
<a name="MySQL-access-from-host"></a>
10011022
### MySQL access from host
10021023

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
- PUID=1000
1919
- PGID=1000
2020
- NODE_VERSION=stable
21+
- TZ=UTC
2122
volumes_from:
2223
- volumes_source
2324
extra_hosts:

workspace/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ ARG PUID=1000
4646
ARG PGID=1000
4747
RUN groupadd -g $PGID laradock && \
4848
useradd -u $PUID -g laradock -m laradock
49+
50+
#####################################
51+
# Set Timezone
52+
#####################################
53+
54+
ARG TZ=UTC
55+
ENV TZ ${TZ}
56+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
4957

5058
#####################################
5159
# Composer:

0 commit comments

Comments
 (0)