-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
/.dev | ||
/coverage | ||
/dist | ||
/lib | ||
/node_modules | ||
/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,67 @@ | ||
group "default" { | ||
targets = ["build"] | ||
variable "NODE_VERSION" { | ||
default = "12" | ||
} | ||
|
||
group "pre-checkin" { | ||
targets = ["update-yarn", "format", "build"] | ||
target "node-version" { | ||
args = { | ||
NODE_VERSION = NODE_VERSION | ||
} | ||
} | ||
|
||
group "validate" { | ||
targets = ["validate-format", "validate-build", "validate-yarn"] | ||
group "default" { | ||
targets = ["build"] | ||
} | ||
|
||
target "dockerfile" { | ||
dockerfile = "Dockerfile.dev" | ||
group "pre-checkin" { | ||
targets = ["vendor-update", "format", "build"] | ||
} | ||
|
||
target "update-yarn" { | ||
inherits = ["dockerfile"] | ||
target = "update-yarn" | ||
output = ["."] | ||
group "validate" { | ||
targets = ["format-validate", "build-validate", "vendor-validate"] | ||
} | ||
|
||
target "build" { | ||
inherits = ["dockerfile"] | ||
target = "dist" | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-update" | ||
output = ["."] | ||
} | ||
|
||
target "test" { | ||
inherits = ["dockerfile"] | ||
target = "test-coverage" | ||
output = ["."] | ||
target "build-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "build-validate" | ||
} | ||
|
||
target "format" { | ||
inherits = ["dockerfile"] | ||
target = "format" | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-update" | ||
output = ["."] | ||
} | ||
|
||
target "validate-format" { | ||
inherits = ["dockerfile"] | ||
target = "validate-format" | ||
target "format-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/build.Dockerfile" | ||
target = "format-validate" | ||
} | ||
|
||
target "vendor-update" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "update" | ||
output = ["."] | ||
} | ||
|
||
target "validate-build" { | ||
inherits = ["dockerfile"] | ||
target = "validate-build" | ||
target "vendor-validate" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/vendor.Dockerfile" | ||
target = "validate" | ||
} | ||
|
||
target "validate-yarn" { | ||
inherits = ["dockerfile"] | ||
target = "validate-yarn" | ||
target "test" { | ||
inherits = ["node-version"] | ||
dockerfile = "./hack/test.Dockerfile" | ||
target = "test-coverage" | ||
output = ["./coverage"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache cpio findutils git | ||
WORKDIR /src | ||
|
||
FROM base AS deps | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn install | ||
|
||
FROM deps AS build | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn run build && mkdir /out && cp -Rf dist /out/ | ||
|
||
FROM scratch AS build-update | ||
COPY --from=build /out / | ||
|
||
FROM build AS build-validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
git add -A && cp -rf /out/* .; \ | ||
if [ -n "$(git status --porcelain -- dist)" ]; then \ | ||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \ | ||
git status --porcelain -- dist; \ | ||
exit 1; \ | ||
fi | ||
|
||
FROM deps AS format | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn run format \ | ||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out | ||
|
||
FROM scratch AS format-update | ||
COPY --from=format /out / | ||
|
||
FROM deps AS format-validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn run format-check \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
WORKDIR /src | ||
|
||
FROM base AS deps | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn install | ||
|
||
FROM deps AS test | ||
ENV RUNNER_TEMP=/tmp/github_runner | ||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
--mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \ | ||
--mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \ | ||
yarn run test --coverageDirectory=/tmp/coverage | ||
|
||
FROM scratch AS test-coverage | ||
COPY --from=test /tmp/coverage / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
ARG NODE_VERSION | ||
|
||
FROM node:${NODE_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/src/node_modules \ | ||
yarn install && mkdir /out && cp yarn.lock /out | ||
|
||
FROM scratch AS update | ||
COPY --from=vendored /out / | ||
|
||
FROM vendored AS validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
git add -A && cp -rf /out/* .; \ | ||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \ | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ | ||
git status --porcelain -- yarn.lock; \ | ||
exit 1; \ | ||
fi |