diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fa81485..3be708c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,16 +94,16 @@ add_custom_command(TARGET hpcore POST_BUILD # COMMAND strip ./build/appbill COMMAND cp ./test/bin/hpws ./test/bin/hpfs ./build/ ) - + target_precompile_headers(hpcore PUBLIC src/pchheader.hpp) -# Create docker image from hpcore build output with 'make docker' +# Create docker image for local cluster testing from hpcore build output with 'make docker' # Requires docker to be runnable without 'sudo' add_custom_target(docker COMMAND mkdir -p ./test/local-cluster/bin COMMAND cp ./build/hpcore ./build/appbill ./test/local-cluster/bin/ - COMMAND cp ./test/bin/fusermount3 ./test/bin/libfuse3.so.3 ./test/bin/libblake3.so ./test/bin/hpws ./test/bin/hpfs ./test/local-cluster/bin/ - COMMAND docker build -t hpcore:latest ./test/local-cluster + COMMAND cp ./test/bin/libblake3.so ./test/bin/hpws ./test/bin/hpfs ./test/local-cluster/bin/ + COMMAND docker build -t hpcore:latest -f ./test/local-cluster/Dockerfile ./test/local-cluster/bin/ ) set_target_properties(docker PROPERTIES EXCLUDE_FROM_ALL TRUE) add_dependencies(docker hpcore) diff --git a/test/bin/fusermount3 b/test/bin/fusermount3 deleted file mode 100755 index cba0239e..00000000 Binary files a/test/bin/fusermount3 and /dev/null differ diff --git a/test/bin/libfuse3.so.3 b/test/bin/libfuse3.so.3 deleted file mode 100755 index e4eedf2a..00000000 Binary files a/test/bin/libfuse3.so.3 and /dev/null differ diff --git a/test/docker/.gitignore b/test/docker/.gitignore new file mode 100644 index 00000000..c5e82d74 --- /dev/null +++ b/test/docker/.gitignore @@ -0,0 +1 @@ +bin \ No newline at end of file diff --git a/test/docker/Dockerfile.ubt.20.04 b/test/docker/Dockerfile.ubt.20.04 new file mode 100644 index 00000000..892a68e9 --- /dev/null +++ b/test/docker/Dockerfile.ubt.20.04 @@ -0,0 +1,14 @@ +# Ubuntu 20.04 + HotPocket + +FROM ubuntu:focal + +COPY libblake3.so /usr/local/lib/ +RUN apt-get update && apt-get install -y \ + libssl1.1 \ + sqlite3 \ + fuse3 + +RUN mkdir /usr/local/bin/hotpocket +COPY hpcore hpfs hpws appbill /usr/local/bin/hotpocket/ + +ENTRYPOINT ["/usr/local/bin/hotpocket/hpcore"] diff --git a/test/docker/Dockerfile.ubt.20.04-njs.14 b/test/docker/Dockerfile.ubt.20.04-njs.14 new file mode 100644 index 00000000..8f0022d3 --- /dev/null +++ b/test/docker/Dockerfile.ubt.20.04-njs.14 @@ -0,0 +1,7 @@ +# HotPocket (Ubuntu 20.04) + NodeJs 14.x + +FROM hotpocketdev/hotpocket:ubt.20.04 + +RUN apt-get install -y curl +RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - +RUN apt-get install -y nodejs diff --git a/test/docker/build.sh b/test/docker/build.sh new file mode 100755 index 00000000..2bc5c976 --- /dev/null +++ b/test/docker/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +hpcoredir=$(realpath ../..) +repo=hotpocketdev/hotpocket + +# Build base Ubuntu image. +mkdir -p bin +cp $hpcoredir/build/{hpcore,appbill} $hpcoredir/test/bin/{hpfs,hpws,libblake3.so} ./bin/ +strip ./bin/hpcore +docker build -t $repo:ubt.20.04 -f ./Dockerfile.ubt.20.04 ./bin +rm -r bin + +# NodeJs image. +docker build -t $repo:ubt.20.04-njs.14 -f ./Dockerfile.ubt.20.04-njs.14 . \ No newline at end of file diff --git a/test/docker/push.sh b/test/docker/push.sh new file mode 100755 index 00000000..472df71d --- /dev/null +++ b/test/docker/push.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +repo=hotpocketdev/hotpocket + +./build.sh +docker push $repo:ubt.20.04 +docker push $repo:ubt.20.04-njs.14 \ No newline at end of file diff --git a/test/local-cluster/Dockerfile b/test/local-cluster/Dockerfile index 9dcd76b0..b9ef6cc5 100644 --- a/test/local-cluster/Dockerfile +++ b/test/local-cluster/Dockerfile @@ -1,24 +1,11 @@ -# We are going with NodeJs debian docker image because sample contracts need NodeJs to run. -# Otherwise, hpcore itself can run on any docker image like ubuntu or debian without NodeJs. -FROM node:12.18.3-buster-slim +# We are going with Hot Pocket NodeJs docker image because sample contracts need NodeJs to run. +FROM hotpocketdev/hotpocket:ubt.20.04-njs.14 -RUN apt-get update -RUN apt-get install -y libgomp1 libssl-dev gdb valgrind +COPY hpcore hpfs hpws appbill /usr/local/bin/hotpocket/ -# Install shared libraries. -# Copy shared libraries and register it. -COPY ./bin/libfuse3.so.3 /usr/local/lib/ -COPY ./bin/libblake3.so /usr/local/lib/ -RUN ldconfig -COPY ./bin/fusermount3 /usr/local/bin/ - -# hpcore binary is copied to /hp directory withtin the docker image. -WORKDIR /hp -COPY ./bin/hpcore . -COPY ./bin/hpfs . -COPY ./bin/hpws . - -ENTRYPOINT ["/hp/hpcore"] +ENTRYPOINT ["/usr/local/bin/hotpocket/hpcore"] # Run with valgrind -# ENTRYPOINT ["valgrind", "/hp/hpcore"] \ No newline at end of file + +# RUN apt-get install -y gdb valgrind +# ENTRYPOINT ["valgrind", "/usr/local/bin/hotpocket/hpcore"] \ No newline at end of file diff --git a/test/local-cluster/cluster-create.sh b/test/local-cluster/cluster-create.sh index 43795e71..20716879 100755 --- a/test/local-cluster/cluster-create.sh +++ b/test/local-cluster/cluster-create.sh @@ -33,13 +33,13 @@ elif [ "$CONTRACT" = "nodefile" ]; then # nodejs file contract (uses BSON protoc npm install popd > /dev/null 2>&1 copyfiles="$hpcore/examples/nodejs_contract/{node_modules,package.json,hp-contract-lib.js,file_contract.js}" - binary="/usr/local/bin/node" + binary="/usr/bin/node" binargs="file_contract.js" else # nodejs echo contract (default) echo "Using nodejs echo contract." copyfiles="$hpcore/examples/nodejs_contract/{package.json,hp-contract-lib.js,echo_contract.js}" - binary="/usr/local/bin/node" + binary="/usr/bin/node" binargs="echo_contract.js" fi diff --git a/test/local-cluster/cluster-start.sh b/test/local-cluster/cluster-start.sh index 74d001c3..d632428a 100755 --- a/test/local-cluster/cluster-start.sh +++ b/test/local-cluster/cluster-start.sh @@ -26,4 +26,4 @@ docker run --rm -t -i --network=hpnet --name=node${n} \ -p ${peerport}:${peerport} \ --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \ --mount type=bind,source=${clusterloc}/node${n},target=/contract \ - hpcore:latest run /contract \ No newline at end of file + hpcore:latest run /contract