Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: Attempt review comments #1

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
88 changes: 4 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,90 +125,6 @@ yarn test

Visit http://localhost:4400/ to see the Webb Component Library! 🕸️ 🚀

## Docker

### Setup Container

* Install and run [Docker](https://www.docker.com/)
* Generate .env file from sample file
```bash
cp .env.example .env
```
* Run Substrate front-end from a Docker container and follow the terminal log instructions.
```bash
./docker-dev.sh
```
Note: The script requires `jq` command to be installed (i.e. Ubuntu `apt-get install -y jq`)

### Run Bridge Dapp

* Enter Docker container
```bash
# last created docker container id
CONTAINER_ID=$(docker ps -n=1 -q)
docker exec -it $CONTAINER_ID yarn start:bridge
```
* Wait until it says `webpack ... compiled`
* Go to http://<IP_ADDRESS>:3000

Note: If run on your local machine then Substitute <IP_ADDRESS> with `localhost`. If hosted on a remote cloud provider then substitute it with the Public IP Address of the cloud provider server instance.

### Run Stats Dapp

* Enter Docker container
```bash
docker exec -it $CONTAINER_ID yarn start:stats
```
* Wait until it says `webpack ... compiled`
* Go to http://<IP_ADDRESS>:3001

### Expose Ports

* Open relevant ports if necessary
```
source .env && export PORT_BRIDGE_DAPP PORT_STATS_DAPP
apt install ufw
ufw default allow outgoing
ufw default allow incoming
ufw enable
ufw allow $PORT_BRIDGE_DAPP/tcp && ufw allow $PORT_BRIDGE_DAPP/udp
ufw allow $PORT_STATS_DAPP/tcp && ufw allow $PORT_STATS_DAPP/udp
ufw reload
ufw status
```

### Useful Docker Commands

* List Docker containers
```bash
docker ps -a
```

* List Docker images
```bash
docker images -a
```

* Enter Docker container shell
```bash
docker exec -it $CONTAINER_ID /bin/sh
```

* View Docker container logs
```bash
docker logs -f $CONTAINER_ID
```

* Remove Docker container
```bash
docker stop $CONTAINER_ID; docker rm $CONTAINER_ID;
```

* Remove Docker image
```bash
docker rmi $IMAGE_ID
```

<h2 id="contribute"> Contributing </h2>

Interested in contributing to the Webb Dapp interface? Thank you so much for your interest! We are always appreciative for contributions from the open-source community!
Expand All @@ -231,6 +147,10 @@ yarn lint
yarn build
```

## Docker

See [Webb Builder Docker](./docker/README.md)

<h2 id="license"> License </h2>

Licensed under <a href="LICENSE">Apache 2.0 license</a>.
Expand Down
1 change: 1 addition & 0 deletions apps/bridge-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@babel/core": "^7.19.0",
"@babel/node": "^7.16.8",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-syntax-import-assertions": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
Expand Down
1 change: 1 addition & 0 deletions apps/bridge-dapp/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function createWebpack(env, mode = 'production') {
{ loose: false },
],
['@babel/plugin-proposal-private-methods', { loose: false }],
'@babel/plugin-syntax-import-assertions',
].filter(Boolean),
},
},
Expand Down
83 changes: 83 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Webb Builder Docker

## Setup Container

* Install and run [Docker](https://www.docker.com/) Engine and Compose
* Generate .env file from sample file in the project root directory
```bash
cp .env.example .env
```
* Build Webb Docker image and container and follow the terminal log instructions.
```bash
cd docker
./docker-dev.sh
```

## Run Bridge Dapp

* Enter Docker container
```bash
# last created docker container id
CONTAINER_ID=$(docker ps -n=1 -q)
docker exec -it $CONTAINER_ID yarn start:bridge
```
* Wait until it says `webpack ... compiled`
* Go to http://<IP_ADDRESS>:3000

Note: If run on your local machine then Substitute <IP_ADDRESS> with `localhost`. If hosted on a remote cloud provider then substitute it with the Public IP Address of the cloud provider server instance.

## Run Stats Dapp

* Enter Docker container
```bash
docker exec -it $CONTAINER_ID yarn start:stats
```
* Wait until it says `webpack ... compiled`
* Go to http://<IP_ADDRESS>:3001

## Expose Ports

* Open relevant ports if necessary
```
source .env && export PORT_BRIDGE_DAPP PORT_STATS_DAPP
apt install ufw
ufw default allow outgoing
ufw default allow incoming
ufw enable
ufw allow $PORT_BRIDGE_DAPP/tcp && ufw allow $PORT_BRIDGE_DAPP/udp
ufw allow $PORT_STATS_DAPP/tcp && ufw allow $PORT_STATS_DAPP/udp
ufw reload
ufw status
```

## Useful Docker Commands

* List Docker containers
```bash
docker ps -a
```

* List Docker images
```bash
docker images -a
```

* Enter Docker container shell
```bash
docker exec -it $CONTAINER_ID /bin/sh
```

* View Docker container logs
```bash
docker logs -f $CONTAINER_ID
```

* Remove Docker container
```bash
docker stop $CONTAINER_ID; docker rm $CONTAINER_ID;
```

* Remove Docker image
```bash
docker rmi $IMAGE_ID
```
6 changes: 3 additions & 3 deletions docker-compose-dev.yml → docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: ${NAME_PROJECT}-dev
restart: always
build:
context: "."
context: "../"
dockerfile: ./docker/Dockerfile.dev
args:
- NAME_PROJECT=${NAME_PROJECT}
Expand All @@ -13,13 +13,13 @@ services:
- PORT_BRIDGE_DAPP=${PORT_BRIDGE_DAPP}
- PORT_STATS_DAPP=${PORT_STATS_DAPP}
volumes:
- ./:/app/${NAME_PROJECT}:delegated
- ../:/app/${NAME_PROJECT}:delegated
- ignore:/app/${NAME_PROJECT}/node_modules
ports:
- "${PORT_BRIDGE_DAPP}:${PORT_BRIDGE_DAPP}"
- "${PORT_STATS_DAPP}:${PORT_STATS_DAPP}"
env_file:
- .env
- ../.env

volumes:
ignore:
13 changes: 10 additions & 3 deletions docker-dev.sh → docker/docker-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
trap "echo; exit" INT
trap "echo; exit" HUP

# The following get the project root
DOCKER_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
PROJECT_ROOT=$(dirname "$DOCKER_DIR")

# try to install wget and curl depending on host operating system
bash -c $DOCKER_DIR/get-deps.sh

# try to fetch public IP address if value not set in .env
PUBLIC_IP_ADDRESS_FALLBACK=$(wget http://ipecho.net/plain -O - -q ; echo)
NAME_PROJECT_FALLBACK=webb-monorepo
Expand All @@ -11,8 +18,8 @@ NAME_STATS_DAPP_FALLBACK=stats-dapp

# assign fallback values for environment variables from .env.example incase
# not declared in .env file. alternative approach is `echo ${X:=$X_FALLBACK}`
source $(dirname "$0")/.env.example
source $(dirname "$0")/.env
source $PROJECT_ROOT/.env.example
source $PROJECT_ROOT/.env
export NAME_PROJECT=$(jq '.name' $PWD/package.json | sed 's/\"//g')
export NAME_BRIDGE_DAPP=$(jq '.name' $PWD/apps/bridge-dapp/package.json | sed 's/\"//g' | sed 's/.*\///g')
export NAME_STATS_DAPP=$(jq '.name' $PWD/apps/stats-dapp/package.json | sed 's/\"//g' | sed 's/.*\///g')
Expand All @@ -27,7 +34,7 @@ if [ "$NODE_ENV" != "development" ]; then
fi
printf "\n*** Started building Docker container."
printf "\n*** Please wait... \n***"
DOCKER_BUILDKIT=0 docker compose -f docker-compose-dev.yml up --build -d
DOCKER_BUILDKIT=0 docker compose -f $DOCKER_DIR/docker-compose-dev.yml up --build -d
if [ $? -ne 0 ]; then
kill "$PPID"; exit 1;
fi
Expand Down
34 changes: 34 additions & 0 deletions docker/get-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Copyright 2015-2020 Parity Technologies (UK) Ltd.
# Reference: https://github.com/paritytech/scripts/blob/master/get-substrate.sh

if [[ "$OSTYPE" == "linux-gnu" ]]; then
set -e
if [[ $(whoami) == "root" ]]; then
MAKE_ME_ROOT=
else
MAKE_ME_ROOT=sudo
fi

echo "Updating package information and installing dependencies."
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get install -y curl jq wget
elif [[ "$OSTYPE" == "darwin"* ]]; then
set -e
echo "Mac OS (Darwin) detected."

if ! which brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi

echo "Updating Homebrew and installing dependencies."
brew update -v
brew install curl jq wget
xcode-select --install
else
echo "Unknown operating system."
echo "This OS is not supported with this script at present. Sorry. Please install dependencies manually."
echo "Please refer to https://github.com/webb-tools/webb-dapp/blob/develop/docker/REAMDE.md for setup information."
exit 1
fi