Skip to content

Commit

Permalink
[CI] Add cosmovisor to container images (#796)
Browse files Browse the repository at this point in the history
## Summary

Add cosmovisor binary to our container images. It will allow us to use
cosmovisor in
[docker-compose-example](https://github.com/pokt-network/poktroll-docker-compose-example)
repo in the future to automate upgrades.

## Type of change

Select one or more from the following:

- [ ] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Documentation
- [x] Other - tooling

## Testing

No code was changed - no reason for extensive testing.

- Tested Dockerfile.release locally and Dockerfile.dev will be tested by
CI.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable
  • Loading branch information
okdas authored Sep 9, 2024
1 parent 93ccae9 commit d0a379a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
make ignite_update_ldflags
make ignite_release
make ignite_release_extract_binaries
make cosmovisor_cross_compile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ gentx-*.json
cmd/poktrolld/*debug_bin*

# The temporary file created by e2e scripts
job.yaml
job.yaml

# tmp directory for locally produced artifacts
tmp/*
3 changes: 3 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ WORKDIR /poktroll

RUN mv /poktroll/bin/ignite /usr/bin/ && mv /poktroll/bin/poktrolld /usr/bin/

# Install Cosmovisor
RUN make install_cosmovisor

# These are helpful for testing locally:
# RUN mv bin/poktrolld /usr/bin/
# RUN mv bin/ignite /usr/bin/
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This Dockerfile is used to build container image for production workloads.
# It relies on the binaries produced by `ignite_release` and `ignite_release_extract_binaries` make targets.
# It relies on the binaries produced by `cosmovisor_cross_compile`, `ignite_release` and `ignite_release_extract_binaries` make targets.
FROM alpine:3.19
ARG TARGETARCH

Expand All @@ -10,6 +10,7 @@ RUN addgroup --gid 1025 -S pocket && adduser --uid 1025 -S pocket -G pocket
RUN apk add --no-cache gcompat

COPY --chown=pocket:pocket release_binaries/poktroll_linux_$TARGETARCH /bin/poktrolld
COPY --chown=pocket:pocket tmp/cosmovisor-linux-$TARGETARCH /bin/cosmovisor

USER pocket

Expand Down
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,35 @@ install_ci_deps: ## Installs `mockgen` and other go tools
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/mikefarah/yq/v4@latest

.PHONY: install_cosmovisor
install_cosmovisor: ## Installs `cosmovisor`
go install cosmossdk.io/tools/cosmovisor/cmd/[email protected] && cosmovisor version --cosmovisor-only

.PHONY: cosmovisor_cross_compile
cosmovisor_cross_compile: # Installs multiple cosmovisor binaries for different platforms (used by Dockerfile.release)
@COSMOVISOR_VERSION="v1.6.0"; \
PLATFORMS="linux/amd64 linux/arm64"; \
mkdir -p ./tmp; \
echo "Fetching Cosmovisor source..."; \
temp_dir=$$(mktemp -d); \
cd $$temp_dir; \
go mod init temp; \
go get cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@$$COSMOVISOR_VERSION; \
for platform in $$PLATFORMS; do \
OS=$${platform%/*}; \
ARCH=$${platform#*/}; \
echo "Compiling for $$OS/$$ARCH..."; \
GOOS=$$OS GOARCH=$$ARCH go build -o $(CURDIR)/tmp/cosmovisor-$$OS-$$ARCH cosmossdk.io/tools/cosmovisor/cmd/cosmovisor; \
done; \
cd $(CURDIR); \
rm -rf $$temp_dir; \
echo "Compilation complete. Binaries are in ./tmp/"; \
ls -l ./tmp/cosmovisor-*

.PHONY: cosmovisor_clean
cosmovisor_clean:
rm -f ./tmp/cosmovisor-*

########################
### Makefile Helpers ###
########################
Expand Down

0 comments on commit d0a379a

Please sign in to comment.