Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 31f7935

Browse files
author
Sven Speckmaier
committed
added command, set work directory for image
1 parent 3178307 commit 31f7935

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

plugin/PhpCliBlueprint/PhpCliBlueprint.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*/
2929
class PhpCliBlueprint implements Blueprint {
3030

31+
private $targetDirectory = '/var/cli/app';
32+
3133
/**
3234
* Provider $this->getFlag('dev', false) to detect `rancherize init php-cli --dev` in init.
3335
*/
@@ -178,13 +180,13 @@ protected function makeDockerfile(Configuration $config):Dockerfile {
178180
$baseimage = $config->get('docker.base-image', 'php:7.0-alpine');
179181
$dockerfile->setFrom($baseimage);
180182

181-
$dockerfile->addVolume('/var/www/app');
183+
$dockerfile->addVolume( $this->targetDirectory );
182184

183-
$dockerfile->setWorkdir('/var/www/app');
185+
$dockerfile->setWorkdir( $this->targetDirectory );
184186

185187
$copySuffix = $config->get('work-sub-directory', '');
186188
$targetSuffix = $config->get('target-sub-directory', '');
187-
$dockerfile->copy('.'.$copySuffix, '/var/www/app'.$targetSuffix);
189+
$dockerfile->copy('.'.$copySuffix, $this->targetDirectory .$targetSuffix);
188190

189191
if ($config->get('add-composer', false)) {
190192
$dockerfile->run('php -r "copy(\'https://getcomposer.org/installer\', \'composer-setup.php\');" \
@@ -206,9 +208,7 @@ protected function makeDockerfile(Configuration $config):Dockerfile {
206208
$dockerfile->addVolume($path);
207209
}
208210
}
209-
$dockerfile->run('rm -Rf /var/www/app/.rancherize');
210-
211-
$dockerfile->setCommand('php '.$config->get('command', '-i'));
211+
$dockerfile->run('rm -Rf '.$this->targetDirectory.'/.rancherize');
212212

213213

214214
return $dockerfile;
@@ -238,10 +238,15 @@ protected function makeServerService(Configuration $config, Configuration $defau
238238
$targetSuffix = $config->get('target-sub-directory', '');
239239

240240
$hostDirectory = getcwd() . $mountSuffix;
241-
$containerDirectory = '/var/www/app' . $targetSuffix;
241+
$containerDirectory = $this->targetDirectory . $targetSuffix;
242242
$serverService->addVolume($hostDirectory, $containerDirectory);
243243
}
244244

245+
$command = 'php ' . $config->get( 'command', '-i' );
246+
$serverService->setCommand($command);
247+
$serverService->setRestart( Service::RESTART_START_ONCE );
248+
$serverService->setWorkDir( $this->targetDirectory );
249+
245250
$persistentDriver = $config->get('docker.persistent-driver', 'pxd');
246251
$persistentOptions = $config->get('docker.persistent-options', [
247252
'repl' => '3',

0 commit comments

Comments
 (0)