Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen committed Jan 14, 2023
1 parent 9234055 commit acf8115
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 90 deletions.
87 changes: 4 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,89 +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
```

### 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 @@ -230,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
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:
12 changes: 8 additions & 4 deletions docker-dev.sh → docker/docker-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
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
./get-deps.sh
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)
Expand All @@ -14,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 @@ -30,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
1 change: 1 addition & 0 deletions get-deps.sh → docker/get-deps.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/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
Expand Down

0 comments on commit acf8115

Please sign in to comment.