diff --git a/README.md b/README.md index 5d2e771299..f2fe9d876f 100644 --- a/README.md +++ b/README.md @@ -293,7 +293,7 @@ Run `./shyft-geth.sh` with one of the following flags: Docker Images are available for ShyftGeth and the Postgresql Database which can be used for development and testing. To launch these containers you will need to have docker-compose installed on your computer. Installation instructions for docker-compose are available [here](https://docs.docker.com/install/). -To launch ShyftGeth and PG - issue the following command from the root of the project directory: +To launch ShyftGeth, PG, the ShyftBlock Explorer Api and UI - issue the following command from the root of the project directory: `docker-compose up` @@ -301,12 +301,13 @@ If you would like to reinitialize/rebuild the docker images you can issue the fo `docker-compose up --build` -The Postgresql Database Container will persist the database data to the the pg-data/ directory. So if you do want to reinitialize the database you should delete the content of this directory prior to launching the docker containers. From your local machine you can view the database by connecting to the database in the container at 127.0.0.1:8001 +The Postgresql Database Container will persist the database data to the the pg-data/ directory. So if you do want to reinitialize the database you should delete the content of this directory prior to launching the docker containers. From your local machine you can view the database by connecting to the database in the container at 127.0.0.1:8001. To access the shyftBlockExplorer open a browser and visit http://localhost:3000 + +NB: The Shyft Geth docker image size is 5+ GB so make sure you have adequate space on your disk drive/ _TODO_ -- Dockerize shyftBlockExplorerAPI -- Dockerize shyftBlockExplorerUI +- Reduce size of the ShytfGeth docker container which is responsible for mining and running the blockchain - Adjust docker scripts and ports to facilitate sending of test transactions - Modify Docker scripts to facilitate hot reloading during development diff --git a/containers/docker/develop-alpine/pg/Dockerfile b/containers/docker/develop-alpine/pg/Dockerfile index 61056561e1..90d5ca89f3 100644 --- a/containers/docker/develop-alpine/pg/Dockerfile +++ b/containers/docker/develop-alpine/pg/Dockerfile @@ -2,7 +2,8 @@ FROM postgres:10.4-alpine # @NOTE:Shyft - need to modify scripts to check db/table existence WORKDIR / -COPY ./shyft-cli/postgres_setup/docker_init_user_db.sh /docker-entrypoint-initdb.d/docker_init_user_db.sh +COPY ./shyft-cli/postgres_setup/docker_init_user_db.sh /docker-entrypoint-initdb.d/ +COPY ./shyft-cli/postgres_setup/create_tables.psql /create_tables.psql RUN cd /docker-entrypoint-initdb.d && ls -a VOLUME ["/var/lib/postgresql"] -EXPOSE 5432 \ No newline at end of file +EXPOSE 5432 diff --git a/docker-compose.yml b/docker-compose.yml index 6e97da14c9..062ce99386 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,7 @@ services: - shyftnet environment: - POSTGRES_USER=postgres - - POSGRES_PASSWORD=docker + - POSTGRES_PASSWORD=docker shyft_block_api: build: context: $PWD diff --git a/shyft-cli/postgres_setup/create_shyftdb.psql b/shyft-cli/postgres_setup/create_shyftdb.psql index 2c029ee772..c24e909f63 100644 --- a/shyft-cli/postgres_setup/create_shyftdb.psql +++ b/shyft-cli/postgres_setup/create_shyftdb.psql @@ -1 +1 @@ -CREATE DATABASE shyftdb +CREATE DATABASE shyftdb; diff --git a/shyft-cli/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql index b913fc4f25..35b1a5c927 100644 --- a/shyft-cli/postgres_setup/create_tables.psql +++ b/shyft-cli/postgres_setup/create_tables.psql @@ -55,4 +55,4 @@ CREATE TABLE IF NOT EXISTS internalTxs ( time text, input text, output text -) \ No newline at end of file +); \ No newline at end of file diff --git a/shyft-cli/postgres_setup/docker_init_user_db.sh b/shyft-cli/postgres_setup/docker_init_user_db.sh index de3db488e8..ee358a08c3 100755 --- a/shyft-cli/postgres_setup/docker_init_user_db.sh +++ b/shyft-cli/postgres_setup/docker_init_user_db.sh @@ -2,64 +2,9 @@ set -e echo $POSTGRES_USER echo $POSTGRES_DB +# createTables="$(cat /create_tables.psql)" +# echo $createTables psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE DATABASE shyftdb; - \connect shyftdb; - CREATE TABLE IF NOT EXISTS blocks ( - hash text primary key, - coinbase text, - gasUsed numeric, - gasLimit numeric, - txCount numeric, - uncleCount numeric, - age timestamp, - parentHash text, - uncleHash text, - difficulty bigint, - size text, - nonce numeric, - rewards numeric, - number bigint - ); - CREATE TABLE IF NOT EXISTS txs ( - txHash text primary key unique, - to_addr text, - from_addr text, - blockhash text references blocks(hash), - blocknumber text, - amount numeric, - gasprice numeric, - gas numeric, - gasLimit numeric, - txFee numeric, - nonce numeric, - txStatus text, - isContract bool, - age timestamp, - data bytea - ); - - CREATE TABLE IF NOT EXISTS accounts ( - addr text primary key unique, - balance numeric, - txCountAccount numeric - ); - - CREATE TABLE IF NOT EXISTS contracts ( - txHash text - ); - - CREATE TABLE IF NOT EXISTS internalTxs ( - id SERIAL PRIMARY KEY, - txHash text references txs(txHash), - type text, - to_addr text, - from_addr text, - amount text, - gas numeric, - gasUsed numeric, - time text, - input text, - output text - ); EOSQL +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d shyftdb < /create_tables.psql diff --git a/shyft-cli/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql index 8826b85093..368c809a42 100644 --- a/shyft-cli/postgres_setup/drop_tables.psql +++ b/shyft-cli/postgres_setup/drop_tables.psql @@ -1,3 +1,5 @@ +\connect +shyftdb; DROP TABLE internalTxs; DROP TABLE txs; DROP TABLE blocks;