by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 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 ( on the env of the old original Laravel project needs to be changed to the service name (db) of the MySQL container.
- 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= 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:

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 ; 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= will be automatically changed to DB_HOST=db in the new version (v1.0.0) .

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= 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

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.

laravel docker

About D-Laravel's project mode

If you are a new user, I suggest you use my latest environment phpenv instead.


D-Laravel v1.2.1 version change description (recommended update, must avoid stepping on thunder)

D-Laravel v1.2.1 revision instructions use GuzzleHttp\Client; When posting, there is an access denied problem. If you are upgrading from an older version, you may need to adjust the configuration file in etc/default-ssl.conf (if there is one) Please adjust php:9000 to web:9000, you can adjust it by executing ./console secure once. In the docker-compose configuration file, change the PHP-FPM container to network_mode: "service:web"...