From a9d4dda14837f2f187dfcba47076cc3aa11412b5 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 18 Oct 2023 16:10:26 -0400 Subject: [PATCH] feat: add docker release --- .github/workflows/release.yml | 38 ++++++++++++++++-- .goreleaser.yml | 7 ++-- Dockerfile | 40 +++---------------- dockers/goreleaser.Dockerfile | 4 +- ...{sedad.Dockerfile => seda-node.Dockerfile} | 0 5 files changed, 45 insertions(+), 44 deletions(-) rename dockers/{sedad.Dockerfile => seda-node.Dockerfile} (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5812a8b..eea3283e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,10 @@ name: Release on: push: tags: - # SemVer regex taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string - - "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" +# SemVer regex taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string +# Added option to start with a v for cases like v0.0.1 + - '^v?(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?' + concurrency: group: ci-${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true @@ -40,4 +42,34 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMET_VERSION: ${{ env.COMET_VERSION }} \ No newline at end of file + COMET_VERSION: ${{ env.COMET_VERSION }} + + build_psuh_node_image: + name: Build and Push Docker Image to GHCR + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/sedaprotocol/node + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./dockers/seda-node.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + diff --git a/.goreleaser.yml b/.goreleaser.yml index 27111349..fb576905 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -10,8 +10,8 @@ before: builds: - main: ./cmd/seda-chaind - id: "sedad" - binary: sedad + id: "seda-chaind" + binary: seda-chaind mod_timestamp: "{{ .CommitTimestamp }}" flags: - -tags=badgerdb ledger netgo @@ -45,6 +45,5 @@ changelog: dockers: - image_templates: - - ghcr.io/sedaprotocol/seda-chain:{{.Version}} - - dockerfile: "gorelease.Dockerfile" + - ghcr.io/sedaprotocol/seda-chaind:{{.Version}} - skip_push: false \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6fc8f963..d4b54459 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,5 @@ -FROM golang:1.21-alpine AS build-env - -# Install minimum necessary dependencies -ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev -RUN apk add --no-cache $PACKAGES - - -WORKDIR /go/src/github.com/sedaprotocol/seda-chain - -# Optimized fetching of dependencies -COPY go.mod go.sum ./ - -RUN go mod download - -# Copy and build the project -COPY . . - -# Dockerfile Cross-Compilation Guide -# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide -ARG TARGETOS TARGETARCH - - -RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build - - -FROM alpine:3 - -RUN apk add --no-cache curl make bash jq sed -COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/seda-chaid /usr/bin/seda-chaind - -EXPOSE 26656 26657 1317 9090 - -CMD ["seda-chaind", "start"] -STOPSIGNAL SIGTERM -WORKDIR /root +# This Dockerfile si for .gorelease purposesBuild: docker build -t seda-chaind . +# If you are looking for a Dockerfile to run a node, see dockers/seda-node.Dockerfile +FROM scratch +ENTRYPOINT ["/seda-chaind"] +COPY seda-chaind / diff --git a/dockers/goreleaser.Dockerfile b/dockers/goreleaser.Dockerfile index 6c0a9fbe..84f6b9c5 100644 --- a/dockers/goreleaser.Dockerfile +++ b/dockers/goreleaser.Dockerfile @@ -1,3 +1,3 @@ FROM scratch -ENTRYPOINT ["/sedad"] -COPY sedad / \ No newline at end of file +ENTRYPOINT ["/seda-chaind"] +COPY seda-chaind / \ No newline at end of file diff --git a/dockers/sedad.Dockerfile b/dockers/seda-node.Dockerfile similarity index 100% rename from dockers/sedad.Dockerfile rename to dockers/seda-node.Dockerfile