From a5aef256c0d14bb0b3f3ad3f0f298e7148b0d8b2 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Mon, 15 Aug 2022 10:44:13 +0100 Subject: [PATCH] build: Optimise Docker build (#365) --- .dockerignore | 12 ++++++------ .github/workflows/build.yml | 3 --- .github/workflows/release.yml | 15 ++++++++++++--- .goreleaser.yml | 2 +- docker/Dockerfile | 2 +- proto/buf.md | 0 proto/buf.yaml | 4 ++-- 7 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 proto/buf.md diff --git a/.dockerignore b/.dockerignore index 5fef7439a..5c5b33a5f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,11 +2,11 @@ **/*.md # Skip build/test folders -build-tools/ -installer/ -networks/ -tests/ +build-tools/** +installer/** +networks/** +tests/** # Skip Git-related folders -.github -.git +.github/** +**/.git diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3581c3740..d20f3593f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,9 +54,6 @@ jobs: go-version-file: ./go.mod cache: true - - name: Generate Protobufs - run: make proto-gen - - name: Setup Docker Buildx uses: docker/setup-buildx-action@v2 id: buildx diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a69b85782..13848c5d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Required to fetch version + persist-credentials: false - uses: actions/setup-go@v3 with: @@ -34,6 +35,10 @@ jobs: cache: 'npm' cache-dependency-path: '**/package-lock.json' + # Setup for pushing to Buf.build later + - uses: bufbuild/buf-setup-action@v1.7.0 + + # Required for short-lived token provided to Semantic Release - name: "Obtain Github App token" id: app-token uses: getsentry/action-github-app-token@v1.0.6 @@ -64,6 +69,12 @@ jobs: RELEASE_VERSION=$( git describe --tags ${{ github.sha }}) echo ::set-output name=RELEASE_VERSION::"$RELEASE_VERSION" + # Push Protobufs to Buf.build registry + - uses: bufbuild/buf-push-action@v1 + with: + input: proto + buf_token: ${{ secrets.BUF_TOKEN }} + release-docker: name: "Docker image" needs: release-binary @@ -73,15 +84,13 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Required to fetch version + persist-credentials: false - uses: actions/setup-go@v3 with: go-version-file: ./go.mod cache: true - - name: Generate golang code - run: make proto-gen - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 id: buildx diff --git a/.goreleaser.yml b/.goreleaser.yml index 69732b4d9..84228dfe4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -50,7 +50,7 @@ checksum: algorithm: sha256 changelog: - use: github + use: github-native sort: asc groups: - title: Features diff --git a/docker/Dockerfile b/docker/Dockerfile index 48123fae2..155be4c9d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,7 +15,7 @@ WORKDIR /go/src/github.com/cheqd/cheqd-node COPY . . # Make node binary -RUN make install && make build +RUN go mod download && make build-linux ############################################################### ### STAGE 2: Build cheqd-node image ### diff --git a/proto/buf.md b/proto/buf.md new file mode 100644 index 000000000..e69de29bb diff --git a/proto/buf.yaml b/proto/buf.yaml index c6c00347a..9020e62f4 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -1,8 +1,8 @@ -# Buf Build config for cheqd-node DID module +# Buf Build config for cheqd Cosmos SDK modules version: v1 -name: buf.build/cheqd/cheqd-node +name: buf.build/cheqd/cheqd-proto deps: - buf.build/cosmos/cosmos-sdk