Today the installation process is written on bash script. It's difficult to maintain a complex script, it would be interesting to find a way to use a more modern programming language to run the installation.
I suggest use the The Console Component from Symfony. With a PHP we can create a more robust script. But on the one hand, PHP becomes a prerequisite together with Docker.
The great challenge is that the script should orchestrate all related containers. With this in mind, I thing the script must call the exec PHP function and call docke-compose.
To abstract we could have the following classes:
Docker.php:
<?php
namespace App\Docker;
class Docker {
public function up($service, $args = null) {
return exec('docker-compose -d up ' . $service . ' ' . $args . ' 2>&1');
}
public function run($service, $args = null) {
return exec('docker-compose run --rm ' . $service . ' ' . $args . ' 2>&1');
}
public function pull() {
return exec('docker-compose pull 2>&1');
}
public function build() {
return exec('docker-compose build 2>&1');
}
}
Yarn.php:
<?php
namespace App\Docker;
class Yarn extends Docker {
public function install() {
return $this->run('node', 'yarn');
}
}
Another approach would be to use access the Docker Engine API, like the reactphp-docker library.
Today the installation process is written on bash script. It's difficult to maintain a complex script, it would be interesting to find a way to use a more modern programming language to run the installation.
I suggest use the The Console Component from Symfony. With a PHP we can create a more robust script. But on the one hand, PHP becomes a prerequisite together with Docker.
The great challenge is that the script should orchestrate all related containers. With this in mind, I thing the script must call the
execPHP function and call docke-compose.To abstract we could have the following classes:
Docker.php:
Yarn.php:
Another approach would be to use access the Docker Engine API, like the reactphp-docker library.