-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dockerization of rosetta (#37)
* added dockerfile container * added git action * changed workflow name * reworked the docker build workflow
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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: | ||
paths: | ||
- "Dockerfile" | ||
push: | ||
branches: | ||
- main | ||
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 <account>/<repo> | ||
IMAGE_NAME: cosmos/rosetta | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
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: 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: | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |