From ec65d76dea22d56e695f045ff3c304c8cefdfa53 Mon Sep 17 00:00:00 2001 From: bizk Date: Thu, 14 Sep 2023 17:28:13 -0300 Subject: [PATCH 1/4] added dockerfile container --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7850725 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.20 AS build-env + +# Set working directory for the build +WORKDIR /go/src/github.com/cosmos/rosetta + +# optimization: if go.sum didn't change, docker will use cached image +COPY go.mod go.sum ./ + +RUN go mod download + +# Add source files +COPY . . + +RUN make build +RUN make plugin + +EXPOSE 8080 + +# Run simd by default +CMD ["./rosetta", "--blockchain", "app", "--network", "network", "--tendermint", "cosmos:26657", "--grpc", "cosmos:9090", "--addr", ":8080"] +ENTRYPOINT ["./rosetta"] +STOPSIGNAL SIGTERM \ No newline at end of file From 7a1b596de3fd1e4116f50be04953d021925d6ea1 Mon Sep 17 00:00:00 2001 From: bizk Date: Thu, 14 Sep 2023 17:53:27 -0300 Subject: [PATCH 2/4] added git action --- .github/workflows/build-docker.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/build-docker.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 0000000..8d58c77 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,36 @@ +name: Build rosetta +# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed +on: + pull_request: + merge_group: + push: + branches: + - main + - release/** +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: false + tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest \ No newline at end of file From 9b62115d4b3a0bb9da5b81c9dafeba0ed316ce4e Mon Sep 17 00:00:00 2001 From: bizk Date: Thu, 14 Sep 2023 17:55:11 -0300 Subject: [PATCH 3/4] changed workflow name --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 8d58c77..124ff50 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,4 +1,4 @@ -name: Build rosetta +name: Build rosetta docker container # This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed on: pull_request: From 031a2e142696af2a2faa116bc24182fe64b5765c Mon Sep 17 00:00:00 2001 From: bizk Date: Fri, 15 Sep 2023 21:53:54 -0300 Subject: [PATCH 4/4] reworked the docker build workflow --- .github/workflows/build-docker.yml | 68 ++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 124ff50..188b936 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -2,35 +2,67 @@ name: Build rosetta docker container # This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed on: pull_request: - merge_group: + paths: + - "Dockerfile" push: branches: - main - - release/** + tags: + - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5 + workflow_dispatch: + inputs: + tags: + description: "Rosetta version (e.g 0.47.1)" + required: true + type: string + permissions: contents: read + packages: write + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: cosmos/rosetta jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v4 - - - name: Login to Docker Hub - uses: docker/login-action@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern={{version}},value=v${{ inputs.tags }},enable=${{ inputs.tags != '' }} + flavor: | + latest=false + + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - - name: Build and push + + - name: Log into registry ${{ env.REGISTRY }} + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to GitHub Packages uses: docker/build-push-action@v5 with: - context: . - file: ./Dockerfile - push: false - tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest \ No newline at end of file + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file