mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Interim Dockerize
This commit is contained in:
parent
d6270fbe94
commit
5c009528a9
6 changed files with 96 additions and 5 deletions
|
|
@ -1,3 +1,9 @@
|
|||
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
|
||||
RUN cd /docker-entrypoint-initdb.d && ls -a
|
||||
|
||||
|
||||
EXPOSE 5432
|
||||
|
|
@ -12,6 +12,7 @@ RUN \
|
|||
COPY ./shyft-cli/initShyftGeth.sh /
|
||||
COPY ./shyft-cli/resetShyftGeth.sh /
|
||||
COPY ./shyft-cli/startShyftGeth.sh /
|
||||
# COPY ./containers/docker/develop-alpine/shyftGeth/wait-for-postgres.sh /
|
||||
COPY config.toml /
|
||||
COPY unlockPasswords.txt /
|
||||
COPY ShyftNetwork.json /
|
||||
|
|
@ -26,6 +27,5 @@ RUN cd / && ls -a
|
|||
# EXPOSE 8545
|
||||
# EXPOSE 30303
|
||||
WORKDIR /
|
||||
RUN ["./initShyftGeth.sh"]
|
||||
|
||||
ENTRYPOINT ["./startShyftGeth.sh"]
|
||||
CMD ["./initShyftGeth.sh"]
|
||||
|
|
@ -8,8 +8,9 @@ import (
|
|||
var blockExplorerDb *sql.DB
|
||||
|
||||
const (
|
||||
connStr = "user=postgres dbname=shyftdb sslmode=disable"
|
||||
connStrTest = "user=postgres dbname=shyftdbtest sslmode=disable"
|
||||
// connStr = "user=postgres dbname=shyftdb password=docker sslmode=disable"
|
||||
connStr = "postgresql://postgres:docker@pg:5432/shyftdb"
|
||||
connStrTest = "user=postgres dbname=shyftdbtest password=docker sslmode=disable"
|
||||
)
|
||||
|
||||
func InitDB() (*sql.DB, error) {
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@
|
|||
- "5432:5432"
|
||||
volumes:
|
||||
- .:/go/src/ShyftNetwork/go-empyrean
|
||||
working_dir: /go/src/ShyftNetwork/go-empyrean
|
||||
# working_dir: /go/src/ShyftNetwork/go-empyrean
|
||||
depends_on:
|
||||
- pg
|
||||
# command: ["./wait-for-postgres.sh", "pg:5432","./initShyftGeth.sh" ]
|
||||
entrypoint: ["/go/src/ShyftNetwork/go-empyrean/wait-for-postgres.sh", "pg:5432","/go/src/ShyftNetwork/go-empyrean/shyft-cli/initShyftGeth.sh"]
|
||||
pg:
|
||||
build:
|
||||
context: $PWD
|
||||
|
|
@ -29,6 +31,7 @@
|
|||
- POSTGRES_USER=postgres
|
||||
- POSGRES_PASSWORD=docker
|
||||
- PGDATA=/pg-data
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
65
shyft-cli/postgres_setup/docker_init_user_db.sh
Executable file
65
shyft-cli/postgres_setup/docker_init_user_db.sh
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
echo $POSTGRES_USER
|
||||
echo $POSTGRES_DB
|
||||
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
|
||||
16
wait-for-postgres.sh
Executable file
16
wait-for-postgres.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
# wait-for-postgres.sh
|
||||
|
||||
set -e
|
||||
|
||||
host="$1"
|
||||
shift
|
||||
cmd="$@"
|
||||
|
||||
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -U "postgres" -c '\q'; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - executing command"
|
||||
exec $cmd
|
||||
Loading…
Reference in a new issue