Permalink
March 28, 2021 16:43
November 16, 2021 04:53
March 28, 2021 16:43
November 16, 2021 04:53
March 28, 2021 16:43
March 28, 2021 16:43
November 16, 2021 04:53
Newer
100644
78 lines (64 sloc)
2.17 KB
6
7
FROM node:${NODE_VERSION}-alpine AS base
8
RUN apk add --no-cache cpio findutils git
9
WORKDIR /src
10
11
FROM base AS deps
12
RUN --mount=type=bind,target=.,rw \
13
--mount=type=cache,target=/src/node_modules \
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
30
31
FROM deps AS build
32
RUN --mount=type=bind,target=.,rw \
33
--mount=type=cache,target=/src/node_modules \
34
yarn run build && mkdir /out && cp -Rf dist /out/
35
36
FROM scratch AS build-update
37
COPY --from=build /out /
38
39
FROM build AS build-validate
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
50
51
FROM deps AS format
52
RUN --mount=type=bind,target=.,rw \
53
--mount=type=cache,target=/src/node_modules \
54
yarn run format \
55
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
56
57
FROM scratch AS format-update
58
COPY --from=format /out /
59
61
RUN --mount=type=bind,target=.,rw \
62
--mount=type=cache,target=/src/node_modules \
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 /