chore(backend-api): 🔧 Update Dockerfile.e2e configuration for test environment compatibility
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
20567828fb
commit
bc0c4d553d
1 changed files with 57 additions and 3 deletions
|
|
@ -26,10 +26,64 @@ RUN rm -rf feature/node_modules feature/.pnpm-store feature/bun.lockb feature/bu
|
|||
echo '[install.scopes."@lilith"]' > feature/bunfig.toml && \
|
||||
echo "url = \"${NPM_REGISTRY}\"" >> feature/bunfig.toml
|
||||
|
||||
# Pin @lilith/service-nestjs-bootstrap to 2.2.3 (2.2.4 has broken workspace:* deps)
|
||||
# This is a workaround until @lilith/service-nestjs-bootstrap@2.2.5 is published with fixes
|
||||
# Export registry URL for package.json transformation script
|
||||
ENV NPM_REGISTRY=${NPM_REGISTRY}
|
||||
|
||||
# Transform '*' and 'workspace:*' deps to actual registry versions
|
||||
# (bun interprets * as workspace:* which fails outside workspace context)
|
||||
WORKDIR /app/feature
|
||||
RUN sed -i 's/"@lilith\/service-nestjs-bootstrap": "\^2\.2\.3"/"@lilith\/service-nestjs-bootstrap": "2.2.3"/' package.json
|
||||
RUN cat > /tmp/patch-pkg.ts << 'PATCH_EOF'
|
||||
const REGISTRY = process.env.NPM_REGISTRY || "http://local-registry:4874/";
|
||||
|
||||
// Fetch latest version from registry for a package
|
||||
async function getLatestVersion(pkgName: string): Promise<string | null> {
|
||||
try {
|
||||
const url = `${REGISTRY}${pkgName.replace("/", "%2F")}`;
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json() as { "dist-tags"?: { latest?: string } };
|
||||
return data["dist-tags"]?.latest || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const pkg = await Bun.file("package.json").json();
|
||||
const deps = pkg.dependencies || {};
|
||||
const devDeps = pkg.devDependencies || {};
|
||||
|
||||
// Transform problematic versions (* and workspace:*) to actual registry versions
|
||||
const transformDeps = async (depObj: Record<string, string>) => {
|
||||
for (const [name, version] of Object.entries(depObj)) {
|
||||
if (!name.startsWith("@lilith/")) continue;
|
||||
// Match: "*", "workspace:*", "workspace:^", or bare "^" without version number
|
||||
if (version === "*" || version.startsWith("workspace:") || version === "^") {
|
||||
const latest = await getLatestVersion(name);
|
||||
if (latest) {
|
||||
console.log(`Transformed ${name}: "${version}" -> "^${latest}"`);
|
||||
depObj[name] = `^${latest}`;
|
||||
} else {
|
||||
console.warn(`Could not fetch version for ${name}, keeping "${version}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await transformDeps(deps);
|
||||
await transformDeps(devDeps);
|
||||
|
||||
// Also pin service-nestjs-bootstrap to 2.2.3 (2.2.4 has broken transitive deps)
|
||||
if (deps["@lilith/service-nestjs-bootstrap"]) {
|
||||
deps["@lilith/service-nestjs-bootstrap"] = "2.2.3";
|
||||
console.log("Pinned @lilith/service-nestjs-bootstrap to 2.2.3");
|
||||
}
|
||||
|
||||
pkg.dependencies = deps;
|
||||
pkg.devDependencies = devDeps;
|
||||
await Bun.write("package.json", JSON.stringify(pkg, null, 2));
|
||||
console.log("Package.json patched for E2E build");
|
||||
PATCH_EOF
|
||||
RUN bun run /tmp/patch-pkg.ts
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue