Skip to content

Commit

Permalink
Merge pull request singnet#53 from vsbogd/docker-image-for-workshop
Browse files Browse the repository at this point in the history
Docker image for workshop
  • Loading branch information
vsbogd authored Dec 12, 2018
2 parents 363d330 + 9e95a58 commit 383fecb
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 26 deletions.
48 changes: 27 additions & 21 deletions workshop/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM ubuntu:18.04

# update apt and sudo
RUN apt-get update
RUN apt-get install sudo

# add unprivileged user
RUN adduser --disabled-password --gecos '' singnet
RUN adduser singnet sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER singnet
RUN umask 0000
RUN echo 'umask 0000' >> ${HOME}/.bashrc

# setup environment variables
ENV ROOT /singnet
ENV ROOT /home/singnet
ENV GOPATH ${ROOT}
ENV BIN ${GOPATH}/bin
ENV PATH ${BIN}:${PATH}
Expand All @@ -15,25 +27,21 @@ RUN mkdir -p ${LOG}
RUN mkdir -p ${IPFS}
RUN mkdir -p ${SINGNET}

# update apt
RUN apt-get update
# install git
RUN apt-get install -y git
# install golang dev environment
RUN apt-get install -y golang go-dep golang-goprotobuf-dev golint
RUN sudo apt-get install -y git
# install NodeJS dev environment
RUN apt-get install -y nodejs npm
RUN npm install -g ganache-cli truffle
RUN sudo apt-get install -y nodejs npm
RUN sudo npm install -g ganache-cli truffle
# install Python dev environment
RUN apt-get install -y python3 python3-pip
RUN sudo apt-get install -y python3 python3-pip
# install other libraries
RUN apt-get install -y libudev-dev libusb-1.0-0-dev
RUN sudo apt-get install -y libudev-dev libusb-1.0-0-dev
# additional tools
RUN apt-get install -y net-tools screen vim
RUN sudo apt-get install -y net-tools screen vim wget

# install IPFS
ENV IPFS_PATH ${IPFS}
RUN apt-get install -y curl
RUN sudo apt-get install -y curl
COPY ./install_ipfs.sh ${GOPATH}/bin/
RUN install_ipfs.sh
# setup IPFS
Expand All @@ -54,24 +62,24 @@ RUN git clone https://github.com/singnet/platform-contracts
WORKDIR ${SINGNET}/platform-contracts
RUN git checkout -b demo v0.2.4
RUN npm install
RUN truffle compile

# snet-cli
WORKDIR ${SINGNET}
RUN git clone https://github.com/singnet/snet-cli
WORKDIR ${SINGNET}/snet-cli
RUN git checkout -b demo v0.1.8
#RUN git checkout -b demo v0.1.8
RUN ./scripts/blockchain install
RUN pip3 install -e .
RUN sudo pip3 install -e .

# snet-daemon
WORKDIR ${SINGNET}
RUN git clone https://github.com/singnet/snet-daemon
WORKDIR ${SINGNET}/snet-daemon
RUN git checkout -b demo v0.1.3
RUN ./scripts/install
RUN ./scripts/build linux amd64
RUN cp ./build/snetd-linux-amd64 ${GOPATH}/bin
WORKDIR /tmp
RUN wget https://github.com/singnet/snet-daemon/releases/download/v0.1.3/snetd-0.1.3.tar.gz && \
tar -xvf snetd-0.1.3.tar.gz && \
mv ./linux-amd64/snetd ${BIN}/snetd-linux-amd64

# wiki
WORKDIR ${SINGNET}
Expand Down Expand Up @@ -103,8 +111,6 @@ RUN snet set current_singularitynettoken_at ${TOKEN_ADDR}
RUN snet set current_registry_at ${REGISTRY_ADDR}
RUN snet set current_multipartyescrow_at ${MULTIPARTYESCROW_ADDR}

# copy examples
COPY examples ${SINGNET}/

COPY ./start_environment.sh ${GOPATH}/bin/
COPY ./stop_service.sh ${GOPATH}/bin
CMD start_environment.sh
6 changes: 3 additions & 3 deletions workshop/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Build docker image:
docker build -t singnet .
```

Run docker image:
Run docker image with examples:
```sh
docker run -ti singnet
./run.sh
```

After docker image is up you will be in the `singnet` folder which contains all
main SingularityNet git repositories and SingularityNet examples.

Please start with reading `00-snet-cli/README` file and follow instructions.
Please start with reading `examples/01-snet-cli/README` file and follow instructions.

# Preparations made in image

Expand Down
2 changes: 1 addition & 1 deletion workshop/docker/add_local_network.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

cat <<EOF >> /root/.snet/config
cat <<EOF >> ~/.snet/config
[network.local]
default_eth_rpc_endpoint = http://127.0.0.1:8545
default_gas_price = 1000000000
Expand Down
2 changes: 1 addition & 1 deletion workshop/docker/examples/01-snet-cli/README
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ snet identity deployer
snet client balance
snet contract SingularityNetToken transferTokens $CLIENT_ADDR 100000000000 --transact --yes

# deposit tokents into MultiPartyEscrow contract
# deposit tokens into MultiPartyEscrow contract
snet identity client
snet client balance
snet client deposit 1000 -y
Expand Down
2 changes: 2 additions & 0 deletions workshop/docker/examples/02-grpc-service/README
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ snet identity client
snet client open_init_channel_registry ExampleOrganization EchoService 50 57600 -y
snet client call 0 3 localhost:8080 echo '{"message": "hello"}'

# stop the service
stop_service.sh
3 changes: 3 additions & 0 deletions workshop/docker/examples/03-process-service/README
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ screen -d -m snetd-linux-amd64
snet identity client
snet client open_init_channel_registry ExampleOrganization ProcessService 50 57600 -y
snet client call 1 3 localhost:8080 echo '{"message": "hello"}'

# stop service
stop_service.sh
3 changes: 3 additions & 0 deletions workshop/docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
PWD="$( cd "$(dirname "$0")" ; pwd -P )"
docker run --user $(id -u):$(id -g) --mount "type=bind,src=${PWD}/examples,dst=/home/singnet/src/github.com/singnet/examples" -ti singnet
3 changes: 3 additions & 0 deletions workshop/docker/stop_service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
screen -ls | grep Detached | cut -d. -f1 | xargs kill

0 comments on commit 383fecb

Please sign in to comment.