From d2b9163537a3cddd143eab5677d1e6eb8e8bdcce Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Wed, 8 Aug 2018 15:58:55 -0600 Subject: [PATCH 1/2] [add] Configuring the mysql port --- api-payroll/src/dependencies.php | 4 ++-- database/Dockerfile | 4 ++++ database/my.cnf | 20 ++++++++++++++++++++ docker-compose.yml | 4 +++- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 database/my.cnf diff --git a/api-payroll/src/dependencies.php b/api-payroll/src/dependencies.php index 1075e7b..43f4e17 100644 --- a/api-payroll/src/dependencies.php +++ b/api-payroll/src/dependencies.php @@ -34,7 +34,7 @@ $container['mysql'] = function ($c) { $databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage']; // Initiate the connection - $dsn = "mysql:host=$host;dbname=$database;charset=$charset"; + $dsn = "mysql:host=$host;port=3307;dbname=$database;charset=$charset"; try { $pdo = new PDO($dsn, $user, $password, $pdoConnectionOptions); } catch (Exception $e) { @@ -69,4 +69,4 @@ $container['employeeApplication'] = function ($c) { $employeeApplication = new App\Application\EmployeeApplication($employeeSettings, $c['mysql'], $c['cryptographyService'], $c['asserts']); return $employeeApplication; -}; \ No newline at end of file +}; diff --git a/database/Dockerfile b/database/Dockerfile index c96c19f..3ae2814 100644 --- a/database/Dockerfile +++ b/database/Dockerfile @@ -1,3 +1,7 @@ FROM mysql:5.7 +# Starting scripts ADD . /docker-entrypoint-initdb.d + +# Config +ADD my.cnf /etc/mysql diff --git a/database/my.cnf b/database/my.cnf new file mode 100644 index 0000000..f17921d --- /dev/null +++ b/database/my.cnf @@ -0,0 +1,20 @@ +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +[mysqld] +port = 3307 + +!includedir /etc/mysql/conf.d/ +!includedir /etc/mysql/mysql.conf.d/ diff --git a/docker-compose.yml b/docker-compose.yml index 5d802d7..eb9029a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,10 @@ services: container_name: payroll_mysql restart: always build: database + expose: + - "3307" ports: - - "3306:3306" + - "3307:3307" volumes: - my-datavolume:/var/lib/mysql environment: From f16e9fe72c6f49b6802e9680d1ca2c382fa1956c Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Wed, 8 Aug 2018 16:15:45 -0600 Subject: [PATCH 2/2] [add] Parametrizing --- api-payroll/src/dependencies.php | 3 ++- api-payroll/src/settings.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api-payroll/src/dependencies.php b/api-payroll/src/dependencies.php index 43f4e17..b4246de 100644 --- a/api-payroll/src/dependencies.php +++ b/api-payroll/src/dependencies.php @@ -24,6 +24,7 @@ $container['mysql'] = function ($c) { // The database parameters $host = $mysqlSettings['host']; + $port = $mysqlSettings['port']; $database = $mysqlSettings['database']; $user = $mysqlSettings['user']; $password = $mysqlSettings['password']; @@ -34,7 +35,7 @@ $container['mysql'] = function ($c) { $databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage']; // Initiate the connection - $dsn = "mysql:host=$host;port=3307;dbname=$database;charset=$charset"; + $dsn = "mysql:host=$host;port=$port;dbname=$database;charset=$charset"; try { $pdo = new PDO($dsn, $user, $password, $pdoConnectionOptions); } catch (Exception $e) { diff --git a/api-payroll/src/settings.php b/api-payroll/src/settings.php index af5995f..74394c6 100644 --- a/api-payroll/src/settings.php +++ b/api-payroll/src/settings.php @@ -27,6 +27,7 @@ return [ // Datanase settings 'mysql' => [ 'host' => 'mysql', + 'port' => '3307', 'database' => 'payroll', 'user' => 'root', 'password' => '12345678',