Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev environment - localnet-1 #96

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 48 additions & 30 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,69 @@
# source: https://docs.github.com/en/enterprise-cloud@latest/actions/publishing-packages/publishing-docker-images
name: Create and publish a Docker image

on:
push:
branches: ['release']
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write

jobs:
build-and-push-image:
build-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=semver,pattern={{version}}

- name: Build and push Docker image
uses: docker/[email protected]
- name: Go Build Cache for Docker
id: cache
uses: actions/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-cache-

- name: inject go-build-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"go-pkg-mod": "/go/pkg/mod",
"go-build-cache": "/root/.cache/go-build"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build and push e2e docker image
uses: docker/build-push-action@v5.1.0
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.e2e
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}-e2e
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
ARG GO_VERSION
ARG IMG_TAG=latest

# Compile the atomoned binary
FROM golang:1.22-alpine AS atomoned-builder
FROM golang:$GO_VERSION-alpine AS builder
WORKDIR /src/app/
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
ENV PACKAGES="curl make git libc-dev bash gcc linux-headers eudev-dev python3"
RUN apk add --no-cache $PACKAGES
RUN CGO_ENABLED=0 make install

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 make install

# Add to a distroless container
FROM cgr.dev/chainguard/static:$IMG_TAG
FROM alpine:$IMG_TAG
RUN adduser -D nonroot
ARG IMG_TAG
COPY --from=atomoned-builder /go/bin/atomoned /usr/local/bin/
COPY --from=builder /go/bin/atomoned /usr/local/bin/
EXPOSE 26656 26657 1317 9090
USER 0
USER nonroot

ENTRYPOINT ["atomoned", "start"]
ENTRYPOINT ["atomoned"]
CMD ["start"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ endif
.PHONY: run-tests $(TEST_TARGETS)

docker-build-debug:
@docker build -t cosmos/atomoned-e2e -f e2e.Dockerfile --build-arg GO_VERSION=$(GO_REQUIRED_VERSION) .
@docker build -t cosmos/atomoned-e2e -f Dockerfile --build-arg GO_VERSION=$(GO_REQUIRED_VERSION) .

docker-build-hermes:
@cd tests/e2e/docker; docker build -t ghcr.io/cosmos/hermes-e2e:1.0.0 -f hermes.Dockerfile .
Expand Down
19 changes: 19 additions & 0 deletions contrib/localnet-1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Localnet-1

This is a quick way to setup a node with current branch version

:warn: This localnet don't persist data on disk

## How to use

```sh
docker compose up -d --build
```

## Endpoints

- P2P http://localhost:26656
- RPC http://localhost:26657
- API http://localhost:1317
- gRPC localhost:9090
- gRPC web localhost:9091
17 changes: 17 additions & 0 deletions contrib/localnet-1/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
services:
atomone:
image: ghcr.io/atomone-hub/atomone:dev
build:
context: ../..
args:
GO_VERSION: ${GO_VERSION}
entrypoint: ["/bin/sh", "/entrypoint.sh"]
volumes:
- ./entrypoint.sh:/entrypoint.sh
ports:
- 1317:1317
- 9090:9090
- 9091:9091
- 26656:26656
- 26657:26657
49 changes: 49 additions & 0 deletions contrib/localnet-1/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

CHAIN_ID="localnet-1"

WALLET_VALIDATOR_ADDR="atone16zau0ntu4xqm58c537e5zwrnkq4s5zpdpxmwz7"
WALLET_VALIDATOR_MNEMONIC="safe permit shrug crumble snap tree law observe melt ramp exit lazy lend few elephant idle now debris soldier split course movie pepper afraid"

WALLET_1_ADDR="atone19j38cmss7m3h4d0fptfwgltfsnhhw583y7h2ay"
WALLET_1_MNEMONIC="enjoy insect mimic number swamp trade obvious swamp stick give stool clarify bulk recipe minimum happy chunk coast suffer dutch high race trumpet sock"

WALLET_2_ADDR="atone1083ytsqvwml9vcytzn79x0dxv027apfthrtsda"
WALLET_2_MNEMONIC="slam tree stamp write hole race unusual erosion express toy pulp domain scan power hawk ball combine that olympic solve loud talk saddle total"

WALLET_3_ADDR="atone1dpspzdsd7nsch65n5dgalqd9ydcuc5nxs9s2x7"
WALLET_3_MNEMONIC="escape daring note begin cattle smooth you forget business vault mirror charge pilot few message corn equip asset nose snake scale sudden practice rib"

atomoned init localnet --chain-id "${CHAIN_ID}" --default-denom="uatone"

atomoned config keyring-backend test

echo "${WALLET_VALIDATOR_MNEMONIC}" | atomoned keys add validator --recover
echo "${WALLET_1_MNEMONIC}" | atomoned keys add wallet-1 --recover
echo "${WALLET_2_MNEMONIC}" | atomoned keys add wallet-2 --recover
echo "${WALLET_3_MNEMONIC}" | atomoned keys add wallet-3 --recover

# Add 100_000_000 $ATONE to all wallets
atomoned genesis add-genesis-account $WALLET_VALIDATOR_ADDR 100000000000uatone

atomoned genesis add-genesis-account $WALLET_1_ADDR 100000000000uatone
atomoned genesis add-genesis-account $WALLET_2_ADDR 100000000000uatone
atomoned genesis add-genesis-account $WALLET_3_ADDR 100000000000uatone

# gentx 10 $ATONE
atomoned genesis gentx validator 10000000uatone --chain-id ${CHAIN_ID}
atomoned genesis collect-gentxs
atomoned genesis validate-genesis

# RPC
sed -i 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' $HOME/.atomone/config/config.toml

# REST
sed -i 's|address = "tcp://localhost:1317"|address = "tcp://0.0.0.0:1317"|g' $HOME/.atomone/config/app.toml
sed -i 's|enable = false|enable = true|g' $HOME/.atomone/config/app.toml

# GRPC
sed -i 's|address = "localhost:9090"|address = "0.0.0.0:9090"|g' $HOME/.atomone/config/app.toml
sed -i 's|address = "localhost:9091"|address = "0.0.0.0:9091"|g' $HOME/.atomone/config/app.toml

exec atomoned start --minimum-gas-prices=0.025uatone
22 changes: 0 additions & 22 deletions e2e.Dockerfile

This file was deleted.

Loading