mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-03-31 05:20:07 +02:00
add container based dev flow
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
80f3f35da3
commit
de88f925d4
5 changed files with 122 additions and 0 deletions
14
.github/CONTRIBUTING.md
vendored
14
.github/CONTRIBUTING.md
vendored
|
@ -14,6 +14,20 @@ Contributions to this project are [released](https://help.github.com/articles/gi
|
||||||
6. Push to your fork and [submit a pull request](https://github.com/docker/setup-buildx-action/compare)
|
6. Push to your fork and [submit a pull request](https://github.com/docker/setup-buildx-action/compare)
|
||||||
7. Pat yourself on the back and wait for your pull request to be reviewed and merged.
|
7. Pat yourself on the back and wait for your pull request to be reviewed and merged.
|
||||||
|
|
||||||
|
## Container based developer flow
|
||||||
|
|
||||||
|
If you don't want to maintain a Node developer environment that fits this project you can use containerized commands instead of invoking yarn directly.
|
||||||
|
|
||||||
|
```
|
||||||
|
# format code and build javascript artifacts
|
||||||
|
docker buildx bake pre-checkin
|
||||||
|
|
||||||
|
# validate all code has correctly formatted and built
|
||||||
|
docker buildx bake validate
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that tests target are currently known to not pass outside Github infrastructure.
|
||||||
|
|
||||||
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
|
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
|
||||||
|
|
||||||
- Make sure the `README.md` and any other relevant **documentation are kept up-to-date**.
|
- Make sure the `README.md` and any other relevant **documentation are kept up-to-date**.
|
||||||
|
|
9
.github/workflows/test.yml
vendored
9
.github/workflows/test.yml
vendored
|
@ -12,6 +12,15 @@ on:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test-containerized:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2.3.2
|
||||||
|
-
|
||||||
|
name: Validate
|
||||||
|
run: docker buildx bake validate
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
51
Dockerfile
Normal file
51
Dockerfile
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#syntax=docker/dockerfile:1.1-experimental
|
||||||
|
|
||||||
|
FROM node:14 AS deps
|
||||||
|
WORKDIR /src
|
||||||
|
COPY package.json yarn.lock ./
|
||||||
|
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
FROM scratch AS update-yarn
|
||||||
|
COPY --from=deps /src/yarn.lock /
|
||||||
|
|
||||||
|
FROM deps AS validate-yarn
|
||||||
|
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi
|
||||||
|
|
||||||
|
FROM deps AS base
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
FROM base AS build
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
FROM deps AS test
|
||||||
|
COPY --from=docker /usr/local/bin/docker /usr/bin/
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG BUILDX_VERSION=v0.4.2
|
||||||
|
ENV RUNNER_TEMP=/tmp/github_runner
|
||||||
|
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
||||||
|
RUN mkdir -p /usr/local/lib/docker/cli-plugins && \
|
||||||
|
curl -fsSL https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.$TARGETOS-$TARGETARCH > /usr/local/lib/docker/cli-plugins/buildx && \
|
||||||
|
chmod +x /usr/local/lib/docker/cli-plugins/buildx && \
|
||||||
|
docker buildx --version && env
|
||||||
|
COPY . .
|
||||||
|
RUN yarn run test
|
||||||
|
|
||||||
|
FROM base AS run-format
|
||||||
|
RUN yarn run format
|
||||||
|
|
||||||
|
FROM scratch AS format
|
||||||
|
COPY --from=run-format /src/src/*.ts /src/
|
||||||
|
|
||||||
|
FROM base AS validate-format
|
||||||
|
RUN yarn run format-check
|
||||||
|
|
||||||
|
FROM scratch AS dist
|
||||||
|
COPY --from=build /src/dist/ /dist/
|
||||||
|
|
||||||
|
FROM build AS validate-build
|
||||||
|
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi
|
||||||
|
|
||||||
|
FROM base AS dev
|
||||||
|
ENTRYPOINT ["bash"]
|
42
docker-bake.hcl
Normal file
42
docker-bake.hcl
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
group "default" {
|
||||||
|
targets = ["build"]
|
||||||
|
}
|
||||||
|
|
||||||
|
group "pre-checkin" {
|
||||||
|
targets = ["update-yarn", "format", "build"]
|
||||||
|
}
|
||||||
|
|
||||||
|
group "validate" {
|
||||||
|
targets = ["validate-format", "validate-build", "validate-yarn"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "update-yarn" {
|
||||||
|
target = "update-yarn"
|
||||||
|
output = ["."]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "build" {
|
||||||
|
target = "dist"
|
||||||
|
output = ["."]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "test" {
|
||||||
|
target = "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "format" {
|
||||||
|
target = "format"
|
||||||
|
output = ["."]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-format" {
|
||||||
|
target = "validate-format"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-build" {
|
||||||
|
target = "validate-build"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "validate-yarn" {
|
||||||
|
target = "validate-yarn"
|
||||||
|
}
|
6
hack/shell
Executable file
6
hack/shell
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
iidfile=$(mktemp -t docker-iidfile.XXXXXXXXXX)
|
||||||
|
DOCKER_BUILDKIT=1 docker build --iidfile $iidfile --progress=plain .
|
||||||
|
docker run -it --rm $(cat $iidfile)
|
||||||
|
docker rmi $(cat $iidfile)
|
Loading…
Add table
Reference in a new issue