From 771bb05a47f63092dcecbc0c39f76f3d3ca7b8cd Mon Sep 17 00:00:00 2001 From: Rohit Narurkar Date: Fri, 14 Dec 2018 13:53:17 +0800 Subject: [PATCH 1/2] add instructions for setting up docker containers --- DAO_SYSTEMS.md | 106 ++++++++++++++++++++++++++++++ scripts/docker/.dockerignore | 0 scripts/docker/Dockerfile.one | 0 scripts/docker/Dockerfile.two | 0 scripts/docker/dir-setup.sh | 24 +++++++ scripts/docker/docker-compose.yml | 0 scripts/docker/run-server.sh | 0 7 files changed, 130 insertions(+) create mode 100644 scripts/docker/.dockerignore create mode 100644 scripts/docker/Dockerfile.one create mode 100644 scripts/docker/Dockerfile.two create mode 100644 scripts/docker/dir-setup.sh create mode 100644 scripts/docker/docker-compose.yml create mode 100644 scripts/docker/run-server.sh diff --git a/DAO_SYSTEMS.md b/DAO_SYSTEMS.md index f949804..a49a3cf 100644 --- a/DAO_SYSTEMS.md +++ b/DAO_SYSTEMS.md @@ -80,3 +80,109 @@ This will: ``` bash scripts/restart.sh ``` + +## Run as Docker Containers +You can run every required service as docker containers in local machine. Finally, it should run containers for the following images: +* IPFS +* MySQL +* MongoDB +* Ganache +* DAO Server +* Info Server, DAO contracts and Governance UI (all these run in the same container, as they're dependent on DAO contracts) + +##### Install packages +* docker-ce +``` +$ sudo apt-get update +$ sudo apt-get install \ + apt-transport-https \ + ca-certificates \ + curl \ + software-properties-common +$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +$ sudo apt-get update +$ sudo apt-get install docker-ce +``` +**Note:** The above should work for Ubuntu 16.04 and 18.04 LTS +* verify installation by running a test container +``` +$ sudo docker run hello-world +``` +* docker-compose +``` +$ sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +$ sudo chmod +x /usr/local/bin/docker-compose +``` +* verify installation by checking the version +``` +$ docker-compose --version +``` + +##### Setup +* move to whatever is your base directory (say, its `~/`) +``` +$ cd ~/ +``` +* download the script to setup your directory structure +``` +$ curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/f672ccde33e57be73783b4179887600d0a4d2cc8/dir-setup.sh +``` +**Note:** Alternatively, this file can also be found in the `scripts/docker/` directory +* run the above script that was downloaded +``` +$ chmod 777 dir-setup.sh +$ bash dir-setup.sh +``` +* verify that the following directory/file structure has been created +``` +base-dir + ├── dir-setup.sh + └── digix-dao/ + ├── dao-server/ + ├── info-server/ + ├── dao-contracts/ + ├── digix-dao-ui/ + | ├── governance-ui-components/ + | ├── governance-ui/ + | └── react-material-ui-suite/ + ├── run-server.sh + ├── Dockerfile.one + ├── Dockerfile.two + ├── docker-compose.yml + └── .dockerignore +``` + +##### Run +* build the images (in `~/digix-dao`) +``` +$ docker-compose build +``` +* start the containers +``` +$ docker-compose up +``` + +##### Testing +* The same keystores have been used as the digixdao-kovan [keystores](https://tracker.digixdev.com/_persistent/digixdao-kovan.zip?file=6-181&c=false&updated=0) + * Password: `digixdao-kovan` (for all keystores) +* Endpoints + * UI: https://localhost:3000 + * Info-server: http://localhost:3001 + * Dao-server: http://localhost:3005 + * MongoDB: `$ mongo` in terminal should work + * MySQL: Can be run from the docker container (password `digixtest`) + ``` + $ docker exec -it CONTAINER-ID /bin/bash + + # mysql -u root -p + ``` +* Logging + * Dao-server: + ``` + $ docker logs -f CONTAINER-ID + ``` + * Info-server: + ``` + $ docker exec -it CONTAINER-ID /bin/bash + # tail -f /usr/src/info-server/out.log + ``` diff --git a/scripts/docker/.dockerignore b/scripts/docker/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/scripts/docker/Dockerfile.one b/scripts/docker/Dockerfile.one new file mode 100644 index 0000000..e69de29 diff --git a/scripts/docker/Dockerfile.two b/scripts/docker/Dockerfile.two new file mode 100644 index 0000000..e69de29 diff --git a/scripts/docker/dir-setup.sh b/scripts/docker/dir-setup.sh new file mode 100644 index 0000000..b0d2e74 --- /dev/null +++ b/scripts/docker/dir-setup.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +mkdir digix-dao && cd digix-dao + +git clone git@github.com:DigixGlobal/dao-contracts.git +cd dao-contracts && git checkout staging-docker && cd .. +git clone git@github.com:DigixGlobal/dao-server.git +cd dao-server && git checkout staging-docker && cd .. +git clone git@github.com:DigixGlobal/info-server.git +cd info-server && git checkout staging-docker && cd .. + +mkdir digix-dao-ui && cd digix-dao-ui +git clone git@github.com:DigixGlobal/governance-ui-components.git +cd governance-ui-components && git checkout staging-docker && cd .. +git clone git@github.com:DigixGlobal/governance-ui.git +cd governance-ui && git checkout staging-docker && cd .. +git clone git@github.com:DigixGlobal/react-material-ui-suite.git +cd .. + +curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/0db4393ad5cea81b0e2bc14bea76decebed9062d/.dockerignore +curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/0db4393ad5cea81b0e2bc14bea76decebed9062d/docker-compose.yml +curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/0db4393ad5cea81b0e2bc14bea76decebed9062d/Dockerfile.one +curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/0db4393ad5cea81b0e2bc14bea76decebed9062d/Dockerfile.two +curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/0db4393ad5cea81b0e2bc14bea76decebed9062d/run-server.sh diff --git a/scripts/docker/docker-compose.yml b/scripts/docker/docker-compose.yml new file mode 100644 index 0000000..e69de29 diff --git a/scripts/docker/run-server.sh b/scripts/docker/run-server.sh new file mode 100644 index 0000000..e69de29 From 8499bcf4b56540e01ee8adfe8fdc971d916d5e13 Mon Sep 17 00:00:00 2001 From: Rohit Narurkar Date: Fri, 14 Dec 2018 13:59:14 +0800 Subject: [PATCH 2/2] fix --- DAO_SYSTEMS.md | 106 ------------------------ docker/.dockerignore | 1 + docker/Dockerfile.one | 19 +++++ docker/Dockerfile.two | 56 +++++++++++++ {scripts/docker => docker}/dir-setup.sh | 1 + docker/docker-compose.yml | 69 +++++++++++++++ docker/instructions.md | 105 +++++++++++++++++++++++ docker/run-server.sh | 13 +++ scripts/docker/.dockerignore | 0 scripts/docker/Dockerfile.one | 0 scripts/docker/Dockerfile.two | 0 scripts/docker/docker-compose.yml | 0 scripts/docker/run-server.sh | 0 13 files changed, 264 insertions(+), 106 deletions(-) create mode 100644 docker/.dockerignore create mode 100644 docker/Dockerfile.one create mode 100644 docker/Dockerfile.two rename {scripts/docker => docker}/dir-setup.sh (99%) create mode 100644 docker/docker-compose.yml create mode 100644 docker/instructions.md create mode 100644 docker/run-server.sh delete mode 100644 scripts/docker/.dockerignore delete mode 100644 scripts/docker/Dockerfile.one delete mode 100644 scripts/docker/Dockerfile.two delete mode 100644 scripts/docker/docker-compose.yml delete mode 100644 scripts/docker/run-server.sh diff --git a/DAO_SYSTEMS.md b/DAO_SYSTEMS.md index a49a3cf..f949804 100644 --- a/DAO_SYSTEMS.md +++ b/DAO_SYSTEMS.md @@ -80,109 +80,3 @@ This will: ``` bash scripts/restart.sh ``` - -## Run as Docker Containers -You can run every required service as docker containers in local machine. Finally, it should run containers for the following images: -* IPFS -* MySQL -* MongoDB -* Ganache -* DAO Server -* Info Server, DAO contracts and Governance UI (all these run in the same container, as they're dependent on DAO contracts) - -##### Install packages -* docker-ce -``` -$ sudo apt-get update -$ sudo apt-get install \ - apt-transport-https \ - ca-certificates \ - curl \ - software-properties-common -$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -$ sudo apt-get update -$ sudo apt-get install docker-ce -``` -**Note:** The above should work for Ubuntu 16.04 and 18.04 LTS -* verify installation by running a test container -``` -$ sudo docker run hello-world -``` -* docker-compose -``` -$ sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose -$ sudo chmod +x /usr/local/bin/docker-compose -``` -* verify installation by checking the version -``` -$ docker-compose --version -``` - -##### Setup -* move to whatever is your base directory (say, its `~/`) -``` -$ cd ~/ -``` -* download the script to setup your directory structure -``` -$ curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/f672ccde33e57be73783b4179887600d0a4d2cc8/dir-setup.sh -``` -**Note:** Alternatively, this file can also be found in the `scripts/docker/` directory -* run the above script that was downloaded -``` -$ chmod 777 dir-setup.sh -$ bash dir-setup.sh -``` -* verify that the following directory/file structure has been created -``` -base-dir - ├── dir-setup.sh - └── digix-dao/ - ├── dao-server/ - ├── info-server/ - ├── dao-contracts/ - ├── digix-dao-ui/ - | ├── governance-ui-components/ - | ├── governance-ui/ - | └── react-material-ui-suite/ - ├── run-server.sh - ├── Dockerfile.one - ├── Dockerfile.two - ├── docker-compose.yml - └── .dockerignore -``` - -##### Run -* build the images (in `~/digix-dao`) -``` -$ docker-compose build -``` -* start the containers -``` -$ docker-compose up -``` - -##### Testing -* The same keystores have been used as the digixdao-kovan [keystores](https://tracker.digixdev.com/_persistent/digixdao-kovan.zip?file=6-181&c=false&updated=0) - * Password: `digixdao-kovan` (for all keystores) -* Endpoints - * UI: https://localhost:3000 - * Info-server: http://localhost:3001 - * Dao-server: http://localhost:3005 - * MongoDB: `$ mongo` in terminal should work - * MySQL: Can be run from the docker container (password `digixtest`) - ``` - $ docker exec -it CONTAINER-ID /bin/bash - - # mysql -u root -p - ``` -* Logging - * Dao-server: - ``` - $ docker logs -f CONTAINER-ID - ``` - * Info-server: - ``` - $ docker exec -it CONTAINER-ID /bin/bash - # tail -f /usr/src/info-server/out.log - ``` diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/docker/Dockerfile.one b/docker/Dockerfile.one new file mode 100644 index 0000000..c44ce79 --- /dev/null +++ b/docker/Dockerfile.one @@ -0,0 +1,19 @@ +FROM ruby:2.5.3 +RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs vim + +RUN mkdir /dao-server + +WORKDIR /usr/src/dao-server +COPY dao-server/Gemfile /usr/src/dao-server/Gemfile +COPY dao-server/Gemfile.lock /usr/src/dao-server/Gemfile.lock +RUN bundle install + +ADD dao-server/ /usr/src/dao-server + +RUN chmod 755 docker-entrypoint.sh +RUN chmod 755 wait-for-it.sh +ENTRYPOINT ["/usr/src/dao-server/docker-entrypoint.sh"] + +EXPOSE 3005 + +CMD ["./wait-for-it.sh", "db:3306", "--", "bundle", "exec", "rails", "s", "-b", "0.0.0.0", "-p", "3005"] diff --git a/docker/Dockerfile.two b/docker/Dockerfile.two new file mode 100644 index 0000000..dd0f71c --- /dev/null +++ b/docker/Dockerfile.two @@ -0,0 +1,56 @@ +FROM ubuntu:16.04 + +RUN apt-get update -qq && apt-get install -y libcairo2-dev \ + libjpeg8-dev libpango1.0-dev libgif-dev build-essential \ + g++ libusb-1.0-0-dev curl git + +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash +RUN apt-get install --yes nodejs +RUN node -v +RUN npm -v + +RUN mkdir -p /usr/src/dao-contracts +WORKDIR /usr/src/dao-contracts +COPY dao-contracts/package.json ./ +RUN npm install +RUN cd node_modules/truffle && npm install solc@0.4.25 && cd ../.. +COPY dao-contracts/ /usr/src/dao-contracts/ +ENV KEYSTORE /usr/src/dao-contracts/sigmate-v3-test-local.json +ENV PASSWORD test-local +RUN /usr/src/dao-contracts/node_modules/.bin/truffle compile + +RUN mkdir -p /usr/src/info-server +WORKDIR /usr/src/info-server +COPY info-server/package.json ./ +RUN npm install +COPY info-server/ /usr/src/info-server/ + +RUN mkdir -p /usr/src/ui/react-material-ui-suite +WORKDIR /usr/src/ui/react-material-ui-suite +COPY digix-dao-ui/react-material-ui-suite/package.json ./ +RUN npm install +COPY digix-dao-ui/react-material-ui-suite /usr/src/ui/react-material-ui-suite + +RUN mkdir -p /usr/src/ui/governance-ui-components +WORKDIR /usr/src/ui/governance-ui-components +COPY digix-dao-ui/governance-ui-components/package.json ./ +RUN npm install +COPY digix-dao-ui/governance-ui-components /usr/src/ui/governance-ui-components + +RUN mkdir -p /usr/src/ui/governance-ui +WORKDIR /usr/src/ui/governance-ui +COPY digix-dao-ui/governance-ui/package.json ./ +RUN npm install +COPY digix-dao-ui/governance-ui /usr/src/ui/governance-ui + +WORKDIR /usr/src/ +COPY run-server.sh ./ +RUN chmod 777 /usr/src/dao-contracts/docker-entrypoint.sh +RUN chmod 777 /usr/src/run-server.sh + +WORKDIR /usr/src/dao-contracts +ENTRYPOINT ["/usr/src/dao-contracts/docker-entrypoint.sh"] +CMD ["../run-server.sh"] + +EXPOSE 3001 +EXPOSE 3000 diff --git a/scripts/docker/dir-setup.sh b/docker/dir-setup.sh similarity index 99% rename from scripts/docker/dir-setup.sh rename to docker/dir-setup.sh index b0d2e74..a9ff522 100644 --- a/scripts/docker/dir-setup.sh +++ b/docker/dir-setup.sh @@ -1,5 +1,6 @@ #!/bin/bash +cd ~/ mkdir digix-dao && cd digix-dao git clone git@github.com:DigixGlobal/dao-contracts.git diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..8c9a37e --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,69 @@ +version: '3' +services: + ipfs: + image: jbenet/go-ipfs + ports: + - "4001:4001" + - "5001:5001" + - "9001:9001" + - "8081:8080" + volumes: + - .ipfs-docker-data:/data/ipfs/ + - .ipfs-docker-staging:/export + ganache: + image: trufflesuite/ganache-cli + ports: + - "8545:8545" + volumes: + - ./ganache-data:/ganache-data + command: ["ganache-cli", "-h=0.0.0.0", "-p=8545", "--mnemonic=candy ignore tape escape hen elder amazing august hungry target embody fault", "-a=25", "-l=0xfffffffffff", "--quiet"] + mongo: + image: mongo + ports: + - "27017:27017" + db: + image: mysql:5.7 + ports: + - "3307:3306" + environment: + MYSQL_USER: root + MYSQL_ROOT_PASSWORD: digixtest + MYSQL_DATABASE: dao_dev + dao-server: + build: + context: . + dockerfile: Dockerfile.one + volumes: + - .:/dao-server + ports: + - "3005:3005" + env_file: + - dao-server/.env + links: + - db:digixdao + depends_on: + - db + dao-contracts-info-server: + build: + context: . + dockerfile: Dockerfile.two + env_file: + - dao-contracts/.env + ports: + - "3001:3001" + - "3000:3000" + links: + - ipfs + - ganache + - mongo + - dao-server + environment: + IPFS_HOST: ipfs + IPFS_ENDPOINT_PORT: 5001 + HTTP_ENDPOINT_PORT: 9001 + depends_on: + - ipfs + - ganache + - mongo + - dao-server + tty: true diff --git a/docker/instructions.md b/docker/instructions.md new file mode 100644 index 0000000..40dd813 --- /dev/null +++ b/docker/instructions.md @@ -0,0 +1,105 @@ +# Run as Docker Containers +You can run every required service as docker containers in local machine. Finally, it should run containers for the following images: +* IPFS +* MySQL +* MongoDB +* Ganache +* DAO Server +* Info Server, DAO contracts and Governance UI (all these run in the same container, as they're dependent on DAO contracts) + +### Install packages +* docker-ce +``` +$ sudo apt-get update +$ sudo apt-get install \ + apt-transport-https \ + ca-certificates \ + curl \ + software-properties-common +$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +$ sudo apt-get update +$ sudo apt-get install docker-ce +``` +**Note:** The above should work for Ubuntu 16.04 and 18.04 LTS +* verify installation by running a test container +``` +$ sudo docker run hello-world +``` +* docker-compose +``` +$ sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +$ sudo chmod +x /usr/local/bin/docker-compose +``` +* verify installation by checking the version +``` +$ docker-compose --version +``` + +### Setup +* move to whatever is your base directory (say, its `~/`) +``` +$ cd ~/ +``` +* download the script to setup your directory structure +``` +$ curl -OL https://gist.githubusercontent.com/roynalnaruto/25ed74dc22aa24960990d83cc80ce6b7/raw/f672ccde33e57be73783b4179887600d0a4d2cc8/dir-setup.sh +``` +**Note:** Alternatively, this file can also be found in the `scripts/docker/` directory +* run the above script that was downloaded +``` +$ chmod 777 dir-setup.sh +$ bash dir-setup.sh +``` +* verify that the following directory/file structure has been created +``` +base-dir + ├── dir-setup.sh + └── digix-dao/ + ├── dao-server/ + ├── info-server/ + ├── dao-contracts/ + ├── digix-dao-ui/ + | ├── governance-ui-components/ + | ├── governance-ui/ + | └── react-material-ui-suite/ + ├── run-server.sh + ├── Dockerfile.one + ├── Dockerfile.two + ├── docker-compose.yml + └── .dockerignore +``` + +### Run +* build the images (in `~/digix-dao`) +``` +$ docker-compose build +``` +* start the containers +``` +$ docker-compose up +``` + +### Testing +* The same keystores have been used as the digixdao-kovan [keystores](https://tracker.digixdev.com/_persistent/digixdao-kovan.zip?file=6-181&c=false&updated=0) + * Password: `digixdao-kovan` (for all keystores) +* Endpoints + * UI: https://localhost:3000 + * Info-server: http://localhost:3001 + * Dao-server: http://localhost:3005 + * MongoDB: `$ mongo` in terminal should work + * MySQL: Can be run from the docker container (password `digixtest`) + ``` + $ docker exec -it CONTAINER-ID /bin/bash + + # mysql -u root -p + ``` +* Logging + * Dao-server: + ``` + $ docker logs -f CONTAINER-ID + ``` + * Info-server: + ``` + $ docker exec -it CONTAINER-ID /bin/bash + # tail -f /usr/src/info-server/out.log + ``` diff --git a/docker/run-server.sh b/docker/run-server.sh new file mode 100644 index 0000000..9115ac5 --- /dev/null +++ b/docker/run-server.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd /usr/src/info-server/ +echo "starting info-server" +rm -f out.log +./node_modules/.bin/pm2 start development.config.js + +cd /usr/src/ui/governance-ui +echo "starting governance ui" +npm start + +cd /usr/src/info-server +tail -f out.log diff --git a/scripts/docker/.dockerignore b/scripts/docker/.dockerignore deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/docker/Dockerfile.one b/scripts/docker/Dockerfile.one deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/docker/Dockerfile.two b/scripts/docker/Dockerfile.two deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/docker/docker-compose.yml b/scripts/docker/docker-compose.yml deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/docker/run-server.sh b/scripts/docker/run-server.sh deleted file mode 100644 index e69de29..0000000