Skip to content

Improve installation script #10

Description

@nicolashuber

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions