Skip to content

Commit 38647c5

Browse files
committed
Try fix docker cache sharing
1 parent 01703d4 commit 38647c5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/php-workshop.yml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- name: Install Dependencies
3030
run: composer update --prefer-dist
3131

32+
- name: Build docker image
33+
run: docker build -t php-workshop .
34+
3235
- name: Run phpunit tests
3336
run: |
3437
mkdir -p build/logs

src/Process/DockerProcessFactory.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function create(ProcessInput $processInput): Process
3131
$mounts = [];
3232
if ($processInput->getExecutable() === 'composer') {
3333
//we need to mount a volume for composer cache
34-
$mounts[] = $this->composerCacheDir . ':/root/.composer/cache';
34+
$mounts[] = $this->composerCacheDir . ':/tmp/composer';
3535
}
3636

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

43+
$env[] = '-e';
44+
$env[] = 'COMPOSER_HOME=/tmp/composer';
45+
4346
return new Process(
4447
[
4548
...$this->baseComposeCommand($mounts, $env),
@@ -48,7 +51,11 @@ public function create(ProcessInput $processInput): Process
4851
...$processInput->getArgs(),
4952
],
5053
$this->basePath,
51-
['SOLUTION' => $processInput->getWorkingDirectory()],
54+
[
55+
'SOLUTION' => $processInput->getWorkingDirectory(),
56+
'UID' => getmyuid(),
57+
'GID' => getmygid(),
58+
],
5259
$processInput->getInput(),
5360
10,
5461
);
@@ -74,6 +81,8 @@ private function baseComposeCommand(array $mounts, array $env): array
7481
'-f',
7582
'.docker/runtime/docker-compose.yml',
7683
'run',
84+
'--user',
85+
getmyuid() . ':' . getmygid(),
7786
'--rm',
7887
...$env,
7988
'-w',

0 commit comments

Comments
 (0)