From ad06fd2b70a5171640737bcb6530aa4817e4e12a Mon Sep 17 00:00:00 2001 From: zhouop0 <11733741+zhouop0@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:53:48 +0800 Subject: [PATCH] feat:add docker deploy --- deploy/docker-compose.yml | 39 +++++++++++++++++++++ deploy/postgres.sql | 71 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 deploy/docker-compose.yml create mode 100644 deploy/postgres.sql diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml new file mode 100644 index 0000000..26a14f9 --- /dev/null +++ b/deploy/docker-compose.yml @@ -0,0 +1,39 @@ +version: "3" + +services: + + postgres: + container_name: postgres-game + image: postgres:15.7 + environment: + - POSTGRES_PASSWORD=postgres + - POSTGRES_USER=postgres + - POSTGRES_DB=postgres + - PGDATA=/var/lib/postgresql/data/pgdata + ports: + - "5435:5432" + volumes: + - ./postgres1/datadir:/var/lib/postgresql/data + - ./postgres.sql:/docker-entrypoint-initdb.d/init.sql + + node1: + container_name: dispute-explorer-backend + image: ghcr.io/optimism-java/dispute-explorer:sha-0e9542b + depends_on: + - postgres + environment: + LOG_LEVEL: "info" + LOG_FORMAT: "console" + POSTGRESQL_DATA_SOURCE: "host=localhost port=5435 user=postgres password=postgres dbname=dispute_explorer sslmode=disable" + MYSQL_MAX_IDLE_CONNS: "10" + MYSQL_MAX_OPEN_CONNS: "20" + MYSQL_CONN_MAX_LIFETIME: "3600" + BLOCKCHAIN: "sepolia" + L1_RPC_URL: "https://quaint-white-season.ethereum-sepolia.quiknode.pro/b5c30cbb548d8743f08dd175fe50e3e923259d30" + FROM_BLOCK_NUMBER: "6034337" + FROM_BLOCK_HASH: "0xafc3e42c5899591501d29649ffef0bfdec68f8d77e6d44ee00ef88cfb1a2f163" + DISPUTE_GAME_PROXY_CONTRACT: "0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1" + network_mode: host + + + diff --git a/deploy/postgres.sql b/deploy/postgres.sql new file mode 100644 index 0000000..7f4a2cb --- /dev/null +++ b/deploy/postgres.sql @@ -0,0 +1,71 @@ +CREATE DATABASE dispute_explorer WITH ENCODING ='UTF8'; +-- Switch to the newly created database +\c dispute_explorer; + +-- Create sync_blocks table +DROP TABLE IF EXISTS sync_blocks; +CREATE TABLE IF NOT EXISTS sync_blocks +( + id SERIAL PRIMARY KEY, + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + blockchain VARCHAR(32) NOT NULL, + miner VARCHAR(42) NOT NULL, + block_time BIGINT NOT NULL, + block_number BIGINT NOT NULL, + block_hash VARCHAR(66) NOT NULL, + tx_count BIGINT NOT NULL, + event_count BIGINT NOT NULL, + parent_hash VARCHAR(66) NOT NULL, + status VARCHAR(32) NOT NULL, + check_count BIGINT NOT NULL +); +CREATE INDEX if not exists status_index ON sync_blocks (status); +CREATE INDEX if not exists tx_count_index ON sync_blocks (tx_count); +CREATE INDEX if not exists check_count_index ON sync_blocks (check_count); + +-- ---------------------------- +-- Table structure for dispute_game +-- ---------------------------- +DROP TABLE IF EXISTS dispute_game; +CREATE TABLE IF NOT EXISTS dispute_game +( + id SERIAL PRIMARY KEY, + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + sync_block_id BIGINT NOT NULL, + blockchain VARCHAR(32) NOT NULL, + block_time BIGINT NOT NULL, + block_number BIGINT NOT NULL, + block_hash VARCHAR(66) NOT NULL, + block_log_indexed BIGINT NOT NULL, + tx_index BIGINT NOT NULL, + tx_hash VARCHAR(66) NOT NULL, + event_name VARCHAR(32) NOT NULL, + event_hash VARCHAR(66) NOT NULL, + contract_address VARCHAR(42) NOT NULL, + game_contract varchar(42) NOT NULL, + game_type int NOT NULL, + l2_block_number bigint NOT NULL, + status int NOT NULL +); + +-- ---------------------------- +-- Table structure for game_claim_data +-- ---------------------------- +DROP TABLE IF EXISTS game_claim_data; +CREATE TABLE IF NOT EXISTS game_claim_data +( + id SERIAL PRIMARY KEY, + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + game_contract varchar(42) NOT NULL, + data_index int NOT NULL, + parent_index bigint NOT NULL, + countered_by varchar(42) NOT NULL, + claimant varchar(64) NOT NULL, + bond bigint NOT NULL, + claim varchar(64) NOT NULL, + position bigint NOT NULL, + clock bigint NOT NULL +)