Skip to content

Commit

Permalink
Try fix docker cache sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed May 25, 2024
1 parent 01703d4 commit 38647c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/php-workshop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Install Dependencies
run: composer update --prefer-dist

- name: Build docker image
run: docker build -t php-workshop .

- name: Run phpunit tests
run: |
mkdir -p build/logs
Expand Down
13 changes: 11 additions & 2 deletions src/Process/DockerProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function create(ProcessInput $processInput): Process
$mounts = [];
if ($processInput->getExecutable() === 'composer') {
//we need to mount a volume for composer cache
$mounts[] = $this->composerCacheDir . ':/root/.composer/cache';
$mounts[] = $this->composerCacheDir . ':/tmp/composer';
}

$env = [];
Expand All @@ -40,6 +40,9 @@ public function create(ProcessInput $processInput): Process
$env[] = $key . '=' . $value;
}

$env[] = '-e';
$env[] = 'COMPOSER_HOME=/tmp/composer';

return new Process(
[
...$this->baseComposeCommand($mounts, $env),
Expand All @@ -48,7 +51,11 @@ public function create(ProcessInput $processInput): Process
...$processInput->getArgs(),
],
$this->basePath,
['SOLUTION' => $processInput->getWorkingDirectory()],
[
'SOLUTION' => $processInput->getWorkingDirectory(),
'UID' => getmyuid(),
'GID' => getmygid(),
],
$processInput->getInput(),
10,
);
Expand All @@ -74,6 +81,8 @@ private function baseComposeCommand(array $mounts, array $env): array
'-f',
'.docker/runtime/docker-compose.yml',
'run',
'--user',
getmyuid() . ':' . getmygid(),
'--rm',
...$env,
'-w',
Expand Down

0 comments on commit 38647c5

Please sign in to comment.