From 65b2e9d1a75d43457a12b76ab9d9b69935a7f024 Mon Sep 17 00:00:00 2001 From: Klemek Date: Thu, 30 Apr 2026 14:11:51 +0200 Subject: [PATCH] initial commit --- README.md | 22 ++++++++++++++++++++++ action.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 README.md create mode 100644 action.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc35517 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Dockerfile test build + +```yaml +name: Docker Build CI +on: [ push ] + +env: + BUILDKIT_VERSION: 'v0.29.0' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/cache@v4 + with: + path: /var/lib/buildkit + key: ${{ runner.os }}-buildkit-${{ env.BUILDKIT_VERSION }} + - uses: https://git.klemek.fr/klemek/dockerfile-test-build@v1 + with: + buildkit_version: ${{ env.BUILDKIT_VERSION }} +``` \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..4382c6d --- /dev/null +++ b/action.yml @@ -0,0 +1,40 @@ +name: 'Dockerfile test build' +description: 'Test build of Dockerfile' +inputs: + dockerfile: + description: 'Dockerfile name' + required: true + default: '.' + context: + description: 'Build context' + required: true + default: '.' + buildkit_version: + description: 'Buildkit version' + required: true +runs: + using: "composite" + steps: + - name: Prepare buildkit directory + shell: bash + run: mkdir -p /var/lib/buildkit + + - name: Download buildkit binaries + shell: bash + run: | + wget -nc -O /var/lib/buildkit/buildkit.tar.gz \ + https://github.com/moby/buildkit/releases/download/${{ inputs.buildkit_version }}/buildkit-${{ inputs.buildkit_version }}.linux-amd64.tar.gz + + - name: Extract buildkit binaries + shell: bash + run: tar -xf /var/lib/buildkit/buildkit.tar.gz -C /var/lib/buildkit + + - name: Run buildkit build + shell: bash + run: | + /var/lib/buildkit/bin/buildkitd & \ + while [ ! -f /run/buildkit/buildkitd.sock ]; do sleep 0.1; done && \ + /var/lib/buildkit/bin/buildctl build \ + --frontend=dockerfile.v0 \ + --local context=${{ inputs.context }} \ + --local dockerfile=${{ inputs.dockerfile }} \ No newline at end of file