-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test node script, reformat dockerfile
- Loading branch information
hard-nett
committed
Oct 14, 2024
1 parent
42819a5
commit c1c52c6
Showing
11 changed files
with
246 additions
and
217 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 |
---|---|---|
@@ -1,45 +1,52 @@ | ||
# syntax=docker/dockerfile:1 | ||
# docker build . -t cosmoscontracts/juno:latest | ||
# docker run --rm -it cosmoscontracts/juno:latest /bin/sh | ||
FROM golang:1.22-alpine AS go-builder | ||
|
||
# this comes from standard alpine nightly file | ||
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile | ||
# with some changes to support our toolchain, etc | ||
SHELL ["/bin/sh", "-ecuxo", "pipefail"] | ||
# we probably want to default to latest and error | ||
# since this is predominantly for dev use | ||
# hadolint ignore=DL3018 | ||
RUN apk add --no-cache ca-certificates build-base git | ||
# NOTE: add these to run with LEDGER_ENABLED=true | ||
# RUN apk add libusb-dev linux-headers | ||
|
||
WORKDIR /code | ||
|
||
# Download dependencies and CosmWasm libwasmvm if found. | ||
ADD go.mod go.sum ./ | ||
RUN set -eux; \ | ||
export ARCH=$(uname -m); \ | ||
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \ | ||
if [ ! -z "${WASM_VERSION}" ]; then \ | ||
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \ | ||
fi; \ | ||
go mod download; | ||
|
||
# Copy over code | ||
COPY . /code/ | ||
|
||
# force it to use static lib (from above) not standard libgo_cosmwasm.so file | ||
# then log output of file /code/bin/bitsongd | ||
# then ensure static linking | ||
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build \ | ||
&& file /code/bin/bitsongd \ | ||
&& echo "Ensuring binary is statically linked ..." \ | ||
&& (file /code/bin/bitsongd | grep "statically linked") | ||
|
||
ARG BASE_IMG_TAG=nonroot | ||
|
||
# -------------------------------------------------------- | ||
# Build | ||
# -------------------------------------------------------- | ||
|
||
FROM golang:1.22-alpine as build | ||
|
||
RUN set -eux; apk add --no-cache ca-certificates build-base; | ||
RUN apk add git | ||
# Needed by github.com/zondax/hid | ||
RUN apk add linux-headers | ||
|
||
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 | ||
RUN apk add --no-cache $PACKAGES | ||
|
||
RUN LEDGER_ENABLED=false CGO_ENABLED=0 make install | ||
|
||
# -------------------------------------------------------- | ||
# Runner | ||
# -------------------------------------------------------- | ||
FROM alpine:3.16 | ||
|
||
FROM gcr.io/distroless/base-debian11:${BASE_IMG_TAG} | ||
#FROM ubuntu:20.04 | ||
COPY --from=go-builder /code/bin/bitsongd /usr/bin/bitsongd | ||
|
||
ENV HOME /go-bitsong | ||
WORKDIR $HOME | ||
COPY docker/* /opt/ | ||
RUN chmod +x /opt/*.sh | ||
|
||
COPY --from=build /go/bin/bitsongd /bin/bitsongd | ||
WORKDIR /opt | ||
|
||
EXPOSE 26656 | ||
EXPOSE 26657 | ||
EXPOSE 9090 | ||
EXPOSE 1317 | ||
# rest server, tendermint p2p, tendermint rpc | ||
EXPOSE 1317 26656 26657 | ||
|
||
#ENTRYPOINT ["/bin/bash"] | ||
ENTRYPOINT ["bitsongd"] | ||
CMD [ "start" ] | ||
CMD ["/usr/bin/bitsongd", "version"] |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
#!/bin/sh | ||
|
||
if test -n "$1"; then | ||
# need -R not -r to copy hidden files | ||
cp -R "$1/.bitsongd" /root | ||
fi | ||
|
||
mkdir -p /root/log | ||
bitsongd start --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices 0.0001ubtsg --trace |
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,4 @@ | ||
#!/bin/sh | ||
|
||
./setup_bitsongd.sh "$@" | ||
./run_bitsongd.sh |
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,69 @@ | ||
#!/bin/sh | ||
#set -o errexit -o nounset -o pipefail | ||
|
||
PASSWORD=${PASSWORD:-1234567890} | ||
STAKE=${STAKE_TOKEN:-ustake} | ||
FEE=${FEE_TOKEN:-ucosm} | ||
CHAIN_ID=${CHAIN_ID:-testing} | ||
MONIKER=${MONIKER:-node001} | ||
KEYRING="--keyring-backend test" | ||
TIMEOUT_COMMIT=${TIMEOUT_COMMIT:-5s} | ||
BLOCK_GAS_LIMIT=${GAS_LIMIT:-10000000} # should mirror mainnet | ||
|
||
echo "Configured Block Gas Limit: $BLOCK_GAS_LIMIT" | ||
|
||
# check the genesis file | ||
GENESIS_FILE="$HOME"/.bitsongd/config/genesis.json | ||
if [ -f "$GENESIS_FILE" ]; then | ||
echo "$GENESIS_FILE exists..." | ||
else | ||
echo "$GENESIS_FILE does not exist. Generating..." | ||
|
||
bitsongdd init --chain-id "$CHAIN_ID" "$MONIKER" | ||
bitsongd add-ica-config | ||
# staking/governance token is hardcoded in config, change this | ||
sed -i "s/\"stake\"/\"$STAKE\"/" "$GENESIS_FILE" | ||
# this is essential for sub-1s block times (or header times go crazy) | ||
sed -i 's/"time_iota_ms": "1000"/"time_iota_ms": "10"/' "$GENESIS_FILE" | ||
# change gas limit to mainnet value | ||
sed -i 's/"max_gas": "-1"/"max_gas": "'"$BLOCK_GAS_LIMIT"'"/' "$GENESIS_FILE" | ||
# change default keyring-backend to test | ||
sed -i 's/keyring-backend = "os"/keyring-backend = "test"/' "$HOME"/.bitsongd/config/client.toml | ||
fi | ||
|
||
APP_TOML_CONFIG="$HOME"/.bitsongd/config/app.toml | ||
APP_TOML_CONFIG_NEW="$HOME"/.bitsongd/config/app_new.toml | ||
CONFIG_TOML_CONFIG="$HOME"/.bitsongd/config/config.toml | ||
if [ -n "$UNSAFE_CORS" ]; then | ||
echo "Unsafe CORS set... updating app.toml and config.toml" | ||
# sorry about this bit, but toml is rubbish for structural editing | ||
sed -n '1h;1!H;${g;s/# Enable defines if the API server should be enabled.\nenable = false/enable = true/;p;}' "$APP_TOML_CONFIG" > "$APP_TOML_CONFIG_NEW" | ||
mv "$APP_TOML_CONFIG_NEW" "$APP_TOML_CONFIG" | ||
# ...and breathe | ||
sed -i "s/enabled-unsafe-cors = false/enabled-unsafe-cors = true/" "$APP_TOML_CONFIG" | ||
sed -i "s/cors_allowed_origins = \[\]/cors_allowed_origins = \[\"\*\"\]/" "$CONFIG_TOML_CONFIG" | ||
fi | ||
|
||
# speed up block times for testing environments | ||
sed -i "s/timeout_commit = \"5s\"/timeout_commit = \"$TIMEOUT_COMMIT\"/" "$CONFIG_TOML_CONFIG" | ||
|
||
# are we running for the first time? | ||
if ! bitsongd keys show validator $KEYRING; then | ||
(echo "$PASSWORD"; echo "$PASSWORD") | bitsongd keys add validator $KEYRING | ||
|
||
# hardcode the validator account for this instance | ||
echo "$PASSWORD" | bitsongd genesis add-genesis-account validator "1000000000$STAKE,1000000000$FEE" $KEYRING | ||
|
||
# (optionally) add a few more genesis accounts | ||
for addr in "$@"; do | ||
echo $addr | ||
bitsongd genesis add-genesis-account "$addr" "1000000000$STAKE,1000000000$FEE,5000000000uusd" | ||
done | ||
|
||
# submit a genesis validator tx | ||
## Workraround for https://github.com/cosmos/cosmos-sdk/issues/8251 | ||
(echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | bitsongd genesis gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID" --amount="250000000$STAKE" $KEYRING | ||
## should be: | ||
# (echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | bitsongd genesis gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID" | ||
bitsongd genesis collect-gentxs | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.