Merge pull request #353 from crazy-max/fix-docker-install-linux
docker(install): add tooldir to path for linux and windows
This commit is contained in:
@@ -19,6 +19,7 @@ import {jest, describe, expect, test, beforeEach, afterEach} from '@jest/globals
|
|||||||
|
|
||||||
import {Install} from '../../src/docker/install';
|
import {Install} from '../../src/docker/install';
|
||||||
import {Docker} from '../../src/docker/docker';
|
import {Docker} from '../../src/docker/docker';
|
||||||
|
import {Exec} from '../../src/exec';
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
|
const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest');
|
||||||
@@ -38,8 +39,19 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
|
|||||||
process.env = originalEnv;
|
process.env = originalEnv;
|
||||||
});
|
});
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each(['v24.0.4'])(
|
test.each(['v26.1.4'])(
|
||||||
'install docker %s', async (version) => {
|
'install docker %s', async (version) => {
|
||||||
|
if (process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) {
|
||||||
|
// Remove containerd first on ubuntu runners to make sure it takes
|
||||||
|
// ones packaged with docker
|
||||||
|
await Exec.exec('sudo', ['apt-get', 'remove', '-y', 'containerd.io'], {
|
||||||
|
env: Object.assign({}, process.env, {
|
||||||
|
DEBIAN_FRONTEND: 'noninteractive'
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
await expect((async () => {
|
await expect((async () => {
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
version: version,
|
version: version,
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ if (Get-Service docker -ErrorAction SilentlyContinue) {
|
|||||||
Write-Host "Service removed"
|
Write-Host "Service removed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$env:Path = "$ToolDir;" + [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
||||||
|
Write-Host "Path: $env:Path"
|
||||||
|
|
||||||
$env:DOCKER_HOST = $DockerHost
|
$env:DOCKER_HOST = $DockerHost
|
||||||
Write-Host "DOCKER_HOST: $env:DOCKER_HOST"
|
Write-Host "DOCKER_HOST: $env:DOCKER_HOST"
|
||||||
|
|
||||||
|
|||||||
@@ -253,6 +253,12 @@ export class Install {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const envs = Object.assign({}, process.env, {
|
||||||
|
PATH: `${this.toolDir}:${process.env.PATH}`
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
|
||||||
await core.group('Start Docker daemon', async () => {
|
await core.group('Start Docker daemon', async () => {
|
||||||
const bashPath: string = await io.which('bash', true);
|
const bashPath: string = await io.which('bash', true);
|
||||||
const cmd = `${this.toolDir}/dockerd --host="${dockerHost}" --config-file="${daemonConfigPath}" --exec-root="${this.runDir}/execroot" --data-root="${this.runDir}/data" --pidfile="${this.runDir}/docker.pid" --userland-proxy=false`;
|
const cmd = `${this.toolDir}/dockerd --host="${dockerHost}" --config-file="${daemonConfigPath}" --exec-root="${this.runDir}/execroot" --data-root="${this.runDir}/data" --pidfile="${this.runDir}/docker.pid" --userland-proxy=false`;
|
||||||
@@ -262,11 +268,12 @@ export class Install {
|
|||||||
// avoid killing it when the action finishes running. Even if detached,
|
// avoid killing it when the action finishes running. Even if detached,
|
||||||
// we also need to run dockerd in a subshell and unref the process so
|
// we also need to run dockerd in a subshell and unref the process so
|
||||||
// GitHub Action doesn't wait for it to finish.
|
// GitHub Action doesn't wait for it to finish.
|
||||||
`sudo -E ${bashPath} << EOF
|
`sudo env "PATH=$PATH" ${bashPath} << EOF
|
||||||
( ${cmd} 2>&1 | tee "${this.runDir}/dockerd.log" ) &
|
( ${cmd} 2>&1 | tee "${this.runDir}/dockerd.log" ) &
|
||||||
EOF`,
|
EOF`,
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
|
env: envs,
|
||||||
detached: true,
|
detached: true,
|
||||||
shell: true,
|
shell: true,
|
||||||
stdio: ['ignore', process.stdout, process.stderr]
|
stdio: ['ignore', process.stdout, process.stderr]
|
||||||
@@ -280,7 +287,7 @@ EOF`,
|
|||||||
try {
|
try {
|
||||||
await Exec.getExecOutput(`docker version`, undefined, {
|
await Exec.getExecOutput(`docker version`, undefined, {
|
||||||
silent: true,
|
silent: true,
|
||||||
env: Object.assign({}, process.env, {
|
env: Object.assign({}, envs, {
|
||||||
DOCKER_HOST: dockerHost
|
DOCKER_HOST: dockerHost
|
||||||
}) as {
|
}) as {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user