diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..9855a68 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,72 @@ +# Copyright 2025 Cockroach Labs, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +name: Docker +permissions: + contents: read +on: + push: + tags: [ 'v*.*.*' ] + # PR's will trigger an image build, but the push action is disabled. + pull_request: + workflow_dispatch: + inputs: + build_binaries: + description: 'Docker' + type: boolean + required: false +jobs: + docker: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to ghcr.io + if: github.event_name != 'pull_request' + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + labels: | + org.opencontainers.image.title=Blobcheck + org.opencontainers.image.vendor=Cockroach Labs Inc. + org.opencontainers.image.descripton=Prototype, not officially supported + - name: Build and push + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..edcc76b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Copyright 2025 Cockroach Labs, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +FROM golang:1.24.6-alpine3.21 AS builder +WORKDIR /tmp/compile +COPY . . +RUN CGO_ENABLED=0 go build -v -ldflags="-s -w " -o /usr/bin/blobcheck . + +FROM scratch +WORKDIR /data/ +ENTRYPOINT ["/usr/bin/blobcheck"] +COPY --from=builder /usr/bin/blobcheck /usr/bin/