mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-24 21:02:09 +03:00
Add grpc generation script and update setup.md to run it using docker container (#209)
* Add grpc generation script and update setup.md to run it using docker container * Change local url from localhost to 127.0.0.1
This commit is contained in:
parent
efd89756e4
commit
6090e21f6a
15
Dockerfile
15
Dockerfile
@ -18,20 +18,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
|
||||
# install lnd grpc services
|
||||
RUN cd api/lightning && git clone https://github.com/googleapis/googleapis.git
|
||||
RUN cd api/lightning && curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
|
||||
RUN cd api/lightning && python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto
|
||||
RUN cd api/lightning && curl -o invoices.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/invoicesrpc/invoices.proto
|
||||
RUN cd api/lightning && python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. invoices.proto
|
||||
RUN cd api/lightning && curl -o router.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto
|
||||
RUN cd api/lightning && python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. router.proto
|
||||
|
||||
# patch generated files relative imports
|
||||
RUN sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/router_pb2.py
|
||||
RUN sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/invoices_pb2.py
|
||||
RUN sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/router_pb2_grpc.py
|
||||
RUN sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/lightning_pb2_grpc.py
|
||||
RUN sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/invoices_pb2_grpc.py
|
||||
RUN sh generate_grpc.sh
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
|
18
generate_grpc.sh
Executable file
18
generate_grpc.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# generate grpc definitions
|
||||
cd api/lightning
|
||||
[ -d googleapis ] || git clone https://github.com/googleapis/googleapis.git googleapis
|
||||
curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
|
||||
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto
|
||||
curl -o invoices.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/invoicesrpc/invoices.proto
|
||||
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. invoices.proto
|
||||
curl -o router.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto
|
||||
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. router.proto
|
||||
|
||||
# patch generated files relative imports
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' router_pb2.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' invoices_pb2.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' router_pb2_grpc.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' lightning_pb2_grpc.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' invoices_pb2_grpc.py
|
29
setup.md
29
setup.md
@ -46,6 +46,8 @@ Make "{robosats-site}/static/css/index.css" redirect to "127.0.0.1:8080/css/inde
|
||||
Spinning up docker for the first time
|
||||
```
|
||||
docker-compose build --no-cache
|
||||
# Install LND python dependencies into local repository
|
||||
docker run --mount type=bind,src=$(pwd),dst=/usr/src/robosats backend sh generate_grpc.sh
|
||||
docker-compose up -d
|
||||
docker exec -it django-dev python3 manage.py makemigrations
|
||||
docker exec -it django-dev python3 manage.py migrate
|
||||
@ -54,31 +56,6 @@ docker-compose restart
|
||||
```
|
||||
Copy the `.env-sample` file into `.env` and check the environmental variables are right for your development.
|
||||
|
||||
### (optional, if error) Install LND python dependencies
|
||||
Depending on your system your dev setup might already be good to start working. However, it might happen that when mounting "." into "/src/usr/robosats" in the docker-compose.yml, it deletes the lnd grpc files that where previously generated during the docker build. If this is the case, run the following:
|
||||
```
|
||||
cd api/lightning
|
||||
pip install grpcio grpcio-tools googleapis-common-protos
|
||||
git clone https://github.com/googleapis/googleapis.git
|
||||
curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
|
||||
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto
|
||||
```
|
||||
We also use the *Invoices* and *Router* subservices for invoice validation and payment routing.
|
||||
```
|
||||
curl -o invoices.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/invoicesrpc/invoices.proto
|
||||
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. invoices.proto
|
||||
curl -o router.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto
|
||||
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. router.proto
|
||||
```
|
||||
Generated files can be automatically patched for relative imports like this:
|
||||
```
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/router_pb2.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/invoices_pb2.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/router_pb2_grpc.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/lightning_pb2_grpc.py
|
||||
sed -i 's/^import .*_pb2 as/from . \0/' api/lightning/invoices_pb2_grpc.py
|
||||
```
|
||||
|
||||
**All set!**
|
||||
|
||||
Commands you will need to startup:
|
||||
@ -112,7 +89,7 @@ You will need these commands also often or eventually:
|
||||
* Open channel
|
||||
`docker exec -it lnd-dev lncli --network=testnet openchannel node_id --local_amt LOCAL_AMT --push_amt PUSH_AMT`
|
||||
|
||||
**RoboSats development site should be accessible on localhost:8000**
|
||||
**RoboSats development site should be accessible on 127.0.0.1:8000**
|
||||
|
||||
|
||||
## The harder way (deprecated)
|
||||
|
Loading…
Reference in New Issue
Block a user