How to setup laravel in docker at production server

Simply search for it. I found…

This is okay brother…But If connect to local database , we put a DB_HOST = 'service_name in docker-compose file'

Then what we do in connect to digital ocean managed database. DB_HOST = ?

You have to adjust the configuration of Laravel as described in the link:

Make sure to select a MySQL 8 connection, and use the following configuration:

  • host: prod-do-user-XXXXXX.b.db.ondigitalocean.com replace with your database’s public hostname
  • port: 25060 it’s not the default, 3306, make sure to update it!
  • username
  • password make sure not to copy the extra space at the end of the password
  • database

and finally, choose the option so you can add the CA certificate that you just downloaded.

Simply edit your .env file, and in the database area replace the values:

DB_CONNECTION=mysql
DB_HOST=private-XXXXX.b.db.ondigitalocean.com
DB_PORT=25060
DB_DATABASE=XXXXX
DB_USERNAME=XXXXX
DB_PASSWORD=XXXXX
SSL_MODE=required
MYSQL_ATTR_SSL_CA=[PATH TO MY PROJECT]/storage/certs/ca-certificate.crt

Don’t forget to copy the CA certificate into the Container where Laravel is located.
Also make sure that the certificate does not located in the web server’s public directory.
And then adjust the path to it under MYSQL_ATTR_SSL_CA

Or have I misunderstood you?