# Redundant OPC UA server set — one compose file, topology chosen from the environment. # # Pick the topology by setting HA_MODE / HA_CONSISTENCY (and REDUNDANCY_MODE) either # inline or with --env-file. Three built-in topologies, each has a ready-made env file: # # * active/active, eventual consistency (CRDT gossip) — DEFAULT # --env-file samples/RedundantServer/active-active-eventual.env # * active/active, strong consistency (Raft) # --env-file samples/RedundantServer/active-active-strong.env # * active/passive, strong consistency (Raft) # --env-file samples/RedundantServer/active-passive.env # # Three server replicas run in every topology (Raft needs 3 for a fault-tolerant quorum; # active/active eventual works with 2 or 3 — remove server-c for a 2-node run). The # replica count is therefore configurable by dropping/adding server-c. # # The build context is the repository root. Run from the repo root, e.g. active/passive: # docker compose --env-file samples/RedundantServer/active-passive.env \ # -f samples/RedundantServer/docker-compose.yml up --build # # OPC UA endpoints on the host: replica-a opc.tcp://localhost:62543/RedundantServer, # replica-b :62544, replica-c :62545. The Raft transport (6560) and CRDT gossip (4840) # stay on the internal network and are addressed by container DNS. # # The transparent (nginx virtual endpoint) and GetEndpoints load-direction demos have # their own folders: Transparent/docker-compose.yml and LoadDirection/docker-compose.yml. x-server: &server build: context: ../.. dockerfile: samples/RedundantServer/Dockerfile image: opcua-redundant-server command: ["--port", "62543"] services: server-a: <<: *server hostname: server-a environment: HA_HOST: server-a HA_NODE_ID: replica-a HA_MODE: ${HA_MODE:-aa} HA_CONSISTENCY: ${HA_CONSISTENCY:-eventual} REDUNDANCY_MODE: ${REDUNDANCY_MODE:-} HA_GOSSIP_PORT: "4840" HA_GOSSIP_PEERS: "server-b:4840,server-c:4840" HA_RAFT_ID: "1" HA_RAFT_MEMBERS: "3" HA_RAFT_BIND: "tcp://0.0.0.0:6560" HA_RAFT_PEERS: "tcp://server-b:6560,tcp://server-c:6560" HA_REDUNDANT_PEERS: "urn:localhost:OPCFoundation:RedundantServer:replica-b|RedundantServer replica-b|opc.tcp://server-b:62543/RedundantServer,urn:localhost:OPCFoundation:RedundantServer:replica-c|RedundantServer replica-c|opc.tcp://server-c:62543/RedundantServer" ports: - "62543:62543" server-b: <<: *server hostname: server-b environment: HA_HOST: server-b HA_NODE_ID: replica-b HA_MODE: ${HA_MODE:-aa} HA_CONSISTENCY: ${HA_CONSISTENCY:-eventual} REDUNDANCY_MODE: ${REDUNDANCY_MODE:-} HA_GOSSIP_PORT: "4840" HA_GOSSIP_PEERS: "server-a:4840,server-c:4840" HA_RAFT_ID: "2" HA_RAFT_MEMBERS: "3" HA_RAFT_BIND: "tcp://0.0.0.0:6560" HA_RAFT_PEERS: "tcp://server-a:6560,tcp://server-c:6560" HA_REDUNDANT_PEERS: "urn:localhost:OPCFoundation:RedundantServer:replica-a|RedundantServer replica-a|opc.tcp://server-a:62543/RedundantServer,urn:localhost:OPCFoundation:RedundantServer:replica-c|RedundantServer replica-c|opc.tcp://server-c:62543/RedundantServer" ports: - "62544:62543" server-c: <<: *server hostname: server-c environment: HA_HOST: server-c HA_NODE_ID: replica-c HA_MODE: ${HA_MODE:-aa} HA_CONSISTENCY: ${HA_CONSISTENCY:-eventual} REDUNDANCY_MODE: ${REDUNDANCY_MODE:-} HA_GOSSIP_PORT: "4840" HA_GOSSIP_PEERS: "server-a:4840,server-b:4840" HA_RAFT_ID: "3" HA_RAFT_MEMBERS: "3" HA_RAFT_BIND: "tcp://0.0.0.0:6560" HA_RAFT_PEERS: "tcp://server-a:6560,tcp://server-b:6560" HA_REDUNDANT_PEERS: "urn:localhost:OPCFoundation:RedundantServer:replica-a|RedundantServer replica-a|opc.tcp://server-a:62543/RedundantServer,urn:localhost:OPCFoundation:RedundantServer:replica-b|RedundantServer replica-b|opc.tcp://server-b:62543/RedundantServer" ports: - "62545:62543" # A managed client that connects to one replica and transparently discovers / fails # over to the others. Part of the "clients" profile so `up` can start servers only. # One client PROCESS per replica: CLIENT_REPLICAS scales the number of containers, # each an independent managed client that fails over on its own. client: profiles: ["clients", "demo"] build: context: ../.. dockerfile: samples/RedundantClient/Dockerfile image: opcua-redundant-client deploy: replicas: ${CLIENT_REPLICAS:-1} depends_on: - server-a - server-b - server-c command: - "--server" - "opc.tcp://server-a:62543/RedundantServer" - "--autoaccept" - "--nosecurity" - "--duration" - "00:10:00"