version: '3.2'
services:
  kbs:
    build:
      context: .
      dockerfile: Dockerfile.kbs
    # image: trustee-registry.cn-hangzhou.cr.aliyuncs.com/instance/kbs:latest
    command: [
        "/usr/local/bin/kbs",
        "--config-file",
        "/etc/kbs-config.toml",
      ]
    restart: always # keep the server running
    ports:
      - "8080:8080"
    volumes:
      - ./kbs/data/kbs-storage:/opt/confidential-containers/kbs/repository:rw
      - ./kbs/config/public.pub:/opt/confidential-containers/kbs/user-keys/public.pub
      - ./kbs/config/docker-compose/kbs-config.toml:/etc/kbs-config.toml
    depends_on:
    - as

  as:
    build:
      context: .
      dockerfile: Dockerfile.as-grpc
    # image: trustee-registry.cn-hangzhou.cr.aliyuncs.com/instance/as:latest
    ports:
    - "50004:50004"
    restart: always
    environment:
      RUST_LOG: debug
    volumes:
    - ./kbs/data/attestation-service:/opt/confidential-containers/attestation-service:rw
    - ./kbs/config/as-config.json:/etc/as-config.json:rw
    - ./kbs/config/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf:rw
    command: [
      "grpc-as",
      "--socket",
      "0.0.0.0:50004",
      "--config-file",
      "/etc/as-config.json"
    ]
    depends_on:
    - rvps

  as-restful:
    build:
      context: .
      dockerfile: Dockerfile.as-restful
    # image: trustee-registry.cn-hangzhou.cr.aliyuncs.com/instance/as-restful:latest
    ports:
    - "50005:50005"
    restart: always
    environment:
      RUST_LOG: debug
    volumes:
    - ./kbs/data/attestation-service:/opt/confidential-containers/attestation-service:rw
    - ./kbs/config/as-config.json:/etc/as-config.json:rw
    - ./kbs/config/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf:rw
    command: [
      "restful-as",
      "--socket",
      "0.0.0.0:50005",
      "--config-file",
      "/etc/as-config.json"
    ]
    depends_on:
    - rvps

  rvps:
    # image: trustee-registry.cn-hangzhou.cr.aliyuncs.com/instance/rvps:latest
    build:
      context: .
      dockerfile: Dockerfile.rvps
    restart: always # keep the server running
    ports:
      - "50003:50003"
    volumes:
      - ./kbs/data/reference-values:/opt/confidential-containers/attestation-service/reference_values:rw
      - ./kbs/config/rvps.json:/etc/rvps.json:rw
    command: [
      "rvps",
      "--address",
      "0.0.0.0:50003"
    ]

  gateway:
    build:
      context: .
      dockerfile: Dockerfile.trustee-gateway
    # image: localhost/trustee-gateway:latest
    restart: always
    ports:
      - "8081:8081"
    volumes:
      - ./trustee-gateway/config.yaml:/app/config.yaml:rw
      - ./trustee-gateway/data:/app/data:rw
    command: [
      "/app/gateway",
      "--config",
      "/app/config.yaml"
    ]
    depends_on:
    - kbs
    - as
    - rvps

  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
    ports:
      - "8082:8082"
    depends_on:
    - gateway
