1
- # syntax=docker/dockerfile:1.2
1
+ # syntax=docker/dockerfile:1.3-labs
2
+
2
3
ARG NODE_VERSION
3
4
4
5
FROM node:${NODE_VERSION}-alpine AS base
@@ -8,7 +9,22 @@ WORKDIR /src
8
9
FROM base AS deps
9
10
RUN --mount=type=bind,target=.,rw \
10
11
--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
12
28
13
29
FROM deps AS build
14
30
RUN --mount=type=bind,target=.,rw \
@@ -19,13 +35,16 @@ FROM scratch AS build-update
19
35
COPY --from=build /out /
20
36
21
37
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
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
29
48
30
49
FROM deps AS format
31
50
RUN --mount=type=bind,target=.,rw \
@@ -39,4 +58,4 @@ COPY --from=format /out /
39
58
FROM deps AS format-validate
40
59
RUN --mount=type=bind,target=.,rw \
41
60
--mount=type=cache,target=/src/node_modules \
42
- yarn run format-check \
61
+ yarn run format-check
0 commit comments