Skip to content

Deploying explorer services with docker compose

Mark Glasgow edited this page May 7, 2022 · 6 revisions

Deplying explorer backend services

Prerequisites: Docker, docker-compose

  1. Publish service images locally

  2. Set up a working environment

    • Create a working directory and put your docker-compose.yaml into it (sample is attached)
    • Create .X_env files with environment vars in order to configure services
      • All vars are listed in default config of the corresponding service.
      • Example: explorer-api - modules/explorer-api/src/main/resources/application.conf

These env files are then referenced in the service definition within docker-compose.yaml:

    api:
        image: oskin1/explorer-api:latest
        env_file:
        - .db_env
        - .redis_env
        - .http_env
        ...

.db_env contents:

DB_URL=jdbc:postgresql://postgres:5432/<db_name>
DB_USER=<db_useer>
DB_PASS=<db_pass>
  • Create docker network docker network create explorer-network
  1. Prepare frontend build

    • Clone https://github.com/ergoplatform/explorer-frontend.git
    • cd explorer-frontend
    • mkdir /<your_working_dir>/front/build
    • cp -r build /<your_working_dir>/front
    • mkdir /<your_working_dir>/front/config
    • Create app.config.js in /<your_working_dir>/front/config (sample is attached below, you need to change apiUrl key pointing to backend API. environments.url can be pointed to your frontend)
  2. Configure other services (such as: nginx, postgres, redis, adminer) according to their documentaion

  3. Run docker-compose up -d (in your working directory) then docker ps -a to make sure everything up and working.

app.config.js example:

var __APP_CONFIG__ = {
  apiUrl: 'https://api.ergoplatform.com',
  alternativeLogo: false, // true by default
  environments: [
     {
       name: 'Mainnet',
       url: 'https://explorer.ergoplatform.com',
     },
  ],
};

if (typeof global !== 'undefined') {
  global.__APP_CONFIG__ = __APP_CONFIG__;
}

docker-compose.yaml example:

version: '3.4'

services:
  nginx:
    image: nginx:1.17.9-alpine
    ports:
      - "443:443"
    volumes:
      - /data/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - /data/nginx/ssl:/etc/ssl:ro
      - /<your_working_dir>/front/build:/usr/share/nginx/html
      - /<your_working_dir>/front/config:/usr/share/nginx/config
    networks:
      - explorer-network
    depends_on:
      - api
  postgres:
    image: postgres:11-alpine
    shm_size: 2g
    environment:
      POSTGRES_PASSWORD: <pg_pass>
    ports:
      - "5432:5432"
    volumes:
      - /data/postgres:/var/lib/postgresql/data:rw
    networks:
      - explorer-network
  redis:
    image: redis:latest
    restart: always
    command: ["redis-server"]
    ports:
      - "127.0.0.1:6379:6379"
    volumes:
      - /data/redis:/usr/local/etc/redis
    networks:
      - explorer-network
  adminer:
    image: adminer:4-standalone
    ports:
      - "8082:8080"
    networks:
      - explorer-network
  grabber:
    image: oskin1/chain-grabber:latest
    networks:
      - explorer-network
    env_file:
      - .db_env
    depends_on:
      - postgres
  api:
    image: oskin1/explorer-api:latest
    ports:
      - "8081:8081"
    networks:
      - explorer-network
    env_file:
      - .db_env
      - .redis_env
      - .http_env
    depends_on:
      - postgres
      - redis
  utx-tracker:
    image: oskin1/utx-tracker:latest
    networks:
      - explorer-network
    env_file:
      - .db_env
    depends_on:
      - postgres
  utx-broadcaster:
    image: oskin1/utx-broadcaster:latest
    networks:
      - explorer-network
    env_file:
      - .redis_env
    depends_on:
      - redis

networks:
  explorer-network:
    external: true
Clone this wiki locally