From 559a0532affb9f5f8941c5ebe079b1bb905c7cdf Mon Sep 17 00:00:00 2001 From: Prasad Lohakpure Date: Thu, 12 Mar 2026 14:14:11 +0530 Subject: [PATCH 1/5] FEAT: Release workflow for docker image --- .github/workflows/release.yaml | 30 ++++++++++++++++++++++++++++++ build/Dockerfile | 13 +++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 build/Dockerfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3c78f13..64a9c55 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,6 +4,8 @@ on: push: tags: - 'v*' + branches: + - 'main' jobs: release: @@ -23,6 +25,7 @@ jobs: CGO_ENABLED=0 GOOS=linux go build -o caterpillar ./cmd/caterpillar/caterpillar.go - name: Create Release + if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v2 with: files: caterpillar @@ -31,3 +34,30 @@ jobs: prerelease: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract taggerdata for Docker + id: tagger + uses: docker/metadata-action@v5 + with: + images: patternoss/caterpillar + tags: | + type=semver,pattern={{major}}.{{minor}}.{{patch}} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.tagger.outputs.tags }} + platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..5958ab6 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:1.24.7-alpine AS builder + +WORKDIR /go/src/github.com/patterninc/caterpillar + +COPY . . + +# build executable +RUN go build -o caterpillar ./cmd/caterpillar/caterpillar.go +RUN chmod 777 caterpillar + +FROM alpine:3.20 +RUN mkdir -p /output +COPY --from=builder /go/src/github.com/patterninc/caterpillar/caterpillar /patterninc/caterpillar/ From 9305560ace0630a733fbed282e1e131a94583cfd Mon Sep 17 00:00:00 2001 From: Prasad Lohakpure Date: Thu, 12 Mar 2026 14:40:40 +0530 Subject: [PATCH 2/5] Change in context --- .github/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 64a9c55..7a4c0f3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -58,6 +58,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . + file: ./build/Dockerfile push: true tags: ${{ steps.tagger.outputs.tags }} platforms: linux/amd64,linux/arm64 \ No newline at end of file From 7e2db22418840ccd4fa9176392d9a4b4eb3f737f Mon Sep 17 00:00:00 2001 From: prasadlohakpure Date: Thu, 12 Mar 2026 14:46:29 +0530 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/release.yaml | 2 +- build/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7a4c0f3..172c407 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -44,7 +44,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Extract taggerdata for Docker + - name: Extract metadata for Docker id: tagger uses: docker/metadata-action@v5 with: diff --git a/build/Dockerfile b/build/Dockerfile index 5958ab6..c108a78 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -6,7 +6,7 @@ COPY . . # build executable RUN go build -o caterpillar ./cmd/caterpillar/caterpillar.go -RUN chmod 777 caterpillar +RUN chmod 755 caterpillar FROM alpine:3.20 RUN mkdir -p /output From 4b1a4536f4bea8c5fe344d345abdb6c09b286fd8 Mon Sep 17 00:00:00 2001 From: prasadlohakpure Date: Mon, 16 Mar 2026 13:06:34 +0530 Subject: [PATCH 4/5] Update COPY command in Dockerfile path --- build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Dockerfile b/build/Dockerfile index c108a78..413949c 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -10,4 +10,4 @@ RUN chmod 755 caterpillar FROM alpine:3.20 RUN mkdir -p /output -COPY --from=builder /go/src/github.com/patterninc/caterpillar/caterpillar /patterninc/caterpillar/ +COPY --from=builder /go/src/github.com/patterninc/caterpillar/caterpillar /caterpillar/ From 278053caf1cff1b442df6f9d0068bc6578560be0 Mon Sep 17 00:00:00 2001 From: prasadlohakpure Date: Mon, 16 Mar 2026 13:14:02 +0530 Subject: [PATCH 5/5] Update Dockerfile to change copy destination --- build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Dockerfile b/build/Dockerfile index 413949c..10570a4 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -10,4 +10,4 @@ RUN chmod 755 caterpillar FROM alpine:3.20 RUN mkdir -p /output -COPY --from=builder /go/src/github.com/patterninc/caterpillar/caterpillar /caterpillar/ +COPY --from=builder /go/src/github.com/patterninc/caterpillar/caterpillar .