Skip to content

Commit

Permalink
Add service deploy to the docker images (exonum#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-ochc authored and Oleksandr Anyshchenko committed Dec 11, 2019
1 parent 1ab0ab7 commit ce0c375
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 18 deletions.
7 changes: 3 additions & 4 deletions examples/cryptocurrency-advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Simply run the following command to start the cryptocurrency service on 4 nodes
on the local machine:

```bash
docker run -p 8000-8008:8000-8008 exonumhub/exonum-cryptocurrency-advanced:demo
docker run -p 8000-8008:8000-8008 exonumhub/exonum-cryptocurrency-advanced:v0.13.0-rc.2
```

Ready! Find demo at [http://127.0.0.1:8008](http://127.0.0.1:8008).
Expand Down Expand Up @@ -86,12 +86,11 @@ exonum-cryptocurrency-advanced generate-config example/common.toml example/3 --
exonum-cryptocurrency-advanced generate-config example/common.toml example/4 --peer-address 127.0.0.1:6334 -n
```

Note that in case of copying files with consensus and service keys to the other machines, you must change the access permissions of these files for every machine.
Note that in case of copying file with master key to the other machines, you must change the access permissions of this file for every machine.
For example:

```sh
sudo chmod 600 consensus.toml
sudo chmod 600 service.toml
sudo chmod 600 master.key.toml
```

Finalize configs:
Expand Down
11 changes: 8 additions & 3 deletions examples/cryptocurrency-advanced/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ RUN apt-get update \
&& apt-get install -y curl git \
build-essential libsodium-dev libsnappy-dev \
librocksdb-dev pkg-config clang-7 lldb-7 lld-7 \
libprotobuf-dev protobuf-compiler
libprotobuf-dev protobuf-compiler \
python3-pip python3-setuptools

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash \
&& apt-get install -y nodejs

RUN pip3 install exonum-launcher --upgrade --no-binary=protobuf

WORKDIR /usr/src
RUN git clone --branch v0.13.0-rc.2 https://github.com/exonum/exonum.git \
&& mv /root/.cargo/bin/* /usr/bin \
&& cd exonum/examples/cryptocurrency-advanced/backend \
&& cargo update && cargo install --path . \
&& cd ../frontend && npm install && npm run build
&& cargo update && cargo install --path .
# skip frontend part until JS light client is fixed
# && cd ../frontend && npm install && npm run build
WORKDIR /usr/src/exonum/examples/cryptocurrency-advanced
COPY launch.sh .
COPY cryptocurrency_advanced.yaml .

ENTRYPOINT ["./launch.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
networks:
- host: "127.0.0.1"
ssl: false
public-api-port: 8000
private-api-port: 8004
- host: "127.0.0.1"
ssl: false
public-api-port: 8001
private-api-port: 8005
- host: "127.0.0.1"
ssl: false
public-api-port: 8002
private-api-port: 8006
- host: "127.0.0.1"
ssl: false
public-api-port: 8003
private-api-port: 8007

deadline_height: 10000
supervisor_mode: "simple"

artifacts:
cryptocurrency:
runtime: rust
name: "exonum-cryptocurrency-advanced:0.13.0-rc.2"

instances:
crypto:
artifact: cryptocurrency
14 changes: 12 additions & 2 deletions examples/cryptocurrency-advanced/docker/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@ do
sleep 1
done

cd ../../frontend
npm start -- --port=$((start_public_port + 2 * node_count)) --api-root=http://127.0.0.1:${start_public_port}
echo "Deploying of cryptocurrency-advanced service is in progress..."
sleep 7
python3 -m exonum_launcher -i ../../cryptocurrency_advanced.yaml

# TODO ECR-3882; temporary loop until frontend is disabled
while true; do
sleep 300
done

# TODO ECR-3882; skip frontend part until JS light client is fixed
#cd ../../frontend
#npm start -- --port=$((start_public_port + 2 * node_count)) --api-root=http://127.0.0.1:${start_public_port}
7 changes: 3 additions & 4 deletions examples/timestamping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Simply run the following command to start the timestamping service on 4 nodes
on the local machine:

```bash
docker run -p 8000-8008:8000-8008 exonumhub/exonum-timestamping:demo
docker run -p 8000-8008:8000-8008 exonumhub/exonum-timestamping:v0.13.0-rc.2
```

Ready! Find demo at [http://127.0.0.1:8008](http://127.0.0.1:8008).
Expand Down Expand Up @@ -80,12 +80,11 @@ exonum-timestamping generate-config example/common.toml example/3 --peer-addres
exonum-timestamping generate-config example/common.toml example/4 --peer-address 127.0.0.1:6334 -n
```

Note that in case of copying files with consensus and service keys to the other machines, you must change the access permissions of these files for every machine.
Note that in case of copying file with master key to the other machines, you must change the access permissions of this file for every machine.
For example:

```sh
sudo chmod 600 consensus.toml
sudo chmod 600 service.toml
sudo chmod 600 master.key.toml
```

Finalize generation of nodes configurations:
Expand Down
11 changes: 8 additions & 3 deletions examples/timestamping/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ RUN apt-get update \
&& apt-get install -y curl git \
build-essential libsodium-dev libsnappy-dev \
librocksdb-dev pkg-config clang-7 lldb-7 lld-7 \
libprotobuf-dev protobuf-compiler
libprotobuf-dev protobuf-compiler \
python3-pip python3-setuptools

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash \
&& apt-get install -y nodejs

RUN pip3 install exonum-launcher --upgrade --no-binary=protobuf

WORKDIR /usr/src
RUN git clone --branch v0.13.0-rc.2 https://github.com/exonum/exonum.git \
&& mv /root/.cargo/bin/* /usr/bin \
&& cd exonum/examples/timestamping/backend \
&& cargo update && cargo install --path . \
&& cd ../frontend && npm install && npm run build
&& cargo update && cargo install --path .
# skip frontend part until JS light client is fixed
# && cd ../frontend && npm install && npm run build
WORKDIR /usr/src/exonum/examples/timestamping
COPY launch.sh .
COPY timestamping.yaml .

ENTRYPOINT ["./launch.sh"]
14 changes: 12 additions & 2 deletions examples/timestamping/docker/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@ do
sleep 1
done

cd ../../frontend
npm start -- --port=$((start_public_port + 2 * node_count)) --api-root=http://127.0.0.1:${start_public_port}
echo "Deploying of timestamping service is in progress..."
sleep 7
python3 -m exonum_launcher -i ../../timestamping.yaml

# TODO ECR-3882; temporary loop until frontend is disabled
while true; do
sleep 300
done

# TODO ECR-3882; skip frontend part until JS light client is fixed
#cd ../../frontend
#npm start -- --port=$((start_public_port + 2 * node_count)) --api-root=http://127.0.0.1:${start_public_port}
37 changes: 37 additions & 0 deletions examples/timestamping/docker/timestamping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
networks:
- host: "127.0.0.1"
ssl: false
public-api-port: 8000
private-api-port: 8004
- host: "127.0.0.1"
ssl: false
public-api-port: 8001
private-api-port: 8005
- host: "127.0.0.1"
ssl: false
public-api-port: 8002
private-api-port: 8006
- host: "127.0.0.1"
ssl: false
public-api-port: 8003
private-api-port: 8007

deadline_height: 10000
supervisor_mode: "simple"

artifacts:
time:
runtime: rust
name: "exonum-time:0.13.0-rc.2"
timestamping:
runtime: rust
name: "exonum-timestamping:0.13.0-rc.2"

instances:
time:
artifact: time
timestamping:
artifact: timestamping
config:
time_service_name: "time"
time_service_id: 2

0 comments on commit ce0c375

Please sign in to comment.