When run GITLAB CI then error migrate laravel with service mysql 5.7 - laravel

enter image description here
Please help me. When gitlab CI instance run then error migrate of laravel , can't connect host mysql
enter image description here

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.

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

Related

Is it possible to rename the db host name?

I've got an odd use case where I'm adding DDEV to a project, but for reasons I'd like the db host to be 'mysql' instead of 'db'.
Is this possible?
Try this .ddev/docker-compose.hostname.yaml:
services:
db:
hostname: mysql

supabase cannot connect to database

I've done a fresh install of Supabase via docker compose following this example into my Ubuntu 20.04 server. When I run docker-compose up everything works except I see this error in my logs:
supabase-rest | 21/Feb/2022:19:50:29 +0000: {"details":"could not translate host name \"l#db\" to address: Name does not resolve\n","code":"","message":"Database connection error. Retrying the connection."}
How do I fix this?
Looking at this section in the docker-compose.yml:
rest:
container_name: supabase-rest
image: postgrest/postgrest:v9.0.0
depends_on:
- db
restart: unless-stopped
environment:
PGRST_DB_URI: postgres://postgres:${POSTGRES_PASSWORD}#db:5432/postgres
It's possible that the password you used in .env is not being escaped correctly - does it contain special chars?
Note that they need to be URI encoded if so as per: How to handle special characters in the password of a Postgresql URL connection string?

Unable to connect to a running Laravel Sail Docker project with TablePlus (role does not exist)

I created a new Laravel project and installed Sail with composer require laravel/sail --dev followed by php artisan sail:install and sail up to get the project up and running in Docker.
By doing these actions my .env file changed from
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_docker
DB_USERNAME=root
DB_PASSWORD=
to
DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=laravel_docker
DB_USERNAME=sail
DB_PASSWORD=password
And now I got two running Docker containers:
laravel-docker_laravel.test_1
laravel-docker_pgsql_1
I'm able to run the basic user migration with sail artisan migrate.
Next up I want to connect Tableplus (or Postico) with my Postgresql database running in Docker. Therefore I filled in the following information:
When trying to connect I got ERROR FATAL: role "sail" does not exist.
Can someone help me out?
Edit 1: Adding a screenshot from some terminal commands. I can connect to the database in the docker container, see a list of the tables and get a table with all the rows from the users table (inserted with a seeder using Laravel Sail)
Edit 2: docker-compose ps
Thanks to this post I found a working solution.
Changing to a different port in the docker-compose.yml file fixed the issue.
Before:
pgsql:
image: 'postgres:13'
ports:
- '${FORWARD_DB_PORT:-5432}:5432'
After:
pgsql:
image: 'postgres:13'
ports:
- '${FORWARD_DB_PORT:-5632}:5432'
After changing the port number to 5632 in TablePlus I'm able to connect to the database.
I have the same problem "role "sail" does not exist". In this case we need to use command ./vendor/bin/sail down -v to delete the existing Docker volume data. After that you can do ./vendor/bin/sail up command.

Laravel Sail & Docker Adding Additional Sites (Multi Project)

It is now recommended to use Sail & Docker with Laravel 8
Now I use homestead, but I wanted to upgrade my system to the latest version 8 and I did the setup before I installed the Docker Desktop and Sail http: // localhost everything works, however nodejs npm and mysql redis are ready for everything
The topic I want to learn is sail & docker, how does multiple projects work in this structure?
For example Homestead before working on this config
- map: homestead.test
to: /home/vagrant/project1/public
- map: another.test
to: /home/vagrant/project2/public
Thanks
You need to change the ports (MySQL, Redis, MailHog etc.) if you want to run multiple projects at the same time.
Application, MySQL, and Redis Ports
Add the desired ports to the .env file:
APP_PORT=81
FORWARD_DB_PORT=3307
FORWARD_REDIS_PORT=6380
MailHog Ports
Update MailHog ports in the docker-compose.yml file. Change these lines:
ports:
- 1025:1025
- 8025:8025
to this:
ports:
- 1026:1025
- 8026:8025
Once the containers have been started, you can access your application at http://localhost:81 and the MailHog web interface at http://localhost:8026.
Yes. You have to change to all non-conflict ports for all Laravel Sail project.
If you want to use custom domain like what you did in Homestead,
you can use the Nginx Proxy to achieve Multiple Project just like Homestead
Here is my article: step-by-step tutorial you can follow with....

Docker Oracle Database - can't overwrite ENV variables for credentials

I would like to configure an Oracle database on a server. For that, I am using this image from DockerHub:
https://hub.docker.com/r/sath89/oracle-12c/
Having included the image in a docker-compose.yml file, I am having trouble with overwriting the default credentials for accessing the database (the username is system while the password is oracle). This is how my docker-compose.yml file looks like:
version: '3.5'
services:
oracle12c-db:
image: sath89/oracle-12c
restart: always # restart policy
ports:
- 1521:1521
environment:
- USER=myusername
- PASS=mypass
- HOST=oracle-database
- PORT=1521
- ORACLE_SID=XE
- HTTP_PORT=8080
After successfully executing the command docker-compose up, I am still not able to access the database with the new credentials (only with the default ones). Is my docker-compose file syntactically correct or am I missing out something else here? Thanks in advance for your help!
I don't you can modify this at run time particularly easily.
Option 1 is to create your own Dockerfile based on theirs and pass in the user and password at build time (or hard code it to something else)
Option 2 is to modify their entrypoint and run the appropriate Oracle commands at startup to change the user/password

Resources