version: "3.8"

services:
  blockscout-db:
    image: postgres:15
    container_name: blockscout-db
    environment:
      - POSTGRES_USER=blockscout
      - POSTGRES_PASSWORD=blockscout
      - POSTGRES_DB=blockscout
    volumes:
      - /opt/blockscout/postgres:/var/lib/postgresql/data
    networks:
      - core
    restart: unless-stopped

  blockscout:
    image: blockscout/blockscout:latest
    container_name: blockscout
    depends_on:
      - blockscout-db
    environment:
      - DATABASE_URL=postgresql://blockscout:blockscout@blockscout-db:5432/blockscout?sslmode=disable
      - ECTO_USE_SSL=false
      - ETHEREUM_JSONRPC_HTTP_URL=http://besu:8545
      - ETHEREUM_JSONRPC_WS_URL=ws://besu:8546
      - ETHEREUM_JSONRPC_TRACE_URL=http://besu:8545
      - COIN=ETH
      - NETWORK=DeFi Oracle Meta Mainnet
      - SUBNETWORK=Mainnet
      - BLOCK_TRANSFORMER=base
      - CHAIN_ID=138
      - SHOW_ADDRESS_MARKETCAP_PERCENTAGE=true
      - ENABLE_ACCOUNT_BALANCE_CACHE=true
      - ENABLE_EXCHANGE_RATES=true
      - EXCHANGE_RATES_COINGECKO_COIN_ID=ethereum
      - ENABLE_SOURCIFY_INTEGRATION=true
      - SOURCIFY_SERVER_URL=https://sourcify.dev/server
      - SOURCIFY_REPO_URL=https://repo.sourcify.dev/contracts/full_match
      - ENABLE_TXS_STATS=true
      - TXS_STATS_DAYS_TO_COMPILE_AT_INIT=1
      - ENABLE_CORS=true
      - CORS_ALLOWED_ORIGINS=https://explorer.d-bis.org,https://portfolio.metamask.io,https://metamask.io,https://chainlist.org
      - ENABLE_TOKEN_METADATA_API=true
      - TOKEN_METADATA_CACHE_ENABLED=true
      - TOKEN_METADATA_CACHE_TTL=3600
      - SECRET_KEY_BASE=change-me-in-production-use-openssl-rand-hex-32
    ports:
      - "4000:4000"
    networks:
      - core
    restart: unless-stopped
    command: ["/bin/sh", "-c", "mix do ecto.create, ecto.migrate && mix phx.server"]

networks:
  core:
    driver: bridge
