Skip to content

Commit

Permalink
refactor: split in to multi image (#5)
Browse files Browse the repository at this point in the history
* refactor: allow unpack snapshot from local file

Signed-off-by: Artur Troian <[email protected]>

* refactor: split in to multi image

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Aug 9, 2023
1 parent 1b47bca commit 7e93f00
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 164 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ COSMOVISOR_VERSION=v1.5.0
GO_VERSION=1.20.6
GO_GETTER_VERSION=v0.2.2
GIT_CHGLOG_VERSION=v0.15.0
GO_TEMPLATE_VERSION=v0.4.3
64 changes: 29 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,55 @@
ARG GO_VERSION
ARG COSMOVISOR_VERSION
FROM ghcr.io/akash-network/cosmovisor-base:$COSMOVISOR_VERSION as cosmovisor

FROM debian:bullseye AS base
LABEL "org.opencontainers.image.source"="https://github.com/akash-network/cosmovisor"

ARG TARGETARCH
ARG GO_GETTER_VERSION
ARG GO_TEMPLATE_VERSION

SHELL ["/bin/bash", "-c"]

ENV LANG="en_US.UTF-8"

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
jq \
pv \
lz4 \
git \
tini \
curl \
wget \
jq \
ca-certificates \
unzip \
gzip \
libarchive-tools \
unzip \
netcat \
gettext-base \
build-essential \
git \
pv \
lz4 \
&& rm -rf /var/lib/apt/lists/* \
&& AWSCLI_ARCH=$(echo -n $TARGETARCH | sed -e 's/arm64/aarch64/g' | sed -e 's/amd64/x86_64/g') \
ca-certificates \
libarchive-tools \
&& rm -rf /var/lib/apt/lists/*

RUN \
AWSCLI_ARCH=$(echo -n $TARGETARCH | sed -e 's/arm64/aarch64/g' | sed -e 's/amd64/x86_64/g') \
&& wget -q "https://awscli.amazonaws.com/awscli-exe-linux-${AWSCLI_ARCH}.zip" -O awscli.zip \
&& unzip awscli.zip && rm awscli.zip \
&& ./aws/install \
&& rm -r aws \
&& git config --global advice.detachedHead "false"

FROM golang:${GO_VERSION}-bullseye as build

ARG GO_VERSION
ARG GO_GETTER_VERSION
ARG COSMOVISOR_VERSION

ENV GO111MODULE=on
ENV GOPROXY=https://proxy.golang.org,direct

SHELL ["/bin/bash", "-c"]

RUN git config --global advice.detachedHead "false"
&& rm -r aws

RUN GOBIN=/usr/bin go install github.com/schwarzit/go-template/cmd/gt@latest
RUN GOBIN=/usr/bin go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v${COSMOVISOR_VERSION}
RUN GOBIN=/usr/bin go install github.com/troian/go-getter@${GO_GETTER_VERSION}

FROM base
LABEL "org.opencontainers.image.source"="https://github.com/akash-network/cosmovisor"
RUN \
git config --global advice.detachedHead "false" \
&& wget https://github.com/SchwarzIT/go-template/releases/download/${GO_TEMPLATE_VERSION}/gt-linux-${TARGETARCH} -O /usr/bin/gt \
&& chmod +x /usr/bin/gt \
&& wget https://github.com/troian/go-getter/releases/download/${GO_GETTER_VERSION}/go-getter_linux_${TARGETARCH}.deb -O go-getter.deb \
&& dpkg -i go-getter.deb \
&& rm -f go-getter.deb

ARG GO_VERSION
ENV GO_VERSION=$GO_VERSION

COPY --from=build /usr/bin/cosmovisor /usr/bin
COPY --from=build /usr/bin/gt /usr/bin
COPY --from=build /usr/bin/go-getter /usr/bin

COPY --from=cosmovisor /usr/bin/cosmovisor /usr/bin
COPY ./scripts/entrypoint.sh /entrypoint.sh
COPY ./patches/ /config/patches

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.cosmovisor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG GO_VERSION

FROM golang:${GO_VERSION}-bullseye as build
LABEL "org.opencontainers.image.source"="https://github.com/akash-network/cosmovisor"

ENV GO111MODULE=on
ENV GOPROXY=https://proxy.golang.org,direct
Expand Down
50 changes: 41 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
include .env

REGISTRY ?= ghcr.io
TAG_VERSION ?= $(shell git describe --tags --abbrev=0)
TAG_VERSION ?= $(shell git describe --tags --abbrev=0 --match="v*")

ifeq ($(REGISTRY),)
IMAGE_NAME := akash-network/cosmovisor:$(TAG_VERSION)-$(COSMOVISOR_VERSION)
else
IMAGE_NAME := $(REGISTRY)/akash-network/cosmovisor:$(TAG_VERSION)-$(COSMOVISOR_VERSION)
IMAGE_NAME := akash-network/cosmovisor:$(TAG_VERSION)-$(COSMOVISOR_VERSION)
IMAGE_BASE_NAME := akash-network/cosmovisor-base:$(COSMOVISOR_VERSION)

ifneq ($(REGISTRY),)
IMAGE_NAME := $(REGISTRY)/$(IMAGE_NAME)
IMAGE_BASE_NAME := $(REGISTRY)/$(IMAGE_BASE_NAME)
endif

DOCKER_BUILD=docker build
Expand All @@ -21,29 +23,59 @@ gen-changelog:

.PHONY: cosmovisor-%
cosmovisor-%:
@echo "building $(IMAGE_NAME)-$(@:cosmovisor-%=%)"
$(DOCKER_BUILD) --platform=linux/$(@:cosmovisor-%=%) -t $(IMAGE_NAME)-$(@:cosmovisor-%=%) \
@echo "building $(IMAGE_NAME)-$*"
$(DOCKER_BUILD) --platform=linux/$* -t $(IMAGE_NAME)-$* \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg COSMOVISOR_VERSION=$(COSMOVISOR_VERSION) \
--build-arg GO_GETTER_VERSION=$(GO_GETTER_VERSION) \
--build-arg GO_TEMPLATE_VERSION=$(GO_TEMPLATE_VERSION) \
-f Dockerfile .

.PHONY: cosmovisor-base-%
cosmovisor-base-%:
@echo "building $(IMAGE_BASE_NAME)-$*"
$(DOCKER_BUILD) --platform=linux/$* -t $(IMAGE_BASE_NAME)-$* \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg COSMOVISOR_VERSION=$(COSMOVISOR_VERSION) \
-f Dockerfile.cosmovisor .

.PHONY: cosmovisor
cosmovisor: $(patsubst %, cosmovisor-%,$(SUBIMAGES))

.PHONY: cosmovisor-base
cosmovisor-base: $(patsubst %, cosmovisor-base-%,$(SUBIMAGES))

.PHONY: docker-push-%
docker-push-%:
docker push $(IMAGE_NAME)-$(@:docker-push-%=%)
docker push $(IMAGE_NAME)-$*

.PHONY: docker-push-base-%
docker-push-base-%:
docker push $(IMAGE_BASE_NAME)-$*

.PHONY: docker-push
docker-push: $(patsubst %, docker-push-%,$(SUBIMAGES))

.PHONY: manifest-create
manifest-create:
@echo "creating manifest $(IMAGE_NAME)"
docker manifest create $(IMAGE_NAME) $(foreach arch,$(SUBIMAGES), --amend $(IMAGE_NAME)-$(arch))
docker manifest rm $(IMAGE_NAME) 2>/dev/null || true
docker manifest create $(IMAGE_NAME) \
$(foreach arch,$(SUBIMAGES), $(shell docker inspect $(IMAGE_NAME)-$(arch) | jq -r '.[].RepoDigests | .[0]'))

.PHONY: manifest-create-base
manifest-create-base:
@echo "creating base manifest $(IMAGE_BASE_NAME)"
docker manifest rm $(IMAGE_BASE_NAME) 2>/dev/null || true
docker manifest create $(IMAGE_BASE_NAME) \
$(foreach arch,$(SUBIMAGES), $(shell docker inspect $(IMAGE_BASE_NAME)-$(arch) | jq -r '.[].RepoDigests | .[0]'))

.PHONY: manifest-push
manifest-push:
@echo "pushing manifest $(IMAGE_NAME)"
docker manifest push $(IMAGE_NAME)

.PHONY: manifest-push-base
manifest-push-base:
@echo "pushing base manifest $(IMAGE_BASE_NAME)"
docker manifest push $(IMAGE_BASE_NAME)
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Image version corresponds to the version of the [cosmovisor](https://github.com/

## Tested mainnet chains
- Akash
- Sifchain
- Rebus
- Stride

Expand Down
12 changes: 0 additions & 12 deletions examples/sifchain/.env

This file was deleted.

43 changes: 0 additions & 43 deletions examples/sifchain/docker-compose.yaml

This file was deleted.

1 change: 0 additions & 1 deletion examples/sifchain/rpc/node_key.json

This file was deleted.

11 changes: 0 additions & 11 deletions examples/sifchain/rpc/priv_validator_key.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/sifchain/validator/node_key.json

This file was deleted.

11 changes: 0 additions & 11 deletions examples/sifchain/validator/priv_validator_key.json

This file was deleted.

Loading

0 comments on commit 7e93f00

Please sign in to comment.