Skip to content

Commit 1034824

Browse files
authored
Merge pull request #43 from crazy-max/update-workflow
dev: update workflow
2 parents 3dc90af + 2c05b5f commit 1034824

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

docker-bake.hcl

+7-4
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,17 +45,19 @@ 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
}

hack/build.Dockerfile

+29-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# syntax=docker/dockerfile:1.2
1+
# syntax=docker/dockerfile:1.3-labs
2+
23
ARG NODE_VERSION
34

45
FROM node:${NODE_VERSION}-alpine AS base
@@ -8,7 +9,22 @@ WORKDIR /src
89
FROM base AS deps
910
RUN --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

1329
FROM deps AS build
1430
RUN --mount=type=bind,target=.,rw \
@@ -19,13 +35,16 @@ FROM scratch AS build-update
1935
COPY --from=build /out /
2036

2137
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
2948

3049
FROM deps AS format
3150
RUN --mount=type=bind,target=.,rw \
@@ -39,4 +58,4 @@ COPY --from=format /out /
3958
FROM deps AS format-validate
4059
RUN --mount=type=bind,target=.,rw \
4160
--mount=type=cache,target=/src/node_modules \
42-
yarn run format-check \
61+
yarn run format-check

hack/vendor.Dockerfile

-23
This file was deleted.

0 commit comments

Comments
 (0)