docs.waku.org/assets/js/7c28fd94.b39bfc8f.js
2024-05-16 17:24:14 +00:00

1 line
13 KiB
JavaScript

"use strict";(self.webpackChunkwaku_guide=self.webpackChunkwaku_guide||[]).push([[906],{3905:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>k});var a=n(67294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){if(null==e)return{};var n,a,o=function(e,t){if(null==e)return{};var n,a,o={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=a.createContext({}),p=function(e){var t=a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=p(e.components);return a.createElement(l.Provider,{value:t},e.children)},c="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,l=e.parentName,u=s(e,["components","mdxType","originalType","parentName"]),c=p(n),m=o,k=c["".concat(l,".").concat(m)]||c[m]||d[m]||r;return n?a.createElement(k,i(i({ref:t},u),{},{components:n})):a.createElement(k,i({ref:t},u))}));function k(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,i=new Array(r);i[0]=m;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[c]="string"==typeof e?e:o,i[1]=s;for(var p=2;p<r;p++)i[p]=n[p];return a.createElement.apply(null,i)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},17217:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>p});var a=n(87462),o=(n(67294),n(3905));const r={title:"Run Nwaku with Docker Compose",hide_table_of_contents:!0},i=void 0,s={unversionedId:"guides/nwaku/run-docker-compose",id:"guides/nwaku/run-docker-compose",title:"Run Nwaku with Docker Compose",description:"nwaku-compose is a ready-to-use Docker Compose setup that configures the following automatically:",source:"@site/docs/guides/nwaku/run-docker-compose.md",sourceDirName:"guides/nwaku",slug:"/guides/nwaku/run-docker-compose",permalink:"/guides/nwaku/run-docker-compose",draft:!1,editUrl:"https://github.com/waku-org/docs.waku.org/tree/develop/docs/guides/nwaku/run-docker-compose.md",tags:[],version:"current",lastUpdatedAt:1715880135,formattedLastUpdatedAt:"16 May 2024",frontMatter:{title:"Run Nwaku with Docker Compose",hide_table_of_contents:!0},sidebar:"guides",previous:{title:"Run a Nwaku Node",permalink:"/guides/nwaku/run-node"},next:{title:"Run Nwaku in a Docker Container",permalink:"/guides/nwaku/run-docker"}},l={},p=[{value:"Video tutorial",id:"video-tutorial",level:2},{value:"Prerequisites",id:"prerequisites",level:2},{value:"Clone the repository",id:"clone-the-repository",level:2},{value:"Configure the setup",id:"configure-the-setup",level:2},{value:"Register for RLN membership",id:"register-for-rln-membership",level:2},{value:"Run the node",id:"run-the-node",level:2},{value:"Monitor the node",id:"monitor-the-node",level:2},{value:"Interact with the node",id:"interact-with-the-node",level:2}],u={toc:p},c="wrapper";function d(e){let{components:t,...r}=e;return(0,o.kt)(c,(0,a.Z)({},u,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("p",null,(0,o.kt)("a",{parentName:"p",href:"https://github.com/waku-org/nwaku-compose"},"nwaku-compose")," is a ready-to-use Docker Compose setup that configures the following automatically:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"nwaku")," node running ",(0,o.kt)("a",{parentName:"li",href:"/learn/concepts/protocols#relay"},"Relay")," and ",(0,o.kt)("a",{parentName:"li",href:"/learn/concepts/protocols#store"},"Store")," protocols with ",(0,o.kt)("a",{parentName:"li",href:"/learn/concepts/protocols#rln-relay"},"RLN")," enabled."),(0,o.kt)("li",{parentName:"ul"},"Simple frontend to interact with the node and Waku network to send and receive messages."),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://grafana.com/"},"Grafana")," metrics dashboard for advanced users and node operators to monitor the node.")),(0,o.kt)("h2",{id:"video-tutorial"},"Video tutorial"),(0,o.kt)("div",{class:"video-container"},(0,o.kt)("iframe",{class:"yt-video",src:"https://www.youtube.com/embed/fs0ynLk4z0I",title:"How to run a Waku node using Nwaku Compose",frameborder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowfullscreen:!0})),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Check out the ",(0,o.kt)("a",{target:"_blank",href:n(18058).Z},"Waku Node Operator Cheatsheet")," to learn how to easily run, monitor, and interact with a node.")),(0,o.kt)("h2",{id:"prerequisites"},"Prerequisites"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://git-scm.com/"},"Git")," or ",(0,o.kt)("a",{parentName:"li",href:"https://desktop.github.com/"},"GitHub Desktop")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://docs.docker.com/engine/install/"},"Docker")," and ",(0,o.kt)("a",{parentName:"li",href:"https://docs.docker.com/compose/install/"},"Docker Compose")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/waku-org/nwaku/blob/master/docs/tutorial/pre-requisites-of-running-on-chain-spam-protected-chat2.md#3-access-a-node-on-the-sepolia-testnet-using-infura"},"Ethereum Sepolia WebSocket Endpoint")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://github.com/waku-org/nwaku/blob/master/docs/tutorial/pre-requisites-of-running-on-chain-spam-protected-chat2.md#2-obtain-sepolia-eth-from-faucet"},"Wallet with Sepolia Ethereum")," (less than 0.01 Sepolia ETH)"),(0,o.kt)("li",{parentName:"ul"},"A password to protect your RLN membership")),(0,o.kt)("admonition",{type:"info"},(0,o.kt)("p",{parentName:"admonition"},"We recommend running a ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node with at least 2GB of RAM, especially if ",(0,o.kt)("inlineCode",{parentName:"p"},"WSS")," is enabled. If running just a ",(0,o.kt)("inlineCode",{parentName:"p"},"Relay")," node, 0.5GB of RAM is sufficient.")),(0,o.kt)("h2",{id:"clone-the-repository"},"Clone the repository"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"git clone https://github.com/waku-org/nwaku-compose\ncd nwaku-compose\n")),(0,o.kt)("h2",{id:"configure-the-setup"},"Configure the setup"),(0,o.kt)("p",null,"Docker Compose ",(0,o.kt)("a",{parentName:"p",href:"https://docs.docker.com/compose/environment-variables/set-environment-variables/#additional-information-3"},"reads the ./.env file")," from the filesystem. You can use ",(0,o.kt)("inlineCode",{parentName:"p"},".env.example")," as a template to provide the above values. The recommended process for working with ",(0,o.kt)("inlineCode",{parentName:"p"},".env")," files is to duplicate ",(0,o.kt)("inlineCode",{parentName:"p"},".env.example"),", rename it as ",(0,o.kt)("inlineCode",{parentName:"p"},".env"),", and then make the necessary value edits."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"cp .env.example .env\n${EDITOR} .env\n")),(0,o.kt)("admonition",{type:"caution"},(0,o.kt)("p",{parentName:"admonition"},"Ensure that you do ",(0,o.kt)("strong",{parentName:"p"},"NOT")," include any secrets in the ",(0,o.kt)("inlineCode",{parentName:"p"},".env.example")," file, as it could accidentally be shared in the Git repository.")),(0,o.kt)("h2",{id:"register-for-rln-membership"},"Register for RLN membership"),(0,o.kt)("p",null,"The RLN membership is your access key to The Waku Network. Its registration is done on-chain, allowing your ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node to send messages decentralised and privately, respecting some rate limits. Other peers won't relay messages that exceed the rate limit."),(0,o.kt)("p",null,"This command registers your membership and saves it in the ",(0,o.kt)("inlineCode",{parentName:"p"},"keystore/keystore.json")," file:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"./register_rln.sh\n")),(0,o.kt)("admonition",{type:"info"},(0,o.kt)("p",{parentName:"admonition"},"If you only want to relay traffic without sending messages to the network, you don't need to register for RLN membership.")),(0,o.kt)("h2",{id:"run-the-node"},"Run the node"),(0,o.kt)("p",null,"Launch all the processes: ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node, database for storing messages, and Grafana for metrics with the following command. Your RLN membership is loaded into ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," under the hood:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"docker-compose up -d\n")),(0,o.kt)("p",null,"View the logs of the node to confirm that it is running correctly:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"docker-compose logs -f nwaku\n")),(0,o.kt)("h2",{id:"monitor-the-node"},"Monitor the node"),(0,o.kt)("p",null,"Visit ",(0,o.kt)("a",{parentName:"p",href:"http://localhost:3000/d/yns_4vFVk/nwaku-monitoring"},"http://localhost:3000/d/yns_4vFVk/nwaku-monitoring")," to view your node metrics in real time."),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"nwaku compose dashboard",src:n(72308).Z,width:"1080",height:"721"})),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"To access Grafana from outside your machine, remove ",(0,o.kt)("inlineCode",{parentName:"p"},"127.0.0.1")," and open the port. Consider setting up a password for Grafana to ensure security.")),(0,o.kt)("h2",{id:"interact-with-the-node"},"Interact with the node"),(0,o.kt)("p",null,"Your ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node provides a ",(0,o.kt)("a",{parentName:"p",href:"https://waku-org.github.io/waku-rest-api/"},"REST API")," on port ",(0,o.kt)("inlineCode",{parentName:"p"},"8645")," for interacting with it:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"# Get nwaku version\ncurl --location 'http://127.0.0.1:8645/debug/v1/version'\n\n# Get nwaku info\ncurl --location 'http://127.0.0.1:8645/debug/v1/info'\n")),(0,o.kt)("p",null,"Send a message to a ",(0,o.kt)("inlineCode",{parentName:"p"},"contentTopic"),", which all subscribers will receive. Please note that the ",(0,o.kt)("inlineCode",{parentName:"p"},"payload")," is encoded in ",(0,o.kt)("inlineCode",{parentName:"p"},"base64"),"."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},'curl --location \'http://127.0.0.1:8645/relay/v1/auto/messages\' \\\n--header \'Content-Type: application/json\' \\\n--data \'{\n "payload": "\'$(echo -n "Hello Waku Network - from Anonymous User" | base64)\'",\n "contentTopic": "/my-app/2/chatroom-1/proto"\n}\'\n')),(0,o.kt)("p",null,"Retrieve messages sent to a ",(0,o.kt)("inlineCode",{parentName:"p"},"contentTopic"),". Please note that this query can be made to any ",(0,o.kt)("inlineCode",{parentName:"p"},"Store")," node within the network:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-shell"},"curl --location 'http://127.0.0.1:8645/store/v1/messages?contentTopics=%2Fmy-app%2F2%2Fchatroom-1%2Fproto&pageSize=50&ascending=true' \\\n--header 'Accept: application/json'\n")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"If you encounter issues running your node or require assistance with anything, please visit the ",(0,o.kt)("a",{parentName:"p",href:"https://discord.com/channels/1110799176264056863/1216748184592711691"},"#node-help channel")," on our Discord.")),(0,o.kt)("admonition",{title:"Congratulations!",type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"You have successfully started a ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node with ",(0,o.kt)("inlineCode",{parentName:"p"},"RLN")," enabled using Docker Compose. Have a look at the ",(0,o.kt)("a",{parentName:"p",href:"/guides/nwaku/configure-nwaku"},"Node Configuration Examples")," and ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/waku-org/nwaku-compose/blob/master/ADVANCED.md"},"Advanced Configuration")," guides to learn how to configure ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," for different use cases.")))}d.isMDXComponent=!0},18058:(e,t,n)=>{n.d(t,{Z:()=>a});const a=n.p+"assets/files/Waku-NodeOperator-7fabb782473f2619b0b05dc209f12f53.pdf"},72308:(e,t,n)=>{n.d(t,{Z:()=>a});const a=n.p+"assets/images/nwaku-compose-dashboard-c0fdabab598b734808be427ff6b24672.png"}}]);