mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
Merge pull request #486 from vvoland/docker-install-rootless2
docker/install: Fix rootless install, make teardown also cleanup the toolDir
This commit is contained in:
commit
781874f7fa
@ -23,7 +23,7 @@ import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docke
|
|||||||
import {Docker} from '../../src/docker/docker';
|
import {Docker} from '../../src/docker/docker';
|
||||||
import {Exec} from '../../src/exec';
|
import {Exec} from '../../src/exec';
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
|
const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
|
||||||
|
|
||||||
describe('install', () => {
|
describe('install', () => {
|
||||||
const originalEnv = process.env;
|
const originalEnv = process.env;
|
||||||
@ -51,7 +51,7 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
|
|||||||
await ensureNoSystemContainerd();
|
await ensureNoSystemContainerd();
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
source: source,
|
source: source,
|
||||||
runDir: tmpDir,
|
runDir: tmpDir(),
|
||||||
contextName: 'foo',
|
contextName: 'foo',
|
||||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
|
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
|
||||||
});
|
});
|
||||||
@ -74,7 +74,7 @@ describe('rootless', () => {
|
|||||||
await ensureNoSystemContainerd();
|
await ensureNoSystemContainerd();
|
||||||
const install = new Install({
|
const install = new Install({
|
||||||
source: source,
|
source: source,
|
||||||
runDir: tmpDir,
|
runDir: tmpDir(),
|
||||||
contextName: 'foo',
|
contextName: 'foo',
|
||||||
daemonConfig: `{"debug":true}`,
|
daemonConfig: `{"debug":true}`,
|
||||||
rootless: true
|
rootless: true
|
||||||
|
@ -170,7 +170,11 @@ export class Install {
|
|||||||
if (this.rootless) {
|
if (this.rootless) {
|
||||||
core.info(`Downloading Docker rootless extras ${version} from ${this.source.channel} at download.docker.com`);
|
core.info(`Downloading Docker rootless extras ${version} from ${this.source.channel} at download.docker.com`);
|
||||||
const extrasFolder = await this.downloadStaticArchive('docker-rootless-extras', this.source);
|
const extrasFolder = await this.downloadStaticArchive('docker-rootless-extras', this.source);
|
||||||
fs.copyFileSync(path.join(extrasFolder, 'dockerd-rootless.sh'), path.join(extractFolder, 'dockerd-rootless.sh'));
|
fs.readdirSync(extrasFolder).forEach(file => {
|
||||||
|
const src = path.join(extrasFolder, file);
|
||||||
|
const dest = path.join(extractFolder, file);
|
||||||
|
fs.copyFileSync(src, dest);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -492,6 +496,13 @@ EOF`,
|
|||||||
throw new Error(`Unsupported platform: ${os.platform()}`);
|
throw new Error(`Unsupported platform: ${os.platform()}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await core.group(`Cleaning up toolDir`, async () => {
|
||||||
|
if (!this._toolDir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fs.rmSync(this._toolDir, {recursive: true, force: true});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async tearDownDarwin(): Promise<void> {
|
private async tearDownDarwin(): Promise<void> {
|
||||||
@ -541,6 +552,9 @@ EOF`,
|
|||||||
await core.group('Removing Docker context', async () => {
|
await core.group('Removing Docker context', async () => {
|
||||||
await Docker.exec(['context', 'rm', '-f', this.contextName]);
|
await Docker.exec(['context', 'rm', '-f', this.contextName]);
|
||||||
});
|
});
|
||||||
|
await core.group('Stopping Docker daemon service', async () => {
|
||||||
|
await Exec.exec('powershell', ['-Command', `Stop-Service -Name docker -Force`]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private downloadURL(component: 'docker' | 'docker-rootless-extras', version: string, channel: string): string {
|
private downloadURL(component: 'docker' | 'docker-rootless-extras', version: string, channel: string): string {
|
||||||
|
Loading…
Reference in New Issue
Block a user