Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
19 changes: 19 additions & 0 deletions docker/Dockerfile.one
Original file line number Diff line number Diff line change
@@ -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"]
56 changes: 56 additions & 0 deletions docker/Dockerfile.two
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions docker/dir-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

cd ~/
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
69 changes: 69 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
105 changes: 105 additions & 0 deletions docker/instructions.md
Original file line number Diff line number Diff line change
@@ -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
```
13 changes: 13 additions & 0 deletions docker/run-server.sh
Original file line number Diff line number Diff line change
@@ -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