Skip to content

Commit

Permalink
DockerContainers images migrated to Alpine ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph3nol committed Sep 13, 2017
1 parent 055988b commit 578fafe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
10 changes: 7 additions & 3 deletions src/Application/DockerContainer/MailcatcherDockerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ph3\DockerArch\Application\DockerContainerInflector;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface;
use Ph3\DockerArch\Domain\Service\Model\Service;
use Ph3\DockerArch\Domain\TemplatedFile\Model\TemplatedFile;

Expand All @@ -17,16 +18,19 @@ class MailcatcherDockerContainer extends DockerContainer
*/
public function init(): void
{
$this->setPackageManager(DockerContainerInterface::PACKAGE_MANAGER_TYPE_APK);

parent::init();

$this->setFrom('schickling/mailcatcher');
$this->setFrom('tophfr/mailcatcher');

// Ports.
$port = $this->addEnvPort('MAILCATCHER', ['from' => '8880', 'to' => '1080']);
$clientPort = $this->addEnvPort('MAILCATCHER_CLIENT', ['from' => '8880', 'to' => '80']);
$this->addEnvPort('MAILCATCHER_SMTP', ['from' => '8825', 'to' => '25']);

// UI.
$this->getService()->addUIAccess([
'port' => $port['from'],
'port' => $clientPort['from'],
'label' => 'MailCatcher Web Client',
]);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Application/DockerContainer/NodejsDockerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ph3\DockerArch\Application\DockerContainerInflector;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface;
use Ph3\DockerArch\Domain\Service\Model\Service;
use Ph3\DockerArch\Domain\TemplatedFile\Model\TemplatedFile;

Expand All @@ -17,12 +18,14 @@ class NodejsDockerContainer extends DockerContainer
*/
public function init(): void
{
$this->setPackageManager(DockerContainerInterface::PACKAGE_MANAGER_TYPE_APK);

parent::init();

$service = $this->getService();
$project = $service->getProject();

$this->setFrom(sprintf('node:%s', $service->getOptions()['version']));
$this->setFrom(sprintf('node:%s-alpine', $service->getOptions()['version']));

$this->applyWebServiceConfiguration();
$this->applyShellConfiguration();
Expand Down
17 changes: 10 additions & 7 deletions src/Application/DockerContainer/PhpDockerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ph3\DockerArch\Application\DockerContainerInflector;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainer;
use Ph3\DockerArch\Domain\DockerContainer\Model\DockerContainerInterface;
use Ph3\DockerArch\Domain\Service\Model\Service;
use Ph3\DockerArch\Domain\TemplatedFile\Model\TemplatedFile;

Expand All @@ -17,11 +18,13 @@ class PhpDockerContainer extends DockerContainer
*/
public function init(): void
{
$this->setPackageManager(DockerContainerInterface::PACKAGE_MANAGER_TYPE_APK);

parent::init();

$service = $this->getService();

$this->setFrom(sprintf('php:%s', $service->getOptions()['version']));
$this->setFrom(sprintf('php:%s-alpine', $service->getOptions()['version']));
$this->applyWebServiceConfiguration();
$this->applyShellConfiguration();

Expand All @@ -31,12 +34,6 @@ public function init(): void
}

// Packages.
if (true === in_array('mysql', $service->getOptions()['extensions']) ||
true === in_array('pdo_mysql', $service->getOptions()['extensions'])) {
$this
->addPackage('libmcrypt-dev')
->addPackage('mysql-client');
}
if (true === $service->getOptions()['composer']) {
$this
->addPackage('zip')
Expand Down Expand Up @@ -85,6 +82,12 @@ private function addOwnCommands(): void
->addPackage('libmcrypt-dev')
->addPackage('mysql-client');
}
if (true === in_array('intl', $extensions)) {
$this
->addPackage('icu')
->addPackage('icu-libs')
->addPackage('icu-dev');
}
foreach (array_unique($extensions) as $extension) {
$this->addCommand('docker-php-ext-install '.$extension);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Service/PhpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getOptionsResolver(): Options
$resolver->setAllowedTypes('version', 'string');
$resolver->setAllowedValues('version', ['5.6', '7.0', '7.1', '7.2']);
$resolver->setNormalizer('version', function (Options $options, $value) {
$dockerVersionSuffix = (true === $options['cli_only']) ? '-cli' : '-fpm';
$dockerVersionSuffix = (false === $options['cli_only']) ? '-fpm' : '';

return $value.$dockerVersionSuffix;
});
Expand Down
5 changes: 2 additions & 3 deletions src/Domain/DockerContainer/Model/DockerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,9 @@ protected function applyShellConfiguration(): void
if (true === $this->getService()->getOptions()['zsh']) {
$this
->addPackage('zsh')
->addCommand('echo "\nsource ~/.shell.config" > ~/.zshrc')
->addCommand('chsh -s /bin/zsh');
->addCommand('echo "source ~/.shell.config" >> ~/.zshrc');
} else {
$this->addCommand('echo "\nsource ~/.shell.config" > ~/.bashrc');
$this->addCommand('echo "source ~/.shell.config" >> ~/.bashrc');
}
if (true === $this->getService()->getOptions()['zsh'] &&
true === $this->getService()->getOptions()['custom_zsh']) {
Expand Down

0 comments on commit 578fafe

Please sign in to comment.