From 28355c7ca79238411630a610bc91222196eca857 Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Tue, 19 Dec 2023 11:51:08 +0100 Subject: [PATCH 1/3] Build & push docker images --- .github/workflows/release.yml | 1 + .github/workflows/release_docker.yml | 57 ++++++++++++++++++++++++++++ Dockerfile | 7 +++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release_docker.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7c17d6..f6bafc0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,7 @@ on: push: tags: - '*' + jobs: create_release: runs-on: ubuntu-latest diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml new file mode 100644 index 0000000..07101cf --- /dev/null +++ b/.github/workflows/release_docker.yml @@ -0,0 +1,57 @@ +name: Build and Publish Docker Image + +on: + push: + branches: [ master ] + tags: ["*"] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: [linux/amd64, linux/arm64] + steps: + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Log in to Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v1 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha + type=raw,value=latest-${{ matrix.platform }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ matrix.platform }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 44ba95a..761c85e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20.3-alpine +FROM golang:1.20.3-alpine as builder WORKDIR /app @@ -6,8 +6,13 @@ COPY go.mod go.sum ./ RUN go mod download && go mod verify COPY . . + +ENV CGO_ENABLED=0 RUN go build -v -o /usr/local/bin/gnark-mbu . +FROM gcr.io/distroless/base-debian11:nonroot + +COPY --from=builder /usr/local/bin/gnark-mbu /usr/local/bin/gnark-mbu VOLUME /mtb ENTRYPOINT [ "gnark-mbu" ] From a6d7009b3bf1a258a028143d65ab45f1e3bf608d Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Tue, 19 Dec 2023 11:54:48 +0100 Subject: [PATCH 2/3] Use tag --- .github/workflows/release_docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index 07101cf..ef49eed 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -34,7 +34,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch - type=ref,event=pr + type=ref,event=tag type=sha type=raw,value=latest-${{ matrix.platform }} From 282eb2b844a3238dfeafab879661ba0624c33b65 Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Tue, 19 Dec 2023 12:10:30 +0100 Subject: [PATCH 3/3] Update versions --- .github/workflows/release_docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index ef49eed..e6d1c5f 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -18,10 +18,10 @@ jobs: platform: [linux/amd64, linux/arm64] steps: - name: Check Out Repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Log in to Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -29,7 +29,7 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v1 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | @@ -45,7 +45,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: Dockerfile