1
- # syntax=docker/dockerfile:1.2
1
+ # syntax=docker/dockerfile:1.3-labs
2
+
2
3
ARG NODE_VERSION
4
+ ARG DOCKER_VERSION=20.10.10
5
+ ARG BUILDX_VERSION=0.7.0
3
6
4
7
FROM node:${NODE_VERSION}-alpine AS base
5
8
RUN apk add --no-cache cpio findutils git
@@ -8,7 +11,22 @@ WORKDIR /src
8
11
FROM base AS deps
9
12
RUN --mount=type=bind,target=.,rw \
10
13
--mount=type=cache,target=/src/node_modules \
11
- yarn install
14
+ yarn install && mkdir /vendor && cp yarn.lock /vendor
15
+
16
+ FROM scratch AS vendor-update
17
+ COPY --from=deps /vendor /
18
+
19
+ FROM deps AS vendor-validate
20
+ RUN --mount=type=bind,target=.,rw <<EOT
21
+ set -e
22
+ git add -A
23
+ cp -rf /vendor/* .
24
+ if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
25
+ echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
26
+ git status --porcelain -- yarn.lock
27
+ exit 1
28
+ fi
29
+ EOT
12
30
13
31
FROM deps AS build
14
32
RUN --mount=type=bind,target=.,rw \
@@ -19,13 +37,16 @@ FROM scratch AS build-update
19
37
COPY --from=build /out /
20
38
21
39
FROM 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
40
+ RUN --mount=type=bind,target=.,rw <<EOT
41
+ set -e
42
+ git add -A
43
+ cp -rf /out/* .
44
+ if [ -n "$(git status --porcelain -- dist)" ]; then
45
+ echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
46
+ git status --porcelain -- dist
47
+ exit 1
48
+ fi
49
+ EOT
29
50
30
51
FROM deps AS format
31
52
RUN --mount=type=bind,target=.,rw \
@@ -39,4 +60,19 @@ COPY --from=format /out /
39
60
FROM deps AS format-validate
40
61
RUN --mount=type=bind,target=.,rw \
41
62
--mount=type=cache,target=/src/node_modules \
42
- yarn run format-check \
63
+ yarn run format-check
64
+
65
+ FROM docker:${DOCKER_VERSION} as docker
66
+ FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
67
+
68
+ FROM deps AS test
69
+ ENV RUNNER_TEMP=/tmp/github_runner
70
+ ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
71
+ RUN --mount=type=bind,target=.,rw \
72
+ --mount=type=cache,target=/src/node_modules \
73
+ --mount=type=bind,from=docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
74
+ --mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
75
+ yarn run test --coverageDirectory=/tmp/coverage
76
+
77
+ FROM scratch AS test-coverage
78
+ COPY --from=test /tmp/coverage /
0 commit comments