mirror of
https://github.com/logos-messaging/docs.waku.org.git
synced 2026-01-04 05:43:07 +00:00
1 line
12 KiB
JavaScript
1 line
12 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 p=a.createContext({}),l=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=l(e.components);return a.createElement(p.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,p=e.parentName,u=s(e,["components","mdxType","originalType","parentName"]),c=l(n),m=o,k=c["".concat(p,".").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 p in t)hasOwnProperty.call(t,p)&&(s[p]=t[p]);s.originalType=e,s[c]="string"==typeof e?e:o,i[1]=s;for(var l=2;l<r;l++)i[l]=n[l];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:()=>p,contentTitle:()=>i,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>l});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 runs the following:",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:1707490311,formattedLastUpdatedAt:"9 Feb 2024",frontMatter:{title:"Run Nwaku with Docker Compose",hide_table_of_contents:!0},sidebar:"guides",previous:{title:"Run Nwaku in a Docker Container",permalink:"/guides/nwaku/run-docker"},next:{title:"Configure Peer Discovery",permalink:"/guides/nwaku/configure-discovery"}},p={},l=[{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:"Interact with the node",id:"interact-with-the-node",level:2},{value:"Use the REST API",id:"use-the-rest-api",level:2}],u={toc:l},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)("inlineCode",{parentName:"p"},"nwaku-compose")," is a ready-to-use Docker Compose setup that runs the following:"),(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)("p",null,"This guide provides detailed steps to configure, run, monitor, and interact with a ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node with ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/waku-org/nwaku-compose"},"nwaku-compose"),"."),(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.1 Sepolia ETH)"),(0,o.kt)("li",{parentName:"ul"},"A password to protect your RLN membership")),(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 ",(0,o.kt)("a",{parentName:"p",href:"https://rfc.vac.dev/spec/64/#rate-limit-exceeded"},"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,"Start all processes: ",(0,o.kt)("inlineCode",{parentName:"p"},"nwaku")," node, database for storing messages, and Grafana for metrics. Your RLN membership is loaded into 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)("h2",{id:"interact-with-the-node"},"Interact with 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(44833).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:"use-the-rest-api"},"Use the REST API"),(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 "timestamp":\'$(date +%s)\'\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",{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},44833:(e,t,n)=>{n.d(t,{Z:()=>a});const a=n.p+"assets/images/nwaku-compose-dashboard-c0fdabab598b734808be427ff6b24672.png"}}]); |