33ARG NODE_VERSION=20
44
55FROM node:${NODE_VERSION}-alpine AS base
6- RUN apk add --no-cache cpio findutils git
6+ RUN apk add --no-cache cpio findutils git rsync
77WORKDIR /src
88RUN --mount=type=bind,target=.,rw \
99 --mount=type=cache,target=/src/.yarn/cache <<EOT
10+ set -e
1011 corepack enable
1112 yarn --version
1213 yarn config set --home enableTelemetry 0
@@ -34,18 +35,27 @@ RUN --mount=type=bind,target=.,rw <<EOT
3435EOT
3536
3637FROM deps AS build
37- RUN --mount=type=bind, target=.,rw \
38+ RUN --mount=target=/context \
3839 --mount=type=cache,target=/src/.yarn/cache \
39- --mount=type=cache,target=/src/node_modules \
40- yarn run build && mkdir /out && cp -Rf dist /out/
40+ --mount=type=cache,target=/src/node_modules <<EOT
41+ set -e
42+ rsync -a /context/. .
43+ rm -rf dist
44+ yarn run build
45+ mkdir /out
46+ cp -r dist /out
47+ EOT
4148
4249FROM scratch AS build-update
4350COPY --from=build /out /
4451
4552FROM build AS build-validate
46- RUN --mount=type=bind,target=.,rw <<EOT
53+ RUN --mount=target=/context \
54+ --mount=target=.,type=tmpfs <<EOT
4755 set -e
56+ rsync -a /context/. .
4857 git add -A
58+ rm -rf dist
4959 cp -rf /out/* .
5060 if [ -n "$(git status --porcelain -- dist)" ]; then
5161 echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
@@ -58,8 +68,7 @@ FROM deps AS format
5868RUN --mount=type=bind,target=.,rw \
5969 --mount=type=cache,target=/src/.yarn/cache \
6070 --mount=type=cache,target=/src/node_modules \
61- yarn run format \
62- && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
71+ yarn run format && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
6372
6473FROM scratch AS format-update
6574COPY --from=format /out /
0 commit comments