Skip to content

Commit

Permalink
Drop Docker Compose V1 support, use V2 always
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanzante committed Apr 1, 2024
1 parent 26a8c96 commit 6fd271c
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/Composer/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ class Handler {
*/
protected $initializeGit;

/**
* Command to use to call the docker compose plugin.
*
* When it is V1 it thould be "docker-compose", for V2 is "docker compose".
*/
protected $dockerComposeCmd;

/**
* Handler constructor.
*
Expand Down Expand Up @@ -128,7 +121,6 @@ public function createProjectAssistant() {
$this->io->write('Launching assistant to configure the Drupal Boilerplate');
$project_name = $this->setConfFiles();
$theme_name = str_replace('-', '_', $project_name);
$this->setupDockerComposeCmd();
$this->setUpGit();
$this->startDocker($theme_name);
$this->initGrumPhp();
Expand All @@ -139,22 +131,13 @@ public function createProjectAssistant() {
return 0;
}

/**
* Determines the command to run docker compose plugin.
*/
protected function setupDockerComposeCmd() {

$this->dockerComposeCmd = trim(shell_exec("grep ^DOCKER_COMPOSE_CMD= .env.example | cut -f2 -d="));
$this->io->write('Using ' . $this->dockerComposeCmd . ' to run Docker Compose commands');
}

/**
* Runs a docker compose command.
*
* It makes sure the proper docker command is used.
*/
protected function runDockerComposeCmd(string $args) {
system($this->dockerComposeCmd . " " . $args);
system('docker compose ' . $args);
}

/**
Expand Down Expand Up @@ -307,7 +290,7 @@ protected function waitDatabase() {
$count = 10;
while ($count) {
$this->io->write('Waiting for database to be ready....');
$result = trim(shell_exec('. ./.env; ' . $this->dockerComposeCmd . ' exec -u root mariadb mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME} -e "SELECT 1234567890 AS result"| grep "1234567890" | wc -l'));
$result = trim(shell_exec('. ./.env; docker compose exec -u root mariadb mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME} -e "SELECT 1234567890 AS result"| grep "1234567890" | wc -l'));
if ($result === "1") {
$this->io->write('Database ready!');
return;
Expand Down Expand Up @@ -338,7 +321,7 @@ protected function createSubTheme(string $theme_name) {
* Assistant success message.
*/
protected function assistantSuccess(string $project_name) {
$port = shell_exec($this->dockerComposeCmd . ' port traefik 80 | cut -d: -f2');
$port = shell_exec('docker compose port traefik 80 | cut -d: -f2');

if ($this->initializeGit) {
system('git add .');
Expand Down

0 comments on commit 6fd271c

Please sign in to comment.