Skip to content

Commit

Permalink
feat: make a txsim binary build from Makefile and dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Bidon15 committed Jul 10, 2023
1 parent 5bcf4ad commit a5a1d70
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ jobs:
uses: celestiaorg/.github/.github/workflows/[email protected] # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile

docker-txsim-build:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/[email protected]
with:
dockerfile: docker/Dockerfile_txsim
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ test-coverage:
@export VERSION=$(VERSION); bash -x scripts/test_cover.sh
.PHONY: test-coverage

## txsim-install: Install the tx simulator/fuzzer.
txsim-install:
@echo "--> Installing tx simulator"
@go build -mod=readonly ./test/cmd/txsim
.PHONY: txsim-install

## txsim-build: Build the txsim binary into the ./build directory.
txsim-build: mod
@echo "--> Building tx simulator"
@cd ./test/cmd/txsim
@mkdir -p build/
@go build $(BUILD_FLAGS) -o build/ ./test/cmd/txsim
@go mod tidy -compat=1.20
.PHONY: txsim-build

## adr-gen: Download the ADR template from the celestiaorg/.github repo. Ex. `make adr-gen`
adr-gen:
@echo "--> Downloading ADR template"
Expand Down
49 changes: 49 additions & 0 deletions docker/Dockerfile_txsim
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# stage 1 Generate celestia-appd Binary
FROM docker.io/golang:1.20.5-alpine3.17 as builder
# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
gcc \
git \
make \
musl-dev
COPY . /celestia-app
WORKDIR /celestia-app
# we need the appd build as we might want to create an account
# internally for txsimulation
RUN make build
RUN make txsim-build

# stage 2
FROM docker.io/alpine:3.18.2

# Read here why UID 10001: https://github.com/hexops/dockerfile/blob/main/README.md#do-not-use-a-uid-below-10000
ARG UID=10001
ARG USER_NAME=celestia

ENV CELESTIA_HOME=/home/${USER_NAME}

# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
bash \
curl \
jq \
# Creates a user with $UID and $GID=$UID
&& adduser ${USER_NAME} \
-D \
-g ${USER_NAME} \
-h ${CELESTIA_HOME} \
-s /sbin/nologin \
-u ${UID}

# Copy in the binary
COPY --from=builder /celestia-app/build/celestia-appd /bin/celestia-appd
COPY --from=builder /celestia-app/build/txsim /bin/txsim

COPY --chown=${USER_NAME}:${USER_NAME} docker/txsim.sh /opt/entrypoint.sh

USER ${USER_NAME}

# p2p, rpc and prometheus port
EXPOSE 26656 26657 1317 9090

ENTRYPOINT [ "/bin/bash", "/opt/entrypoint.sh" ]
15 changes: 15 additions & 0 deletions docker/txsim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ "$1" = 'create-key' ]; then
echo "Creating a new keyring-test for the txsim"
exec /bin/celestia-appd keys add sim --keyring-backend test --home /home/celestia
fi

# TODO: This is a temporary solution to get the txsim working
# Please define your own entrypoint.sh when running a txsim's dockerimage
txsim --help

# example of running a txsim on robusta chain
# txsim --key-path /home/celestia \
# --rpc-endpoints http://consensus-validator-robusta-rc6.celestia-robusta.com:26657,http://consensus-full-robusta-rc6.celestia-robusta.com:26657 \
# --grpc-endpoints consensus-validator-robusta-rc6.celestia-robusta.com:9090 --poll-time 10s --blob 10 --seed 100 --send 10 --stake 2

0 comments on commit a5a1d70

Please sign in to comment.