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" ]