mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-08-22 15:07:53 +03:00
Compare commits
6 commits
a9e7dd1024
...
46ae1aa4c9
Author | SHA1 | Date | |
---|---|---|---|
|
46ae1aa4c9 | ||
|
4cc794f83e | ||
|
4dfc3d6c5d | ||
|
80d22c042f | ||
|
66d7daabf8 | ||
|
bc3c5abd64 |
5 changed files with 93 additions and 35 deletions
50
.github/workflows/ci.yml
vendored
50
.github/workflows/ci.yml
vendored
|
@ -32,7 +32,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
id: buildx
|
||||
|
@ -51,7 +51,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx 1
|
||||
uses: ./
|
||||
|
@ -64,7 +64,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Stop docker
|
||||
run: |
|
||||
|
@ -92,7 +92,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Create Dockerfile
|
||||
run: |
|
||||
|
@ -120,7 +120,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -142,7 +142,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -165,7 +165,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -178,7 +178,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -211,7 +211,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Create context
|
||||
run: |
|
||||
|
@ -233,7 +233,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Create buildkitd conf
|
||||
run: |
|
||||
|
@ -265,7 +265,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Create Dockerfile
|
||||
run: |
|
||||
|
@ -301,7 +301,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
@ -330,7 +330,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -353,7 +353,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Uninstall docker cli
|
||||
run: |
|
||||
|
@ -381,7 +381,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Uninstall docker cli
|
||||
run: |
|
||||
|
@ -412,7 +412,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Uninstall docker cli
|
||||
run: |
|
||||
|
@ -442,7 +442,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Create dummy contexts
|
||||
run: |
|
||||
|
@ -471,7 +471,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
@ -486,7 +486,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Create Docker context
|
||||
run: |
|
||||
|
@ -509,7 +509,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -528,7 +528,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Install k3s
|
||||
uses: crazy-max/.github/.github/actions/install-k3s@a94383ec9e125b23907fb6fcebf7ff87964595e5
|
||||
|
@ -576,7 +576,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -589,7 +589,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
id: buildx
|
||||
|
@ -610,7 +610,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
@ -629,7 +629,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
id: buildx
|
||||
|
|
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Publish
|
||||
uses: actions/publish-immutable-action@v0.0.4
|
||||
|
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -17,7 +17,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: ./
|
||||
|
|
2
.github/workflows/validate.yml
vendored
2
.github/workflows/validate.yml
vendored
|
@ -19,7 +19,7 @@ jobs:
|
|||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
-
|
||||
name: List targets
|
||||
id: generate
|
||||
|
|
72
src/main.ts
72
src/main.ts
|
@ -17,6 +17,37 @@ import {ContextInfo} from '@docker/actions-toolkit/lib/types/docker/docker';
|
|||
import * as context from './context';
|
||||
import * as stateHelper from './state-helper';
|
||||
|
||||
/**
|
||||
* Retry a function with exponential backoff
|
||||
*/
|
||||
async function retryWithBackoff<T>(
|
||||
operation: () => Promise<T>,
|
||||
maxRetries: number = 3,
|
||||
initialDelay: number = 1000,
|
||||
maxDelay: number = 10000,
|
||||
shouldRetry: (error: Error) => boolean = () => true
|
||||
): Promise<T> {
|
||||
let retries = 0;
|
||||
let delay = initialDelay;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
return await operation();
|
||||
} catch (error) {
|
||||
if (retries >= maxRetries || !shouldRetry(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
retries++;
|
||||
core.info(`Retry ${retries}/${maxRetries} after ${delay}ms due to: ${error.message}`);
|
||||
await new Promise(resolve => setTimeout(resolve, delay));
|
||||
|
||||
// Exponential backoff with jitter
|
||||
delay = Math.min(delay * 2, maxDelay) * (0.8 + Math.random() * 0.4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actionsToolkit.run(
|
||||
// main
|
||||
async () => {
|
||||
|
@ -175,13 +206,40 @@ actionsToolkit.run(
|
|||
|
||||
await core.group(`Booting builder`, async () => {
|
||||
const inspectCmd = await toolkit.buildx.getCommand(await context.getInspectArgs(inputs, toolkit));
|
||||
await Exec.getExecOutput(inspectCmd.command, inspectCmd.args, {
|
||||
ignoreReturnCode: true
|
||||
}).then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
await retryWithBackoff(
|
||||
async () => {
|
||||
// Create a promise that will timeout after 15 seconds
|
||||
const timeoutPromise = new Promise<never>((_, reject) => {
|
||||
setTimeout(() => {
|
||||
reject(new Error('Timeout exceeded while waiting for buildkit to initialize'));
|
||||
}, 15000); // 15 second timeout
|
||||
});
|
||||
|
||||
// Create the actual command execution promise
|
||||
const execPromise = Exec.getExecOutput(inspectCmd.command, inspectCmd.args, {
|
||||
ignoreReturnCode: true
|
||||
}).then(res => {
|
||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
||||
// Race the timeout against the actual command
|
||||
// If the command takes too long, we'll get the timeout error instead
|
||||
return Promise.race([execPromise, timeoutPromise]);
|
||||
},
|
||||
3, // maxRetries - retry up to 3 times for buildkit initialization
|
||||
1000, // initialDelay - start with 1 second
|
||||
15000 // maxDelay - cap at 15 seconds
|
||||
);
|
||||
} catch (error) {
|
||||
// Log the warning but continue - this matches current behavior where builds still succeed
|
||||
core.warning(`Failed to bootstrap builder after multiple retries: ${error.message}`);
|
||||
core.warning('Continuing execution as buildkit daemon may initialize later');
|
||||
}
|
||||
});
|
||||
|
||||
if (inputs.install) {
|
||||
|
|
Loading…
Add table
Reference in a new issue