Skip to content

Commit

Permalink
Fix function manual_build
Browse files Browse the repository at this point in the history
  • Loading branch information
Flouse committed Oct 15, 2023
1 parent 3273817 commit 66b1a1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
volumes:
- ./redis/data:/data

# TODO: update CKB version
ckb:
image: nervos/ckb:v0.103.0
user: root
Expand All @@ -31,6 +32,7 @@ services:
- ./layer1/ckb:/var/lib/ckb
command: [ "run", "-C", "/var/lib/ckb" ]

# TODO: update CKB version
ckb-miner:
init: true
image: nervos/ckb:v0.103.0
Expand Down
38 changes: 23 additions & 15 deletions kicker
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,19 @@ function manual_build() {
echo "DOCKER_MANUAL_BUILD_IMAGE = \"$DOCKER_MANUAL_BUILD_IMAGE\""
echo

info "Start building..." | tee /tmp/kicker.log
du -hd6 $WORKSPACE | egrep G | tee --append /tmp/kicker.log

if [ "$MANUAL_BUILD_WEB3" = "true" ]; then
info "Start building godwoken-web3"

# godwoken-web3 is managed in the Godwoken monorepo.
# See https://github.com/godwokenrises/godwoken/tree/develop/web3
srcdir=$WORKSPACE/packages/godwoken-web3/web3
srcdir=$WORKSPACE/packages/godwoken/web3
dstdir=$WORKSPACE/docker/manual-artifacts/godwoken-web3

# Download repo
prepare_repo godwoken-web3 "$WEB3_GIT_URL" "$WEB3_GIT_CHECKOUT"
prepare_repo godwoken "$WEB3_GIT_URL" "$WEB3_GIT_CHECKOUT"

# Yarn install via docker (assumes the "web3" docker-compose service installed yarn)

Expand Down Expand Up @@ -490,34 +493,34 @@ function manual_build() {
if [ "$MANUAL_BUILD_WEB3_INDEXER" = "true" ]; then
info "Start building godwoken-web3-indexer"

srcdir=$WORKSPACE/packages/godwoken-web3
srcdir=$WORKSPACE/packages/godwoken
dstdir=$WORKSPACE/docker/manual-artifacts

# Download repo
prepare_repo godwoken-web3 "$WEB3_GIT_URL" "$WEB3_GIT_CHECKOUT"
prepare_repo godwoken "$WEB3_GIT_URL" "$WEB3_GIT_CHECKOUT"

# Cargo fetch Rust dependencies (in order to access network via
# host network). The docker image must have installed cargo, molecule
# and rustfmt.
erun "cd $srcdir/web3 && CARGO_HOME=$srcdir/web3/.cargo cargo fetch --locked && cd -"
erun docker run \
--rm \
--env CARGO_HOME=/app/.cargo \
erun "cd $srcdir/web3 && CARGO_HOME=$WORKSPACE/packages/.cargo cargo fetch --locked && cd -"

erun docker run --rm \
--workdir /app/web3 \
--volume $srcdir:/app \
--volume $WORKSPACE/packages/.rustup:/root/.rustup \
--workdir /app/web3 \
$DOCKER_MANUAL_BUILD_IMAGE cargo build --locked --release
--env CARGO_HOME=$WORKSPACE/packages/.cargo \
$DOCKER_MANUAL_BUILD_IMAGE cargo build --locked

# Copy the built artifacts to `docker/manual-artifacts/gw-web3-indexer`
#
# More: ./docker/manual-web3-indexer.compose.yml
erun mkdir -p $dstdir
erun cp $srcdir/web3/target/release/gw-web3-indexer $dstdir
erun cp $srcdir/web3/target/debug/gw-web3-indexer $dstdir

# Remove Rust target to avoid `out of disk` issue in CI
sudo rm -rf $srcdir/web3/target/release
sudo rm -rf $srcdir/target
else
info "skip building godwoken-web3-indexer(gw-web3-indexer)"
info "skip building godwoken-web3-indexer (gw-web3-indexer)"
fi

if [ "$MANUAL_BUILD_GODWOKEN" = "true" ]; then
Expand All @@ -538,11 +541,11 @@ function manual_build() {
# to `cargo build` arguments.
erun docker run \
--rm \
--env CARGO_HOME=/app/.cargo \
--env CARGO_HOME=$WORKSPACE/packages/.cargo \
--volume $srcdir:/app \
--volume $WORKSPACE/packages/.rustup:/root/.rustup \
--workdir /app \
$DOCKER_MANUAL_BUILD_IMAGE \
godwoken \
cargo build --locked --release --features gw-config/no-builtin

# Copy the built artifacts to `docker/manual-artifacts/`
Expand Down Expand Up @@ -607,6 +610,11 @@ function manual_build() {
else
info "skip building Scripts"
fi

docker rmi $DOCKER_MANUAL_BUILD_IMAGE

info "End building." | tee --append /tmp/kicker.log
du -hd6 $WORKSPACE | egrep G | tee --append /tmp/kicker.log
}

function prepare_repo() {
Expand Down

0 comments on commit 66b1a1a

Please sign in to comment.