Make the strongest Laravel development environment (Docker) Japan time

Introduction (Development environment construction)

https://qiita.com/ucan-lab/items/5fc1281cd8076c8ac9f4

When I cloned this god repository and tried to use it, Since TimeZone was UTC, it will be a memorandum when it is corrected to Japan time.

Modify the Dockerfile in the configuration below. When implementing for those who have launched a container, Correct the Dockerfile when the container is stopped and rebuild it.

Directory structure

├── backend #Laravel project root directory
├── infra
│     └── docker
│          ├── mysql
│          │   ├── Dockerfile
│          │   └── my.cnf
│          ├── nginx
│          │   ├── Dockerfile
│          │   └── default.conf
│          └── php
│              ├── Dockerfile
│              ├── php-fpm.d
│              │   └── zzz-www.conf =>unix domain socket configuration file
│              └── php.ini
├── Makefile
└── docker-compose.yml

mysql

Modification place

docker-laravel\infra\docker\mysql\Dockerfile


#Change ENV TZ (near the 4th line)
# ENV TZ=UTC \
ENV TZ=Asia/Tokyo \

Confirmation method

It will be the work after build and container start-up (up) are completed.

shell


$ make db
# $ docker-compose exec db bash (Contents of the above make command)
root@XXXXXXX:# mysql -u root -p -h 127.0.0.1
Enter password: secret
#Please enter the PW near the 8th line described in the Dockerfile.
#  MYSQL_ROOT_PASSWORD=secret
#                       ̄ ̄ ̄ ̄
mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | JST    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.01 sec)

If JST is displayed in system_time_zone, there is no problem.

nginx

Modification place

docker-laravel\infra\docker\nginx\Dockerfile


#Change ENV TZ (near line 6)
# ENV TZ=UTC
ENV TZ=Asia/Tokyo

Confirmation method

It will be the work after build and container start-up (up) are completed.

shell


$ make web
# $ docker-compose exec web ash  (Contents of the above make command)
/work/backend# date

If the current time is displayed, there is no problem.

php

Modification place

docker-laravel\infra\docker\php\Dockerfile


#Change the timezone environment (near the 5th line)
# ENV TZ=UTC \
  # locale
#  LANG=en_US.UTF-8 \
#  LANGUAGE=en_US:en \
#  LC_ALL=en_US.UTF-8 \
ENV TZ=Asia/Tokyo \
  # locale
  LANG=ja_JP.UTF-8 \
  LANGUAGE=ja_JP:ja \
  LC_ALL=ja_JP.UTF-8 \

docker-laravel\infra\docker\php\Dockerfile


#Change local settings (near line 36)
#  locale-gen en_US.UTF-8 && \
#  localedef -f UTF-8 -i en_US en_US.UTF-8 && \

  locale-gen ja_JP.UTF-8 && \
  localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 && \

Confirmation method

It will be the work after build and container start-up (up) are completed.

shell


$ make app
# $ docker-compose exec app bash (Contents of the above make command)
root@XXXXXXX:/work/backend# php -r 'echo date("Y/m/d H:i:s"),PHP_EOL;'

If the current time is displayed, there is no problem.

Finally

This completes the response. I hope it helps someone.

If you have any mistakes or better repair methods, please let us know in the comments. Thank you.

Recommended Posts

Make the strongest Laravel development environment (Docker) Japan time
Laravel development environment construction with Docker (Mac)
Improve the performance of your Docker development environment
Docker the development environment of Ruby on Rails project
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
Debug the VSCode + Docker + PHP development environment with XDebug.
Environment construction method and troubleshooter at the time of joint development (rails, docker and github)
WSL2 + VSCode + Docker development environment
One file of Docker x Laravel threat! Build a local development environment with the minimum configuration
About the current development environment (Java 8)
Install laravel/Dusk in docker environment (laravel6)
Build a browser test environment using Capybara in the Docker development environment
Create Laravel environment with Docker (docker-compose)
Build Unity development environment on docker
Build docker + laravel environment with laradock
Build a Docker-based development environment on Windows 10 Home 2020 ver. Part 2 VS Code should make the Docker development environment comfortable
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
I had to lower the PHP version in Docker + Composer + Laravel environment
I tried migrating the portfolio created on Vagrant to the Docker development environment
Sapper × Go (echo) × Docker development environment construction
Build a PureScript development environment with Docker
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Create Spring Boot-gradle-mysql development environment with Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Laravel + MySQL + phpMyadmin environment construction with Docker
Build a Wordpress development environment with Docker
Try the Docker environment on AWS ECS
Build an Ultra96v2 development environment on Docker 1
Lightweight PHP 7.4 development environment created with Docker
Build a simple Docker + Django development environment
Prepare Nuxt (web) + Laravel (API) development environment in the same repository using docker-compose
Procedure for introducing Docker into the development environment of existing Rails applications [Rails, MySQL, Docker]
Introduce Docker to the development environment and test environment of existing Rails and MySQL applications
I tried using Docker for the first time
Just install Laravel8 on docker in PHP8 environment
Build a Laravel / Docker environment with VSCode devcontainer
Prepare the JVM language development environment with WSL
Build a WordPress development environment quickly with Docker
The story that docker had a hard time
Build a simple Docker Compose + Django development environment
I tried touching Docker for the first time
A reminder of Docker and development environment construction
Docker × Laravel HTTPS (SSL) communication in local environment
Build a development environment for Docker, java, vscode
[First team development ②] Build an environment with Docker
Unify the Rails app time zone to Japan time
Wordpress local environment construction & development procedure with Docker
Create a Spring Boot development environment with docker