Please help me. When gitlab CI instance run then error migrate of laravel , can't connect host mysql enter image description here
CodePudding user response:
First: Use Docker with environment variables for deploy everyone :D
Second:
Make cut .env
in CI script and show.
Your sed is not working right. It substitutes the variable name with the value, and not your data in the variable value.
Should be something like:
sed -i "s|DB_HOST=|DB_HOST=${DB_HOST}|g" .env
Third: Don't use .env.example
for building .env
. Build .env
file from empty.
CodePudding user response:
You didn't set up your MySQL properly. For services you have MySQL, but no port of it is exposed, NO MySQL root username, password, or database is set. It should be something like...
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: laravel
ports:
- 33306:3306
Then use that in your project Environment, try this for a complete yml.
If you want SQLite instead of MySQL you can try this