Skip to content

Commit 8c09d89

Browse files
committed
Use containerized Astro build for cross-platform consistency
- Build Astro in Docker container (node:22-slim) instead of native npm - Removes Windows-specific npm dependency issues - Remove manually added Windows packages from package.json - Regenerate package-lock.json in container for Linux compatibility - Increase Node.js memory limit (4GB) to handle large builds
1 parent b97a9a2 commit 8c09d89

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

astro/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
"@fontsource/roboto": "^5.2.9",
3131
"@pasqal-io/starlight-client-mermaid": "^0.1.0",
3232
"@resvg/resvg-js": "^2.6.2",
33-
"@resvg/resvg-js-win32-x64-msvc": "^2.6.2",
34-
"@rollup/rollup-win32-x64-msvc": "^4.55.1",
3533
"astro": "^5.17.1",
3634
"astro-opengraph-images": "^1.14.2",
3735
"astro-redirect-from": "^1.3.4",

build.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
?? throw new InvalidOperationException("Could not find repository root");
1414
}
1515

16-
var astroDir = Path.Combine(repoRoot, "astro");
1716
var serverDir = Path.Combine(repoRoot, "server");
1817
var wwwrootDir = Path.Combine(serverDir, "Docs.Web", "wwwroot");
1918

2019
// Target names
2120
const string Restore = "restore";
22-
const string AstroInstall = "astro-install";
2321
const string AstroBuild = "astro-build";
2422
const string DotnetBuild = "dotnet-build";
2523
const string DotnetPublish = "dotnet-publish";
@@ -31,18 +29,33 @@
3129
const string Clean = "clean";
3230
const string Default = "default";
3331

34-
// Restore/Install
32+
// Restore
3533
Target(Restore, () =>
3634
RunAsync("dotnet", "restore Docs.slnx", workingDirectory: serverDir));
3735

38-
// Use 'npm install' instead of 'npm ci' due to npm bug with optional dependencies on Windows
39-
// See: https://github.com/npm/cli/issues/4828
40-
Target(AstroInstall, () =>
41-
RunAsync("npm", "install", workingDirectory: astroDir));
42-
43-
// Build
44-
Target(AstroBuild, dependsOn: [AstroInstall], () =>
45-
RunAsync("npm", "run build -- --outDir ../server/Docs.Web/wwwroot", workingDirectory: astroDir));
36+
// Astro build in container - avoids Windows npm issues with platform-specific dependencies
37+
Target(AstroBuild, async () =>
38+
{
39+
// Ensure output directory exists
40+
Directory.CreateDirectory(wwwrootDir);
41+
42+
// Convert Windows paths to Docker-compatible format (forward slashes)
43+
var astroPath = Path.Combine(repoRoot, "astro").Replace('\\', '/');
44+
var outputPath = wwwrootDir.Replace('\\', '/');
45+
46+
// Use Docker to build Astro - consistent across all platforms
47+
// Use Debian-based image (not Alpine) for better compatibility with native modules
48+
// Increase Node.js memory limit to handle large builds
49+
await RunAsync("docker",
50+
"run --rm " +
51+
$"-v \"{astroPath}:/app\" " +
52+
$"-v \"{outputPath}:/output\" " +
53+
"-w /app " +
54+
"-e NODE_OPTIONS=\"--max-old-space-size=4096\" " +
55+
"node:22-slim " +
56+
"sh -c \"npm ci && npm run build -- --outDir /output\"",
57+
configureEnvironment: env => env.Add("MSYS_NO_PATHCONV", "1"));
58+
});
4659

4760
Target(DotnetBuild, dependsOn: [Restore], () =>
4861
RunAsync("dotnet", "build Docs.slnx --no-restore", workingDirectory: serverDir));

0 commit comments

Comments
 (0)