Skip to content

Commit

Permalink
chore: add cosmosvisor dockerfile (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code committed May 31, 2024
1 parent 0c9b3e7 commit c8c9460
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 161 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ build
dist
node_modules
proto
artifacts
artifacts
Dockerfile
*.Dockerfile
102 changes: 96 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ on:
pull_request:
paths:
- 'Dockerfile'
- 'cosmovisor.Dockerfile'
- 'cosmovisor_lite.Dockerfile'
- '.github/workflows/docker.yml'

permissions:
packages: write
contents: read

jobs:
build_and_push:
name: Push Docker image to multiple registries
fxcore:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -55,4 +57,92 @@ jobs:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}

cosmovisor_lite:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/fxcorevisor_lite
${{ secrets.DOCKER_HUB_USERNAME }}/fxcorevisor_lite
tags: |
type=semver,pattern={{version}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
file: ./cosmovisor_lite.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}

cosmovisor:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/fxcorevisor
${{ secrets.DOCKER_HUB_USERNAME }}/fxcorevisor
tags: |
type=semver,pattern={{version}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
file: ./cosmovisor.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/make -f

GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')
GIT_TAGS := $(shell git describe --tags --always 2>/dev/null || echo 'unknown')
VERSION := $(GIT_BRANCH)-$(GIT_TAGS)
VERSION := $(shell git describe --tags --always 2>/dev/null || echo 'unknown')
COMMIT := $(shell git log -1 --format='%H' 2>/dev/null || echo 'unknown')

LEDGER_ENABLED ?= true
Expand Down
74 changes: 0 additions & 74 deletions contrib/upgrade/run-cosmovisor.sh

This file was deleted.

61 changes: 0 additions & 61 deletions contrib/upgrade/run-upgrade.sh

This file was deleted.

15 changes: 0 additions & 15 deletions contrib/upgrade/run.sh

This file was deleted.

64 changes: 64 additions & 0 deletions cosmovisor.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM golang:1.21.4-alpine3.18 as builder

RUN apk add --no-cache git build-base linux-headers

RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0

WORKDIR /app

COPY . .

RUN make build

FROM functionx/fx-core:1.1.4 as fxv1
FROM functionx/fx-core:2.4.3 as fxv2
FROM functionx/fx-core:3.1.2 as fxv3
FROM functionx/fx-core:4.0.1-rc1 as fxv4
FROM functionx/fx-core:4.1.1-rc0 as fxv4_1
FROM functionx/fx-core:4.2.2 as fxv4_2
FROM functionx/fx-core:5.0.0 as fxv5
FROM functionx/fx-core:6.0.0 as fxv6
FROM functionx/fx-core:7.0.1-rc0 as fxv7
FROM functionx/fx-core:7.1.0-rc1 as fxv7_1
FROM functionx/fx-core:7.2.0-rc2 as fxv7_2

FROM alpine:3.18

WORKDIR /root

ENV DAEMON_HOME=/root/.fxcore
ENV DAEMON_NAME=fxcored
ENV DAEMON_ALLOW_DOWNLOAD_BINARIES=false
ENV DAEMON_DOWNLOAD_MUST_HAVE_CHECKSUM=false
ENV DAEMON_RESTART_AFTER_UPGRADE=true
ENV DAEMON_RESTART_DELAY=1s
ENV DAEMON_POLL_INTERVAL=3s
ENV UNSAFE_SKIP_BACKUP=true
ENV DAEMON_PREUPGRADE_MAX_RETRIES=3
ENV COSMOVISOR_DISABLE_LOGS=false
ENV COSMOVISOR_COLOR_LOGS=true

COPY --from=builder /go/bin/cosmovisor /usr/bin/cosmovisor
COPY --from=builder /app/build/bin/fxcored /usr/bin/fxcored

# The copy directory needs to be changed in the next version
COPY --from=fxv1 /usr/bin/fxcored /root/.fxcore/cosmovisor/genesis/bin/fxcored
COPY --from=fxv2 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/fxv2/bin/fxcored
COPY --from=fxv3 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/fxv3/bin/fxcored
COPY --from=fxv4 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/fxv4/bin/fxcored
COPY --from=fxv4_1 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v4.1.x/bin/fxcored
COPY --from=fxv4_2 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v4.2.x/bin/fxcored
COPY --from=fxv5 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v5.0.x/bin/fxcored
COPY --from=fxv6 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v6.0.x/bin/fxcored
COPY --from=fxv7 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v7.0.x/bin/fxcored
COPY --from=fxv7_1 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v7.1.x/bin/fxcored
COPY --from=fxv7_2 /usr/bin/fxcored /root/.fxcore/cosmovisor/upgrades/v7.2.x/bin/fxcored

RUN cosmovisor init /root/.fxcore/cosmovisor/genesis/bin/fxcored

EXPOSE 26656/tcp 26657/tcp 26660/tcp 9090/tcp 1317/tcp 8545/tcp 8546/tcp

VOLUME ["/root"]

ENTRYPOINT ["cosmovisor", "run"]

Loading

0 comments on commit c8c9460

Please sign in to comment.