Hello,
I have a monolithic repository which is compound of two Symfony application, one uses a Postgresql database, the other one uses Mysql.
When I tried to setup databases schema through steps
, it’ works for the Postgresql, but it didn’t work for Mysql, I got the error An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or dir ectory
, I conclude that my php image couldn’t connect to the mysql server.
This is my config.yml
version: 2
jobs:
build:
working_directory: /app/acme
docker:
- image: studapart/php
environment:
SYMFONY_ENV: test
SYMFONY_DEBUG: false
POSTGRESQL_ADDON_HOST: localhost
POSTGRESQL_ADDON_DB: studapart_test
POSTGRESQL_ADDON_USER: studapart
POSTGRESQL_ADDON_PORT: 5432
MYSQL_ADDON_HOST: localhost
MYSQL_ADDON_PORT: 3306
MYSQL_ADDON_DB: pro_test
MYSQL_ADDON_USER: studapart
MYSQL_ADDON_PASSWORD: studapartpwd
BEHAT_SCREENSHOT_DIR: /tmp/behat/screenshots
- image: circleci/postgres:9.5.6-alpine
environment:
PGDATA: /dev/shm/pgdata/data
POSTGRES_USER: studapart
POSTGRES_DB: studapart_test
POSTGRES_PASSWORD: studapartpwd
- image: circleci/mysql:5.6
environment:
MYSQL_PORT: 3306
MYSQL_USER: studapart
MYSQL_DATABASE: pro_test
MYSQL_PASSWORD: studapartpwd
...
steps:
...
- run:
name: Install db
command: |
cd back # The application using Postgresql
bin/console doctrine:database:create -n --if-not-exists # No problem
bin/console doctrine:schema:drop --force --full-database -vvv # No problem
bin/console doc:mig:mig --no-interaction # No problem
cd ../pro # The application using Mysql
bin/console doctrine:database:create -n --if-not-exists # Error : No such file or directory
bin/console doctrine:schema:drop --force --full-database -vvv
cat codeigniter/fixtures/schema.sql | docker exec -i acme_mysql_1 mysql --user=studapart --password=studapartpwd pro_test
bin/console doc:mig:mig --no-interaction