mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
docker: detach dockerd for linux install
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
3c2fe5ddb2
commit
ac9d9d9a1b
@ -11,9 +11,9 @@
|
|||||||
"prettier": "prettier --check \"./**/*.ts\"",
|
"prettier": "prettier --check \"./**/*.ts\"",
|
||||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:e2e": "jest -c jest.config.e2e.ts --runInBand --detectOpenHandles --forceExit",
|
"test:e2e": "jest -c jest.config.e2e.ts --runInBand --detectOpenHandles",
|
||||||
"test-coverage": "jest --coverage",
|
"test-coverage": "jest --coverage",
|
||||||
"test-coverage:e2e": "jest --coverage -c jest.config.e2e.ts --runInBand --detectOpenHandles --forceExit"
|
"test-coverage:e2e": "jest --coverage -c jest.config.e2e.ts --runInBand --detectOpenHandles"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -50,6 +50,7 @@
|
|||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@actions/io": "^1.1.2",
|
"@actions/io": "^1.1.2",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
|
"async-retry": "^1.3.3",
|
||||||
"csv-parse": "^5.3.5",
|
"csv-parse": "^5.3.5",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
|
@ -75,22 +75,6 @@ mkdir -p "$RUNDIR"
|
|||||||
--userland-proxy=false \\
|
--userland-proxy=false \\
|
||||||
2>&1 | tee "$RUNDIR/dockerd.log"
|
2>&1 | tee "$RUNDIR/dockerd.log"
|
||||||
) &
|
) &
|
||||||
|
|
||||||
tries=60
|
|
||||||
while ! docker version &> /dev/null; do
|
|
||||||
((tries--))
|
|
||||||
if [ $tries -le 0 ]; then
|
|
||||||
if [ -z "$DOCKER_HOST" ]; then
|
|
||||||
echo >&2 "error: daemon failed to start"
|
|
||||||
else
|
|
||||||
echo >&2 "error: daemon at $DOCKER_HOST fails to 'docker version':"
|
|
||||||
docker version >&2 || true
|
|
||||||
fi
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "Docker daemon started successfully!"
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const setupDockerWinPs1Data = `
|
export const setupDockerWinPs1Data = `
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as child_process from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import retry from 'async-retry';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@ -133,9 +135,12 @@ export class Install {
|
|||||||
private async installLinux(toolDir: string, runDir: string): Promise<void> {
|
private async installLinux(toolDir: string, runDir: string): Promise<void> {
|
||||||
const dockerHost = `unix://${path.join(runDir, 'docker.sock')}`;
|
const dockerHost = `unix://${path.join(runDir, 'docker.sock')}`;
|
||||||
|
|
||||||
await core.group('Install 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);
|
||||||
await Exec.exec('sudo', ['-E', bashPath, setupDockerLinuxSh()], {
|
const proc = await child_process.spawn(`sudo -E ${bashPath} ${setupDockerLinuxSh()}`, [], {
|
||||||
|
detached: true,
|
||||||
|
shell: true,
|
||||||
|
stdio: ['ignore', process.stdout, process.stderr],
|
||||||
env: Object.assign({}, process.env, {
|
env: Object.assign({}, process.env, {
|
||||||
TOOLDIR: toolDir,
|
TOOLDIR: toolDir,
|
||||||
RUNDIR: runDir,
|
RUNDIR: runDir,
|
||||||
@ -144,6 +149,35 @@ export class Install {
|
|||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
proc.unref();
|
||||||
|
await retry(
|
||||||
|
async bail => {
|
||||||
|
await Exec.getExecOutput(`docker version`, undefined, {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true,
|
||||||
|
env: Object.assign({}, process.env, {
|
||||||
|
DOCKER_HOST: dockerHost
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
bail(new Error(res.stderr));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return res.exitCode == 0;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
bail(error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
retries: 5
|
||||||
|
}
|
||||||
|
);
|
||||||
|
core.info(`Docker daemon started started successfully`);
|
||||||
});
|
});
|
||||||
|
|
||||||
await core.group('Create Docker context', async () => {
|
await core.group('Create Docker context', async () => {
|
||||||
|
17
yarn.lock
17
yarn.lock
@ -774,6 +774,7 @@ __metadata:
|
|||||||
"@types/tmp": ^0.2.3
|
"@types/tmp": ^0.2.3
|
||||||
"@typescript-eslint/eslint-plugin": ^5.49.0
|
"@typescript-eslint/eslint-plugin": ^5.49.0
|
||||||
"@typescript-eslint/parser": ^5.49.0
|
"@typescript-eslint/parser": ^5.49.0
|
||||||
|
async-retry: ^1.3.3
|
||||||
cpy-cli: ^4.2.0
|
cpy-cli: ^4.2.0
|
||||||
csv-parse: ^5.3.5
|
csv-parse: ^5.3.5
|
||||||
dotenv: ^16.0.3
|
dotenv: ^16.0.3
|
||||||
@ -2034,6 +2035,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"async-retry@npm:^1.3.3":
|
||||||
|
version: 1.3.3
|
||||||
|
resolution: "async-retry@npm:1.3.3"
|
||||||
|
dependencies:
|
||||||
|
retry: 0.13.1
|
||||||
|
checksum: 38a7152ff7265a9321ea214b9c69e8224ab1febbdec98efbbde6e562f17ff68405569b796b1c5271f354aef8783665d29953f051f68c1fc45306e61aec82fdc4
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"asynckit@npm:^0.4.0":
|
"asynckit@npm:^0.4.0":
|
||||||
version: 0.4.0
|
version: 0.4.0
|
||||||
resolution: "asynckit@npm:0.4.0"
|
resolution: "asynckit@npm:0.4.0"
|
||||||
@ -5947,6 +5957,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"retry@npm:0.13.1":
|
||||||
|
version: 0.13.1
|
||||||
|
resolution: "retry@npm:0.13.1"
|
||||||
|
checksum: 47c4d5be674f7c13eee4cfe927345023972197dbbdfba5d3af7e461d13b44de1bfd663bfc80d2f601f8ef3fc8164c16dd99655a221921954a65d044a2fc1233b
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"retry@npm:^0.12.0":
|
"retry@npm:^0.12.0":
|
||||||
version: 0.12.0
|
version: 0.12.0
|
||||||
resolution: "retry@npm:0.12.0"
|
resolution: "retry@npm:0.12.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user