Skip to content

Commit

Permalink
Docker file updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fordnox committed Jul 13, 2022
1 parent f103978 commit 6dda3e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ exec-db: ## Enter DB container shell
$(DOCKER_DB_CONTAINER_EXEC) bash

install: start ## Install app after start
$(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --no-suggest --prefer-dist --no-dev
$(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --prefer-dist --no-dev
$(DOCKER_PHP_CONTAINER_EXEC) $(DOCKER_PHP_EXECUTABLE_CMD) ./bin/prepare.php

reinstall: ## Reinstall app
rm -rf ./src/bb-config.php
Expand Down
8 changes: 4 additions & 4 deletions bin/prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$dbname = $config['db']['name'];
$user = $config['db']['user'];
$password = $config['db']['password'];
$port = $config['db']['port'];
$port = isset($config['db']['port']) ? $config['db']['port'] : 3306;


echo sprintf("Connecting to database %s@%s/%s", $user, $host, $dbname) . PHP_EOL;
Expand All @@ -36,7 +36,7 @@
$connected = true;
} catch (Exception $e) {
$message = $e->getMessage();
$message = "SQLSTATE[HY000] [2002] Connection refused in /var/www/html/bin/prepare.php:23";

if(strpos($e->getMessage(), "Connection refused") !== false) {
sleep(1); // mysql container might still not be up, lets wait
$iter--;
Expand Down Expand Up @@ -74,7 +74,7 @@
exit;
}

echo sprintf("Create SQL database structure from file %s", $structureSql) . PHP_EOL;
echo sprintf("Create SQL database structure from file %s", $pathAppInstall . $structureSql) . PHP_EOL;
$sql = file_get_contents($pathAppInstall . $structureSql);
$dbh->exec($sql);
$error = $dbh->errorInfo();
Expand All @@ -83,7 +83,7 @@
exit;
}

echo sprintf("Import content to database from file %s", $contentSql) . PHP_EOL;
echo sprintf("Import content to database from file %s", $pathAppInstall . $contentSql) . PHP_EOL;
$sql = file_get_contents($pathAppInstall . $contentSql);
$stmt = $dbh->prepare($sql);
$stmt->execute();
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
- 80:80
networks:
backend:
depends_on:
- php
php:
image: chialab/php:8.0-fpm
volumes:
Expand All @@ -24,11 +26,11 @@ services:
- database
restart: always
database:
image: mysql:5
image: mariadb
ports:
- 3306:3306
- 6033:3306
environment:
MYSQL_ROOT_PASSWORD: root
MARIADB_ROOT_PASSWORD: root
networks:
backend:
restart: always
Expand Down

0 comments on commit 6dda3e6

Please sign in to comment.