diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index f7fb65b..95c8e73 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -28,12 +28,22 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-and-push-image: + build: runs-on: ubuntu-latest permissions: contents: read packages: write + strategy: + matrix: + os: [linux] + arch: [amd64, arm64] + + # Exclude arm64 build in pull requests + is_pr: ["${{github.event_name == 'pull_request'}}"] + exclude: + - { is_pr: true, arch: arm64 } + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -41,15 +51,8 @@ jobs: fetch-depth: 0 fetch-tags: true - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 - name: "Generate Build ID (main)" if: github.ref == 'refs/heads/main' && github.event_name == 'push' @@ -72,6 +75,16 @@ jobs: - name: 'Generate App Version' run: echo "VERSION=$(make version)" >> $GITHUB_ENV + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4 @@ -90,8 +103,8 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max + platforms: ${{ matrix.os }}/${{ matrix.arch }} + cache-from: type=gha,scope=${{ matrix.os }}/${{ matrix.arch }} + cache-to: type=gha,mode=max,scope=${{ matrix.os }}/${{ matrix.arch }} build-args: | VERSION=${{ env.VERSION }} diff --git a/Dockerfile b/Dockerfile index 45efc94..621c105 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,11 @@ COPY go.mod ./ COPY go.sum ./ RUN go mod download +# Then copy the rest of the source code and build COPY . ./ - RUN make build -# Final +# Final image FROM alpine:3.18 RUN apk upgrade && apk add --no-cache bash curl diff --git a/go.mod b/go.mod index 419424c..ea09a71 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/kilnfi/cosmos-validator-watcher go 1.20 require ( + cosmossdk.io/math v1.0.1 github.com/avast/retry-go/v4 v4.5.0 github.com/cometbft/cometbft v0.37.2 github.com/cosmos/cosmos-sdk v0.47.4 @@ -22,7 +23,6 @@ require ( cosmossdk.io/core v0.5.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.3 // indirect cosmossdk.io/errors v1.0.0 // indirect - cosmossdk.io/math v1.0.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -111,7 +111,7 @@ require ( golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.11.0 // indirect + golang.org/x/sys v0.10.0 // indirect golang.org/x/term v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect diff --git a/go.sum b/go.sum index 9fda80a..fbc4fac 100644 --- a/go.sum +++ b/go.sum @@ -680,8 +680,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=