feat(infra): Removed alpine/jq dependencies

Changed from using `jq` to a nodejs script to merge package.json files
This commit is contained in:
Maieul BOYER 2025-08-03 15:10:13 +02:00
parent c3d29662ba
commit c633200e86
2 changed files with 29 additions and 8 deletions

View file

@ -0,0 +1,23 @@
#!/usr/bin/env node
import fs from 'node:fs/promises'
const merge_json = (prev, cur) => {
const keys = ["dependencies", "devDependencies"];
const out = {};
for (let k of keys)
out[k] = Object.assign(prev[k] ?? {}, cur[k] ?? {});
return out;
};
const promises = process.argv.slice(2).map(f => fs.readFile(f, { encoding: "utf8" }));
const jsons = (await Promise.all(promises)).map(JSON.parse);
const deps = jsons.reduce(merge_json, {});
const out = Object.assign(deps, {
private: true,
name: "stub",
});
console.log(JSON.stringify(out));

View file

@ -1,6 +1,5 @@
FROM guergeiro/pnpm:22-10-alpine as builder FROM guergeiro/pnpm:22-10-slim as builder
RUN apk add jq;
ARG SERVICE ARG SERVICE
WORKDIR /build WORKDIR /build
@ -15,14 +14,13 @@ RUN pnpm install;
COPY ./@shared/ /build/@shared/ COPY ./@shared/ /build/@shared/
COPY ./${SERVICE}/ /build/service/ COPY ./${SERVICE}/ /build/service/
RUN cd /build/service && \ RUN cd /build/service && \
pnpm run build:prod && \ pnpm run build:prod && \
jq -s '.[0] * .[1]' /build/*/package.json >/dist/package.json && \ node /build/@shared/scripts/merge.js /build/*/package.json >/dist/package.json && \
cp /build/pnpm-workspace.yaml /dist/pnpm-workspace.yaml && \ cp /build/pnpm-workspace.yaml /dist/pnpm-workspace.yaml;
true;
FROM guergeiro/pnpm:22-10-slim FROM guergeiro/pnpm:22-10-alpine
WORKDIR /src WORKDIR /src