Skip to content

Commit 97c65e5

Browse files
authored
Merge pull request #2 from arturgontijo/master
[docker volume] Using docker volume to secure etcd
2 parents 2c43048 + 0cbb158 commit 97c65e5

4 files changed

Lines changed: 39 additions & 34 deletions

File tree

Dockerfile

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,23 @@ RUN mkdir -p ${SINGNET_REPOS}
66

77
RUN apt-get update && \
88
apt-get install -y \
9-
apt-utils \
109
nano \
1110
git \
12-
wget \
13-
curl \
14-
zip \
15-
libudev-dev \
16-
libusb-1.0-0-dev
11+
wget
1712

18-
RUN apt-get install -y nodejs npm
1913
RUN apt-get install -y python3 python3-pip
2014

21-
RUN cd ${SINGNET_REPOS} && \
22-
git clone https://github.com/singnet/snet-cli && \
23-
cd snet-cli && \
24-
./scripts/blockchain install && \
25-
pip3 install -e .
26-
2715
RUN cd ${SINGNET_REPOS} && \
2816
mkdir snet-daemon && \
2917
cd snet-daemon && \
30-
wget https://github.com/singnet/snet-daemon/releases/download/v0.1.3/snetd-0.1.3.tar.gz && \
31-
tar -xvf snetd-0.1.3.tar.gz && \
32-
mv linux-amd64/snetd /usr/bin/snetd
18+
wget https://github.com/singnet/snet-daemon/releases/download/v0.1.4/snetd-0.1.4.tar.gz && \
19+
tar -xvf snetd-0.1.4.tar.gz && \
20+
mv snetd-0.1.4/snetd-linux-amd64 /usr/bin/snetd
3321

3422
RUN cd ${SINGNET_REPOS} && \
3523
git clone https://github.com/singnet/example-service.git && \
3624
cd example-service && \
25+
pip3 install -r requirements.txt && \
3726
sh buildproto.sh
3827

3928
WORKDIR ${SINGNET_REPOS}/example-service

README.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,21 @@ $ python3 test_example_service.py
4646

4747
##### SingularityNET Daemon Configuration
4848

49-
Now you must follow the [howToPublishService](https://github.com/singnet/wiki/tree/master/tutorials/howToPublishService)
50-
tutorial to publish this service and set the `snetd.config.json` file.
49+
To get the `ORGANIZATION_ID` and `SERVICE_ID` you must have already published a service
50+
(check this [link](https://dev.singularitynet.io/tutorials/publish/)).
5151

52-
Then, be sure that you have the `snetd` in your PATH.
53-
54-
Create the `snetd.config.json` file using this template:
52+
Create the `SNET Daemon`'s config JSON file (`snetd.config.json`).
5553

5654
```
5755
{
5856
"DAEMON_END_POINT": "http://DAEMON_HOST:DAEMON_PORT",
5957
"ETHEREUM_JSON_RPC_ENDPOINT": "https://kovan.infura.io",
6058
"IPFS_END_POINT": "http://ipfs.singularitynet.io:80",
61-
"REGISTRY_ADDRESS_KEY": "0x2e4b2f2b72402b9b2d6a7851e37c856c329afe38",
59+
"REGISTRY_ADDRESS_KEY": "0xe331bf20044a5b24c1a744abc90c1fd711d2c08d",
6260
"PASSTHROUGH_ENABLED": true,
63-
"PASSTHROUGH_ENDPOINT": "http://SERVICE_GRPC_HOST:SERVICE_GRPC_PORT",
64-
"ORGANIZATION_NAME": "ORGANIZATION_NAME",
65-
"SERVICE_NAME": "SERVICE_NAME",
61+
"PASSTHROUGH_ENDPOINT": "http://SERVICE_GRPC_HOST:SERVICE_GRPC_PORT",
62+
"ORGANIZATION_ID": "ORGANIZATION_ID",
63+
"SERVICE_ID": "SERVICE_ID",
6664
"LOG": {
6765
"LEVEL": "debug",
6866
"OUTPUT": {
@@ -76,8 +74,8 @@ For example, replace tags with:
7674

7775
- `http://DAEMON_HOST:DAEMON_PORT`: http://localhost:7000
7876
- `http://SERVICE_GRPC_HOST:SERVICE_GRPC_PORT`: http://localhost:7003
79-
- `ORGANIZATION_NAME`: example-organization
80-
- `SERVICE_NAME`: example-service
77+
- `ORGANIZATION_ID`: example-organization
78+
- `SERVICE_ID`: example-service
8179

8280
See [SingularityNet daemon configuration](https://github.com/singnet/snet-daemon/blob/master/README.md#configuration) for detailed configuration description.
8381

@@ -95,14 +93,35 @@ $ python3 run_example_service.py
9593

9694
```
9795
$ docker build -t snet_example_service https://github.com/singnet/example-service.git#master
98-
$ docker run -p 7000:7000 -ti snet_example_service bash
96+
$ export ETCD_HOST_FOLDER=$HOME/singnet/etcd/example-service/
97+
$ export ETCD_CONTAINER_FOLDER=/opt/singnet/example-service/storage-data-dir-1.etcd/
98+
$ docker run -p 7000:7000 -v $ETCD_HOST_FOLDER:$ETCD_CONTAINER_FOLDER -ti snet_example_service bash
9999
```
100100

101+
Note that the `$ETCD_(HOST|CONTAINER)_FOLDER` are useful to keep your service's etcd folder outside the container.
102+
101103
From this point we follow the tutorial in the Docker Container's prompt.
102104

103-
After this, run the service (with `SNET Daemon`):
105+
After this, run the service (with `SNET Daemon`), make sure you have the `snetd.config.json` file in the service folder:
104106

105107
```
108+
# cat snetd.config.json
109+
{
110+
"DAEMON_END_POINT": "http://localhost:7000",
111+
"ETHEREUM_JSON_RPC_ENDPOINT": "https://kovan.infura.io",
112+
"IPFS_END_POINT": "http://ipfs.singularitynet.io:80",
113+
"REGISTRY_ADDRESS_KEY": "0xe331bf20044a5b24c1a744abc90c1fd711d2c08d",
114+
"PASSTHROUGH_ENABLED": true,
115+
"PASSTHROUGH_ENDPOINT": "http://localhost:7003",
116+
"ORGANIZATION_ID": "example-organization",
117+
"SERVICE_ID": "example-service",
118+
"LOG": {
119+
"LEVEL": "debug",
120+
"OUTPUT": {
121+
"TYPE": "stdout"
122+
}
123+
}
124+
}
106125
# python3 run_example_service.py &
107126
```
108127

buildproto.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /bin/bash
2-
python3.6 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. service/service_spec/example_service.proto
2+
python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. service/service_spec/example_service.proto

test_example_service.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,18 @@
2727
# Open a gRPC channel
2828
channel = grpc.insecure_channel("{}".format(endpoint))
2929
stub = grpc_ex_grpc.CalculatorStub(channel)
30+
number = grpc_ex_pb2.Numbers(a=a, b=b)
3031

3132
if grpc_method == "add":
32-
number = grpc_ex_pb2.Numbers(a=a, b=b)
3333
response = stub.add(number)
3434
print(response.value)
3535
elif grpc_method == "sub":
36-
number = grpc_ex_pb2.Numbers(a=a, b=b)
3736
response = stub.sub(number)
3837
print(response.value)
3938
elif grpc_method == "mul":
40-
number = grpc_ex_pb2.Numbers(a=a, b=b)
4139
response = stub.mul(number)
4240
print(response.value)
4341
elif grpc_method == "div":
44-
number = grpc_ex_pb2.Numbers(a=a, b=b)
4542
response = stub.div(number)
4643
print(response.value)
4744
else:

0 commit comments

Comments
 (0)