You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Local development

Use the following instructions to setup two federated Corteza instances.

Create a data directory

CLI command to create the directory with permissions:
mkdir data && chmod 755 data/ -R

Create the docker compose file

docker-compose.yaml files for the two instances:
version: "3"
services:
  db_origin:
    image: percona:8.0
    container_name: db_origin
    restart: always
    cap_add:
      - SYS_NICE  # mbind warning fix
    environment:
      MYSQL_DATABASE:      corteza
      MYSQL_USER:          corteza
      MYSQL_PASSWORD:      rootcorteza
      MYSQL_ROOT_PASSWORD: rootcorteza
    volumes:
      - "../../data/db_origin:/var/lib/mysql"
    ports:
      - 3306:3306

  db_destination:
    image: percona:8.0
    container_name: db_destination
    restart: always
    cap_add:
      - SYS_NICE  # mbind warning fix
    environment:
      MYSQL_DATABASE:      corteza
      MYSQL_USER:          corteza
      MYSQL_PASSWORD:      rootcorteza
      MYSQL_ROOT_PASSWORD: rootcorteza
    volumes:
      - "../../data/db_destination:/var/lib/mysql"
    ports:
      - 3307:3306

  node_origin:
    image: golang
    container_name: node_origin
    entrypoint: [ make, watch ]
    depends_on: [ db_origin ]
    volumes:
      - "../../:/app"
      - "./.env.orig:/app/.env"
    working_dir: /app
    restart: always
    ports:
      - 8084:8084

  node_destination:
    image: golang
    container_name: node_destination
    entrypoint: [ make, watch ]
    depends_on: [ db_destination ]
    volumes:
      - "../../:/app"
      - "./.env.dest:/app/.env"
    working_dir: /app
    restart: always
    ports:
      - 8085:8084

This docker compose file creates two Corteza instances with their corresponding databases. Binary uploads are stored in the data directory created above.

Create the environment files

\.env.orig:
PROVISION_ALWAYS=false
HTTP_ADDR=:8084

LOG_LEVEL=info

DB_DSN=corteza:rootcorteza@tcp(db_origin:3306)/corteza?collation=utf8mb4_general_ci
LOG_DEBUG=true
CORREDOR_ADDR=localhost:50051
CORREDOR_ENABLED=false
CORREDOR_CLIENT_CERTIFICATES_ENABLED=false

GRPC_SERVER_ADDR=localhost:50052

CORTEZA_PROTOBUF_PATH=/home/wrk/Projects/corteza/corteza-protobuf

FEDERATION_ENABLED=true
FEDERATION_HOST=node_origin:8084
FEDERATION_LABEL=Federation origin host

# Sync settings
FEDERATION_SYNC_STRUCTURE_MONITOR_INTERVAL=60s
FEDERATION_SYNC_STRUCTURE_PAGE_SIZE=1
FEDERATION_SYNC_DATA_MONITOR_INTERVAL=20s
FEDERATION_SYNC_DATA_PAGE_SIZE=100
\.env.dest:
PROVISION_ALWAYS=false
HTTP_ADDR=:8084

LOG_LEVEL=info

DB_DSN=corteza:rootcorteza@tcp(db_destination:3306)/corteza?collation=utf8mb4_general_ci
LOG_DEBUG=true
CORREDOR_ADDR=localhost:50051
CORREDOR_ENABLED=false
CORREDOR_CLIENT_CERTIFICATES_ENABLED=false

GRPC_SERVER_ADDR=localhost:50052

CORTEZA_PROTOBUF_PATH=/home/wrk/Projects/corteza/corteza-protobuf

FEDERATION_ENABLED=true
FEDERATION_HOST=node_destination:8084
FEDERATION_LABEL=Federation destination host

# Sync settings
FEDERATION_SYNC_STRUCTURE_MONITOR_INTERVAL=60s
FEDERATION_SYNC_STRUCTURE_PAGE_SIZE=1
FEDERATION_SYNC_DATA_MONITOR_INTERVAL=20s
FEDERATION_SYNC_DATA_PAGE_SIZE=100

Run the instances

$ docker-compose up -d node_origin
$ docker-compose up -d node_destination

Once the instances are up, you can follow the docker-compose logs by running:

Logs for the origin Corteza instance:
$ docker-compose logs -f node_origin
Logs for the destination Corteza instance:
$ docker-compose logs -f node_destination

Port mappings

Instance Local connectivity Docker connectivity

node_origin

localhost:8084

node_origin:8084 (from node_destination)

node_destination

localhost:8085

node_destination:8084 (from node_origin)

db_origin

localhost:3306

db_origin:3306 (from any of the nodes)

db_destination

localhost:3307

db_destination:3306 (from any of the nodes)