Skip to content

Commit

Permalink
Merge pull request #479 from crazy-max/dockerfile-validate
Browse files Browse the repository at this point in the history
dockerfile validation
  • Loading branch information
crazy-max authored Oct 30, 2024
2 parents 6f86e02 + f06ec3b commit e84b18a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ jobs:
prepare:
runs-on: ubuntu-20.04
outputs:
targets: ${{ steps.targets.outputs.matrix }}
targets: ${{ steps.generate.outputs.targets }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Matrix
id: targets
run: |
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
name: List targets
id: generate
uses: docker/bake-action/subaction/list-targets@v5
with:
target: validate

validate:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/node_modules \
yarn run lint

FROM docker:${DOCKER_VERSION} as docker
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
FROM crazymax/undock:${UNDOCK_VERSION} as undock
FROM docker:${DOCKER_VERSION} AS docker
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
FROM crazymax/undock:${UNDOCK_VERSION} AS undock

FROM deps AS test
RUN --mount=type=bind,target=.,rw \
Expand Down
14 changes: 13 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ group "pre-checkin" {
}

group "validate" {
targets = ["lint", "vendor-validate", "license-validate"]
targets = ["lint", "vendor-validate", "dockerfile-validate", "license-validate"]
}

target "build" {
Expand Down Expand Up @@ -54,6 +54,18 @@ target "vendor-validate" {
output = ["type=cacheonly"]
}

target "dockerfile-validate" {
matrix = {
dockerfile = [
"dev.Dockerfile",
"./hack/dockerfiles/license.Dockerfile"
]
}
name = "dockerfile-validate-${md5(dockerfile)}"
dockerfile = dockerfile
call = "check"
}

target "test" {
dockerfile = "dev.Dockerfile"
target = "test"
Expand Down

0 comments on commit e84b18a

Please sign in to comment.