|
| 1 | +FROM adguard/node-ssh:22.22--0 AS base |
| 2 | +SHELL ["/bin/bash", "-lc"] |
| 3 | + |
| 4 | +RUN npm install -g pnpm@10.7.1 |
| 5 | + |
| 6 | +WORKDIR /ecsstree |
| 7 | + |
| 8 | +ENV npm_config_store_dir=/pnpm-store |
| 9 | + |
| 10 | +# ============================================================================ |
| 11 | +# Stage: deps |
| 12 | +# Cached until package.json/pnpm-lock.yaml changes |
| 13 | +# ============================================================================ |
| 14 | +FROM base AS deps |
| 15 | + |
| 16 | +COPY package.json pnpm-lock.yaml ./ |
| 17 | + |
| 18 | +# --ignore-scripts: package.json has "prepare": "node .husky/install.js" which |
| 19 | +# must not run in CI (requires git hooks setup). |
| 20 | +RUN --mount=type=cache,target=/pnpm-store,id=ecsstree-pnpm \ |
| 21 | + pnpm install --frozen-lockfile --ignore-scripts |
| 22 | + |
| 23 | +# ============================================================================ |
| 24 | +# Stage: source |
| 25 | +# Full source copy — parent for all lint/test/build stages |
| 26 | +# ============================================================================ |
| 27 | +FROM deps AS source |
| 28 | + |
| 29 | +COPY . /ecsstree |
| 30 | + |
| 31 | +# ============================================================================ |
| 32 | +# Stage: lint |
| 33 | +# Runs ESLint and markdownlint |
| 34 | +# ============================================================================ |
| 35 | +FROM source AS lint |
| 36 | + |
| 37 | +ARG BUILD_RUN_ID="" |
| 38 | + |
| 39 | +RUN --mount=type=cache,target=/pnpm-store,id=ecsstree-pnpm \ |
| 40 | + echo "${BUILD_RUN_ID}" > /tmp/.build-run-id && \ |
| 41 | + mkdir -p /out && \ |
| 42 | + touch /out/lint.txt && \ |
| 43 | + pnpm lint |
| 44 | + |
| 45 | +FROM scratch AS lint-output |
| 46 | +COPY --from=lint /out/ / |
| 47 | + |
| 48 | +# ============================================================================ |
| 49 | +# Stage: test |
| 50 | +# Runs vitest |
| 51 | +# Always exits 0 — exit code stored in /out/exit-code.txt for Bamboo to check |
| 52 | +# ============================================================================ |
| 53 | +FROM source AS test |
| 54 | + |
| 55 | +ARG BUILD_RUN_ID="" |
| 56 | + |
| 57 | +RUN --mount=type=cache,target=/pnpm-store,id=ecsstree-pnpm \ |
| 58 | + echo "${BUILD_RUN_ID}" > /tmp/.build-run-id && \ |
| 59 | + mkdir -p /out && \ |
| 60 | + pnpm test; echo $? > /out/exit-code.txt |
| 61 | + |
| 62 | +FROM scratch AS test-output |
| 63 | +COPY --from=test /out/ / |
| 64 | + |
| 65 | +# ============================================================================ |
| 66 | +# Stage: build |
| 67 | +# Creates the library build, runs smoke tests, packs .tgz for npm publish, |
| 68 | +# and exports build.txt for Bamboo variable injection |
| 69 | +# ============================================================================ |
| 70 | +FROM source AS build |
| 71 | + |
| 72 | +ARG BUILD_RUN_ID="" |
| 73 | + |
| 74 | +RUN --mount=type=cache,target=/pnpm-store,id=ecsstree-pnpm \ |
| 75 | + echo "${BUILD_RUN_ID}" > /tmp/.build-run-id && \ |
| 76 | + pnpm build && \ |
| 77 | + pnpm test:smoke && \ |
| 78 | + pnpm pack --out ecsstree.tgz && \ |
| 79 | + mkdir -p /out/artifacts && \ |
| 80 | + mv ecsstree.tgz /out/artifacts/ && \ |
| 81 | + cp build.txt /out/artifacts/ |
| 82 | + |
| 83 | +FROM scratch AS build-output |
| 84 | +COPY --from=build /out/ / |
0 commit comments