feat(infra): Removed alpine/jq dependencies
Changed from using `jq` to a nodejs script to merge package.json files
This commit is contained in:
parent
c3d29662ba
commit
c633200e86
2 changed files with 29 additions and 8 deletions
23
src/@shared/scripts/merge.js
Normal file
23
src/@shared/scripts/merge.js
Normal 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));
|
||||
|
|
@ -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
|
||||
|
||||
WORKDIR /build
|
||||
|
|
@ -15,14 +14,13 @@ RUN pnpm install;
|
|||
COPY ./@shared/ /build/@shared/
|
||||
COPY ./${SERVICE}/ /build/service/
|
||||
|
||||
RUN cd /build/service && \
|
||||
pnpm run build:prod && \
|
||||
jq -s '.[0] * .[1]' /build/*/package.json >/dist/package.json && \
|
||||
cp /build/pnpm-workspace.yaml /dist/pnpm-workspace.yaml && \
|
||||
true;
|
||||
RUN cd /build/service && \
|
||||
pnpm run build:prod && \
|
||||
node /build/@shared/scripts/merge.js /build/*/package.json >/dist/package.json && \
|
||||
cp /build/pnpm-workspace.yaml /dist/pnpm-workspace.yaml;
|
||||
|
||||
|
||||
FROM guergeiro/pnpm:22-10-slim
|
||||
FROM guergeiro/pnpm:22-10-alpine
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue