Skip to content

Commit 04841f2

Browse files
authored
Merge pull request #499 from crazy-max/update-workflow
dev: update workflow
2 parents 0a196c9 + 049b7ca commit 04841f2

File tree

4 files changed

+54
-66
lines changed

4 files changed

+54
-66
lines changed

docker-bake.hcl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ target "build-validate" {
3131
inherits = ["node-version"]
3232
dockerfile = "./hack/build.Dockerfile"
3333
target = "build-validate"
34+
output = ["type=cacheonly"]
3435
}
3536

3637
target "format" {
@@ -44,24 +45,26 @@ target "format-validate" {
4445
inherits = ["node-version"]
4546
dockerfile = "./hack/build.Dockerfile"
4647
target = "format-validate"
48+
output = ["type=cacheonly"]
4749
}
4850

4951
target "vendor-update" {
5052
inherits = ["node-version"]
51-
dockerfile = "./hack/vendor.Dockerfile"
52-
target = "update"
53+
dockerfile = "./hack/build.Dockerfile"
54+
target = "vendor-update"
5355
output = ["."]
5456
}
5557

5658
target "vendor-validate" {
5759
inherits = ["node-version"]
58-
dockerfile = "./hack/vendor.Dockerfile"
59-
target = "validate"
60+
dockerfile = "./hack/build.Dockerfile"
61+
target = "vendor-validate"
62+
output = ["type=cacheonly"]
6063
}
6164

6265
target "test" {
6366
inherits = ["node-version"]
64-
dockerfile = "./hack/test.Dockerfile"
67+
dockerfile = "./hack/build.Dockerfile"
6568
target = "test-coverage"
6669
output = ["./coverage"]
6770
}

hack/build.Dockerfile

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# syntax=docker/dockerfile:1.2
1+
# syntax=docker/dockerfile:1.3-labs
2+
23
ARG NODE_VERSION
4+
ARG DOCKER_VERSION=20.10.10
5+
ARG BUILDX_VERSION=0.7.0
36

47
FROM node:${NODE_VERSION}-alpine AS base
58
RUN apk add --no-cache cpio findutils git
@@ -8,7 +11,22 @@ WORKDIR /src
811
FROM base AS deps
912
RUN --mount=type=bind,target=.,rw \
1013
--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
1230

1331
FROM deps AS build
1432
RUN --mount=type=bind,target=.,rw \
@@ -19,13 +37,16 @@ FROM scratch AS build-update
1937
COPY --from=build /out /
2038

2139
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
2950

3051
FROM deps AS format
3152
RUN --mount=type=bind,target=.,rw \
@@ -39,4 +60,19 @@ COPY --from=format /out /
3960
FROM deps AS format-validate
4061
RUN --mount=type=bind,target=.,rw \
4162
--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 /

hack/test.Dockerfile

Lines changed: 0 additions & 28 deletions
This file was deleted.

hack/vendor.Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)