mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-17 17:42:47 +08:00
fix: Remove isolated-vm from Dockerfile npm rebuild (#26745)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
5fbcaeee05
commit
908a810e07
@@ -119,7 +119,17 @@ const __dirname = path.dirname(__filename);
|
||||
const isInScriptsDir = path.basename(__dirname) === 'scripts';
|
||||
const rootDir = isInScriptsDir ? path.join(__dirname, '..') : __dirname;
|
||||
|
||||
const noCache = process.env.DOCKER_BUILD_NO_CACHE === 'true';
|
||||
const withBaseImage = process.env.DOCKER_BUILD_BASE_IMAGE === 'true';
|
||||
const nodeVersion = process.env.NODE_VERSION || '24.13.1';
|
||||
|
||||
const config = {
|
||||
base: {
|
||||
dockerfilePath: path.join(rootDir, 'docker/images/n8n-base/Dockerfile'),
|
||||
get fullImageName() {
|
||||
return `n8nio/base:${nodeVersion}`;
|
||||
},
|
||||
},
|
||||
n8n: {
|
||||
dockerfilePath: path.join(rootDir, 'docker/images/n8n/Dockerfile'),
|
||||
imageBaseName: process.env.IMAGE_BASE_NAME || 'n8nio/n8n',
|
||||
@@ -153,20 +163,35 @@ async function main() {
|
||||
echo(`INFO: n8n Image: ${config.n8n.fullImageName}`);
|
||||
echo(`INFO: Runners Image: ${config.runners.fullImageName}`);
|
||||
echo(`INFO: Platform: ${platform}`);
|
||||
if (noCache) echo(chalk.yellow('INFO: Docker layer cache disabled (DOCKER_BUILD_NO_CACHE=true)'));
|
||||
if (withBaseImage) echo(chalk.yellow('INFO: Building base image first (DOCKER_BUILD_BASE_IMAGE=true)'));
|
||||
echo(chalk.gray('-'.repeat(47)));
|
||||
|
||||
await checkPrerequisites();
|
||||
|
||||
if (withBaseImage) {
|
||||
await buildDockerImage({
|
||||
name: 'base',
|
||||
dockerfilePath: config.base.dockerfilePath,
|
||||
fullImageName: config.base.fullImageName,
|
||||
buildArgs: [`NODE_VERSION=${nodeVersion}`],
|
||||
});
|
||||
}
|
||||
|
||||
const nodeVersionArgs = withBaseImage ? [`NODE_VERSION=${nodeVersion}`] : [];
|
||||
|
||||
const n8nBuildTime = await buildDockerImage({
|
||||
name: 'n8n',
|
||||
dockerfilePath: config.n8n.dockerfilePath,
|
||||
fullImageName: config.n8n.fullImageName,
|
||||
buildArgs: nodeVersionArgs,
|
||||
});
|
||||
|
||||
const runnersBuildTime = await buildDockerImage({
|
||||
name: 'runners',
|
||||
dockerfilePath: config.runners.dockerfilePath,
|
||||
fullImageName: config.runners.fullImageName,
|
||||
buildArgs: nodeVersionArgs,
|
||||
});
|
||||
|
||||
// Get image details
|
||||
@@ -226,13 +251,18 @@ async function checkPrerequisites() {
|
||||
}
|
||||
}
|
||||
|
||||
async function buildDockerImage({ name, dockerfilePath, fullImageName }) {
|
||||
async function buildDockerImage({ name, dockerfilePath, fullImageName, buildArgs = [] }) {
|
||||
const startTime = Date.now();
|
||||
const containerEngine = await getContainerEngine();
|
||||
// Push directly if image name contains a registry (e.g., ghcr.io/...)
|
||||
// This avoids the slow --load step (export/import tarball) when pushing to a registry
|
||||
const shouldPush = fullImageName.includes('/') && fullImageName.split('/').length > 2;
|
||||
|
||||
const extraFlags = [
|
||||
...buildArgs.flatMap((arg) => ['--build-arg', arg]),
|
||||
...(noCache ? ['--no-cache'] : []),
|
||||
];
|
||||
|
||||
echo(chalk.yellow(`INFO: Building ${name} Docker image using ${containerEngine}...`));
|
||||
if (shouldPush) {
|
||||
echo(chalk.yellow(`INFO: Registry detected - pushing directly to ${fullImageName}`));
|
||||
@@ -243,6 +273,7 @@ async function buildDockerImage({ name, dockerfilePath, fullImageName }) {
|
||||
const { stdout } = await $`podman build \
|
||||
--platform ${platform} \
|
||||
--build-arg TARGETPLATFORM=${platform} \
|
||||
${extraFlags} \
|
||||
-t ${fullImageName} \
|
||||
-f ${dockerfilePath} \
|
||||
${config.buildContext}`;
|
||||
@@ -256,6 +287,7 @@ async function buildDockerImage({ name, dockerfilePath, fullImageName }) {
|
||||
const { stdout } = await $`docker buildx build \
|
||||
--platform ${platform} \
|
||||
--build-arg TARGETPLATFORM=${platform} \
|
||||
${extraFlags} \
|
||||
-t ${fullImageName} \
|
||||
-f ${dockerfilePath} \
|
||||
--provenance=false \
|
||||
|
||||
Reference in New Issue
Block a user