symfony / flex

Composer plugin for Symfony
MIT License
4.17k stars 183 forks source link

Renaming of docker-compose.yaml in compose.yaml : postgresql does'nt work anymore #1001

Closed sblondeau closed 1 year ago

sblondeau commented 1 year ago

Hello,

My issue comes appears after that commit https://github.com/symfony/flex/commit/46bebc3d097d1bb1dce04c5ba83658afd79988f9 where docker.compose.yaml has been renamed in compose.yaml

Since yesterday, when I install a new symfony project with --webapp, and then run a docker compose up, my postgresql container is created BUT when I try to use it (via a make:migration or a d:d:c in example) it crashed with this message

SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 5432 failed: Connection refused  
        Is the server running on that host and accepting TCP/IP connections?                           

After long search, I have finally found that if I rename the file compose.yaml with former name docker-compose.yaml, it works well. Maybe the problem comes from my docker compose configuration ? Do you have any idea? Many thanks for your help

nicolas-grekas commented 1 year ago

What does docker --version return for you?

sblondeau commented 1 year ago

Hello Nicolas, It returns 24.0.6

and docker compose version return v2.21.0

dunglas commented 1 year ago

Can you paste your compose.yaml file? Also, do you have any override file? If yes, does it follow the same convention?

sblondeau commented 1 year ago

Hello Kevin, My compose and compose.override have no modification, they are generated when I start my project

version: '3'

services:
###> doctrine/doctrine-bundle ###
  database:
    image: postgres:${POSTGRES_VERSION:-15}-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-app}
      # You should definitely change the password in production
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
      POSTGRES_USER: ${POSTGRES_USER:-app}
    volumes:
      - database_data:/var/lib/postgresql/data:rw
      # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/db/data:/var/lib/postgresql/data:rw
###< doctrine/doctrine-bundle ###

volumes:
###> doctrine/doctrine-bundle ###
  database_data:
###< doctrine/doctrine-bundle ###

and the override

version: '3'

services:
###> doctrine/doctrine-bundle ###
  database:
    ports:
      - "5432"
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
  mailer:
    image: schickling/mailcatcher
    ports: ["1025", "1080"]
###< symfony/mailer ###

As soon as I rename it in docker-compose.yaml, my postgre container works well :-)

wryk commented 1 year ago

I encountered the same database issue with symfony-cli local dev server. The cause was pretty clear when running symfony var:export --debug.

ERROR: unable to find a docker-compose.yaml or docker-compose.yml for the current directory
ERROR: unable to find a compose directory for the current directory

Renaming the files fixed the issue.

dunglas commented 1 year ago

Ok I think I got it, support for the new compose file convention probably needs to be added somewhere in Symfony CLI.

fabpot commented 1 year ago

@dunglas Sometimes like this? https://github.com/symfony-cli/symfony-cli/pull/364

fabpot commented 1 year ago

Symfony CLI v5.6.2 has been released with the fix.