added scripts to build and run waku and server with docker

This commit is contained in:
jasquat 2022-09-26 16:48:45 -04:00
parent 342054a914
commit 10120729e2
8 changed files with 104 additions and 52 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
README.md
Dockerfile
.*ignore
LICENSE*
tests
examples
*.db
/go-waku
/client

1
.gitignore vendored
View File

@ -16,3 +16,4 @@
/t /t
/client /client
/go-waku

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
# BUILD IMAGE --------------------------------------------------------
FROM golang:1.17-alpine as builder
# Get build tools and required header files
RUN apk add --no-cache build-base
RUN apk add --no-cache bash
RUN apk add --no-cache git
WORKDIR /app
COPY . .
# Build the final node binary
# RUN make -j$(nproc) build
RUN go build waku/client
RUN ls
RUN ls /app
ENTRYPOINT ["./client"]
#
# # ACTUAL IMAGE -------------------------------------------------------
#
# FROM alpine:3.12
#
# ARG GIT_COMMIT=unknown
#
# LABEL maintainer="richard@status.im"
# LABEL source="https://github.com/status-im/go-waku"
# LABEL description="go-waku: Waku V2 node"
# LABEL commit=$GIT_COMMIT
#
# # color, nocolor, json
# ENV GOLOG_LOG_FMT=nocolor
#
# # go-waku default ports
# EXPOSE 9000 30303 60000 60001 8008 8009
#
# COPY --from=builder /app/build/waku /usr/bin/waku
#
# ENTRYPOINT ["/usr/bin/waku"]
# # By default just show help if called without arguments
# CMD ["--help"]

1
run.go
View File

@ -142,6 +142,7 @@ func sendMessage(c *gin.Context) {
fmt.Println("response Headers:", resp.Header) fmt.Println("response Headers:", resp.Header)
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("response Body:", string(body)) fmt.Println("response Body:", string(body))
c.String(200, string(body))
} }
func ContentTopic(t []byte) string { func ContentTopic(t []byte) string {

21
start_server_with_docker Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
tag_name="local-build-$(date +%s)"
image_name="waku-integration"
container_name="$image_name"
image_with_tag="${image_name}:${tag_name}"
if [[ -n "$(docker ps -a -q -f name=${container_name})" ]] ; then
docker stop ${container_name}
docker rm ${container_name}
fi
docker build -t "$image_with_tag" .
docker run -d --net=host -p 7005:7005 --name "$container_name" "$image_with_tag"

30
start_waku_node_with_docker Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
if [[ ! -d 'go-waku' ]]; then
git clone https://github.com/status-im/go-waku
fi
if [[ -n "$(docker ps -a -q -f name=go-waku-node)" ]] ; then
docker stop go-waku-node
docker rm go-waku-node
fi
tag_name="local-build-$(date +%s)"
cd go-waku
docker build -t "go-waku:${tag_name}" .
docker run -d --name go-waku-node -p8545:8545 --net=host "go-waku:${tag_name}" \
--dns-discovery=true \
--dns-discovery-url=enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@prod.nodes.status.im \
--discv5-discovery=true \
--rpc \
--rpc-admin

View File

@ -1,51 +0,0 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
# HELP:
cd ~/projects/github/go-waku
if [[ ! -f "./build/waku" ]]; then
make
fi
# --dns-discovery-url=enrtree://ANTL4SLG2COUILKAPE7EF2BYNL2SHSHVCHLRD5J7ZJLN5R3PRJD2Y@prod.waku.nodes.status.im \
# --dns-discovery-url=enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net \
./build/waku \
--dns-discovery=true \
--dns-discovery-url=enrtree://AOGECG2SPND25EEFMAJ5WF3KSGJNSGV356DSTL2YVLLZWIV6SAYBM@prod.nodes.status.im \
--discv5-discovery=true \
--rpc \
--rpc-admin
# ./build/waku \
# --staticnode=/dns4/node-01.ac-cn-hongkong-c.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAkvEZgh3KLwhLwXg95e5ojM8XykJ4Kxi2T7hk22rnA7pJC \
# --staticnode=/dns4/node-01.do-ams3.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAm6HZZr7aToTvEBPpiys4UxajCTU97zj5v7RNR2gbniy1D \
# --staticnode=/dns4/node-01.gc-us-central1-a.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAkwBp8T6G77kQXSNMnxgaMky1JeyML5yqoTHRM8dbeCBNb \
# --staticnode=/dns4/node-02.ac-cn-hongkong-c.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAmFy8BrJhCEmCYrUfBdSNkrPw6VHExtv4rRp1DSBnCPgx8 \
# --staticnode=/dns4/node-02.do-ams3.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAmSve7tR5YZugpskMv2dmJAsMUKmfWYEKRXNUxRaTCnsXV \
# --staticnode=/dns4/node-02.gc-us-central1-a.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAmDQugwDHM3YeUp86iGjrUvbdw3JPRgikC7YoGBsT2ymMg \
# --rpc \
# --rpc-admin
# curl -d '{"jsonrpc":"2.0","id":"id","method":"get_waku_v2_debug_v1_info", "params":[]}' --header "Content-Type: application/json" http://localhost:8545 | jq .
# curl -v -f -s -X POST -H Content-type:application/json --data '{
# "id": 1,
# "jsonrpc": "2.0",
# "method": "post_waku_v2_relay_v1_message",
# "params": ["", {
# "payload": "abcdef112233",
# "contentTopic": "contentTopicGoesHere",
# "timestamp": 1257894000000000000,
# "version": 1
# }]
# }' http://localhost:8545

View File

@ -14,7 +14,7 @@ mikeKey="04622248490465b1d0cd5ec48375484682bec9a16f550ffd461cb803d4a8970a88cf8f9
publicKey=$rramosKey publicKey=$rramosKey
if [[ "${1-}" == "public" ]]; then if [[ "${1-}" == "public" ]]; then
curl localhost:7005/sendMessage -X POST --data '{"message": "new_message2", "recipient": "testrramos", "message_type": "public"}' curl localhost:7005/sendMessage -X POST --data '{"message": "new_message7", "recipient": "testrramos", "message_type": "public"}'
else else
curl -v localhost:7005/sendMessage -X POST --data '{"message": "new_message1", "recipient": "'$publicKey'", "message_type": "one_to_one"}' curl -v localhost:7005/sendMessage -X POST --data '{"message": "new_message1", "recipient": "'$publicKey'", "message_type": "one_to_one"}'
fi fi