mglaman / commerce-project-template

[EXPERIMENT] a Drupal Commerce 2 project template, with Behat + PHPUnit.
GNU General Public License v2.0
14 stars 2 forks source link

Can't connect to database #2

Open sakonn opened 7 years ago

sakonn commented 7 years ago

Hello and thanks again, I am moving forward in getting this working but now I run into the issue that drupal can not be installed because it can't connect to database. The mysql container is running but drush/drupal throws only error at every attempt.

Thanks again

mglaman commented 7 years ago

The settings.local.php is set up to use the Docker Compose YAML provided. You can manually edit or do the following if you use Docker

docker-compose -f docker-compose.yml.dist build
docker-compose -f docker-compose.yml.dist pull
docker-compose -p commerce2 -f docker-compose.yml.dist up -d

or run ./scripts/docker-up.sh

sakonn commented 7 years ago

Thanks for the fast reply. I use this file to start docker container but it throw error anyway.

mglaman commented 7 years ago

Can you run drush status and see what comes back? Basically in settings.local.php it tries to get the running container's port.

Andddd I just thought of this: if *.dev TLD doesn't resolve to local host, it'll fail https://github.com/mglaman/commerce-project-template/blob/master/web/sites/default/settings.local.php#L29

mglaman commented 7 years ago

I should just update the project to use localhost for domain.

sakonn commented 7 years ago

When I run status it return this: Drupal version : 8.2.7 Site URI : http://default
Database driver : mysql
Database hostname : commerce2.dev
Database port : 32768
Database username : mysql
Database name : data
PHP executable : /usr/bin/php
PHP configuration : /etc/php/7.0/cli/php.ini
PHP OS : Linux
Drush script : /home/jakub/Projects/commerce/vendor/drush/drush/drush.php Drush version : 8.0.5
Drush temp directory : /tmp
Drush configuration :
Drush alias files : Drupal root : /home/jakub/Projects/commerce/web Drupal Settings File : sites/default/settings.php Site path : sites/default Sync config path : ../config/sync

Drush seems to work until I try to read or write something to database. Docker ps return this: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3162f27c69c9 nginx:1.9.0 "nginx -g 'daemon ..." 12 minutes ago Up 12 minutes 0.0.0.0:80->80/tcp, 443/tcp commerce2_nginx_1 5ad9a8554a41 mglaman/docker-php-bcmath:7.0-fpm "docker-php-entryp..." 12 minutes ago Up 12 minutes 9000/tcp commerce2_phpfpm_1 b3eec9f001d7 mariadb "docker-entrypoint..." 12 minutes ago Up 12 minutes 0.0.0.0:32768->3306/tcp commerce2_mariadb_1 8700d57a6804 mailhog/mailhog "MailHog" 12 minutes ago Up 12 minutes 1025/tcp, 0.0.0.0:32769->8025/tcp commerce2_mailhog_1

So I do not know if it is supposed to seems like this. I this that problem is somewhere in the configuration of database container.

mglaman commented 7 years ago

What happens if you run curl http://commerce2.dev, I think the issue is the domain name resolution.

sakonn commented 7 years ago

Command throw this: The website encountered an unexpected error. Please try again later.

Symfony\Component\HttpKernel\Exception\NotFoundHttpException: in Drupal\Core\PathProcessor\PathProcessorFront->processInbound() (line 43 of core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php).

When I tried curl to 127.0.53.53 it show only this: The provided host name is not valid for this server.

And the curl to 127.0.53.53:32771 this: 5.5.5-10.1.22-MariaDB-1~jessis&_0lS9d�?�lqsnNz?gi[k(mysql_native_password!��#08S01Got packets out of order

mglaman commented 7 years ago

@sakonn sorry for delay. Been busy prepping for MidCamp. Those errors are Drupal ones when there's no site installed. I'll work on an update to remove hostname

sakonn commented 7 years ago

It is OK. Let me know if you figure out where is the problem. I would be glad to help at least with testing.