Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Commit

Permalink
drocker.phar: boot2docker configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Mainardi committed Dec 30, 2014
1 parent 87a49c4 commit 65931a1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
47 changes: 41 additions & 6 deletions DrockerRoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@
class RoboFile extends \Robo\Tasks
{
/**
* Init drocker project.
* Get internal base path.
*/
public function init()
{
$this->yell("Drocker init.");
private function getBasePath() {
$base_path = __DIR__;
$phar = FALSE;
if (strpos(__FILE__, 'phar://') !== FALSE) {
$base_path = 'phar://drocker.phar';
$phar = TRUE;
}
return $base_path;
}

/**
* Init drocker project.
*/
public function init()
{
$this->yell("Drocker init.");
$base_path = $this->getBasePath();

// Create directory structure.
$this->taskFileSystemStack()
->mkdir('data')
Expand All @@ -44,4 +51,32 @@ public function init()
->to($gid)
->run();
}

/**
* Reconfigure boot2docker cpu/memory.
*/
public function boot2dockerOptimize($opts = ['cpu' => '1', 'memory' => '8192']) {
$memory = $opts['memory'];
$cpu = $opts['cpu'];
$this->taskExecStack()
->stopOnFail(TRUE)
->exec('boot2docker stop')
->exec('VBoxManage modifyvm "boot2docker-vm" --memory ' . $memory . ' --cpus ' . $cpu)
->exec('boot2docker up')
->run();
}

/**
* Configure NFS mount boot script.
*/
public function boot2dockerNfsSetup() {
$base_path = $this->getBasePath();
$mount_boot_script = file_get_contents($base_path . '/src/scripts/boot2local.sh');
$this->taskExecStack()
->stopOnFail(TRUE)
->exec('boot2docker ssh "sudo rm /var/lib/boot2docker/bootlocal.sh && sudo touch /var/lib/boot2docker/bootlocal.sh"')
->exec('boot2docker ssh "echo \'' . $mount_boot_script . '\' | sudo tee -a /var/lib/boot2docker/bootlocal.sh" >/dev/null')
->exec('boot2docker restart')
->run();
}
}
5 changes: 5 additions & 0 deletions Robofile.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ public function pharBuild() {

// Add drocker binary and make it as executable.
$packer->addFile('DrockerRoboFile.php', 'DrockerRoboFile.php');
// Add fig.yml.
$packer->addFile('fig.yml.dist', 'fig.yml.dist');

// Add boot2local.sh script.
$packer->addFile('src/scripts/boot2local.sh', 'src/scripts/boot2local.sh');

$packer->addFile('drocker', 'drocker')
->executable('drocker')
->run();
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/boot2local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#|/bin/bash
sudo umount /Users
sudo /usr/local/etc/init.d/nfs-client start
sudo mount 192.168.59.3:/Users /Users -o rw,async,noatime,rsize=32768,wsize=32768,proto=tcp

0 comments on commit 65931a1

Please sign in to comment.