by Devin Yang
(This article was automatically translated.)

Published - 7 years ago ( Updated - 7 years ago )

In order to allow the container to be used more flexibly, D-Laravel has released version v1.0.0 , which is not backward compatible .

meaning of incompatible change

- The old ./console and ./create bash cannot be used normally in the new version v1.0.0 .
- The location of the database IP (127.0.0.1) on the env of the old original Laravel project needs to be changed to the service name (db) of the MySQL container.
DB_HOST=db
- If you have a custom nginx configuration file, you need to adjust the connection method of php-fpm.
fastcgi_pass php:9000;
-If you have a custom docker-compose-custom.yml that needs to be adjusted to the new one.

When you update directly to v1.0.0 with git pull:

Normally, you just need to adjust the location of DB_HOST.
You need to modify the .env file on the old Laravel project, change DB_HOST=127.0.0.1 to DB_HOST=db
If you have a custom docker-compose-custom.yml file,
Please use docker-compose-normal or docker-compose-random as a template for modification.

About this change:

For the yaml file of docker-compose before v1.0.0 , use network_mod: "service:web", we can imagine that the networks of the three container services are tied to the web container service
Therefore, in terms of settings, we connect to php-fpm and mysql using the IP address of the local machine connected to the loopback: 127.0.0.1.

The new setting of v1.0.0 is to change the yaml file of docker-compose to use networks . We can think of it as three container services ( web , php and db ) added to the customized network.
So the web container (that is, nginx) service needs to use php-fpm to specify the service name of the php container. (here called php )
Below is the fragment of etc/default.conf, the original fastcgi_pass 127.0.0.1:9000 ; has been adjusted to fastcgi_pass php :9000;
 location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_read_timeout 500;
}
The new version create bash, for example: when using the project ./create test1,
The original DB_HOST=127.0.0.1 will be automatically changed to DB_HOST=db in the new version (v1.0.0) .
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=test1
DB_USERNAME=homestead
DB_PASSWORD=secret

Old version (before v1.0.0) updated to new version (v1.0.0)

For a safe update method, we can grab D-Laravel v1.0.0 and test it.
Copy the project in the sites/ of the old version to the sites/ of the new version v.1.0.0.
The folder data/ containing the data is copied to the directory of v1.0.0.
( Please confirm that the new version of docker-compose.yml uses the same DB image version as the old version,
A mysql image with too much difference will cause the DB container to fail to start)
And modify the .env file of the laravel project in sites/, change DB_HOST=127.0.0.1 to DB_HOST=db
There must be port overflow, we can stop the old version of D-Laravel,
Restart the v1.0.0 version of d-laravel to confirm whether it works normally.
 

Tags: d-laravel docker laravel docker-compose

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


docker laravel

Chatting about D-Laravel's console commands

D-Laravel's console command allows us to quickly understand what he executes. How is it executed if docker-compose is used? Let's see.

laravel example, laravel teaching, livewire example, laravel

How to set cultural error messages in Laravel Livewire components

This article uses a simple Laravel livewire example to see how the livewire component verifies user input errors and displays Chinese error messages.

docker, d-laravel, docker-compose, laravel

docker-compose loads multiple configuration files

We will use docker --network to establish multiple container interconnections, but if there are four containers, Is it necessary to issue docker run instructions for different containers four times, kill me, This article introduces the establishment of multiple containers at one time through the yaml file definition of docker-compose. Learn how to load multiple configuration files with the dokcer-compose -f parameter.