1- # syntax=docker/dockerfile:1.2
1+ # syntax=docker/dockerfile:1.3-labs
2+
23ARG NODE_VERSION
34
45FROM node:${NODE_VERSION}-alpine AS base
@@ -8,7 +9,22 @@ WORKDIR /src
89FROM base AS deps
910RUN --mount=type=bind,target=.,rw \
1011 --mount=type=cache,target=/src/node_modules \
11- yarn install
12+ yarn install && mkdir /vendor && cp yarn.lock /vendor
13+
14+ FROM scratch AS vendor-update
15+ COPY --from=deps /vendor /
16+
17+ FROM deps AS vendor-validate
18+ RUN --mount=type=bind,target=.,rw <<EOT
19+ set -e
20+ git add -A
21+ cp -rf /vendor/* .
22+ if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
23+ echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
24+ git status --porcelain -- yarn.lock
25+ exit 1
26+ fi
27+ EOT
1228
1329FROM deps AS build
1430RUN --mount=type=bind,target=.,rw \
@@ -19,13 +35,16 @@ FROM scratch AS build-update
1935COPY --from=build /out /
2036
2137FROM build AS build-validate
22- RUN --mount=type=bind,target=.,rw \
23- git add -A && cp -rf /out/* .; \
24- if [ -n "$(git status --porcelain -- dist)" ]; then \
25- echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"' ; \
26- git status --porcelain -- dist; \
27- exit 1; \
28- fi
38+ RUN --mount=type=bind,target=.,rw <<EOT
39+ set -e
40+ git add -A
41+ cp -rf /out/* .
42+ if [ -n "$(git status --porcelain -- dist)" ]; then
43+ echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
44+ git status --porcelain -- dist
45+ exit 1
46+ fi
47+ EOT
2948
3049FROM deps AS format
3150RUN --mount=type=bind,target=.,rw \
@@ -39,4 +58,14 @@ COPY --from=format /out /
3958FROM deps AS format-validate
4059RUN --mount=type=bind,target=.,rw \
4160 --mount=type=cache,target=/src/node_modules \
42- yarn run format-check \
61+ yarn run format-check
62+
63+ FROM deps AS test
64+ ENV RUNNER_TEMP=/tmp/github_runner
65+ ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
66+ RUN --mount=type=bind,target=.,rw \
67+ --mount=type=cache,target=/src/node_modules \
68+ yarn run test --coverageDirectory=/tmp/coverage
69+
70+ FROM scratch AS test-coverage
71+ COPY --from=test /tmp/coverage /
0 commit comments