# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

version: '3.7'

services:
  teaclave-authentication-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    ports:
      - 7776:7776
    expose:
      - 7776
      - 17776
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    entrypoint: ./teaclave_authentication_service
    container_name: teaclave-authentication-service
    networks:
      api:
      internal:

  teaclave-frontend-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    ports:
      - 7777:7777
    expose:
      - 7777
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    entrypoint: ./teaclave_frontend_service
    depends_on:
      - teaclave-management-service
    container_name: teaclave-frontend-service
    networks:
      api:
      internal:

  teaclave-management-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    expose:
      - 17777
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
      - /tmp/fusion_data:/tmp/fusion_data
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    entrypoint: ./teaclave_management_service
    depends_on:
      - teaclave-storage-service
      - teaclave-access-control-service
    container_name: teaclave-management-service
    networks:
      internal:

  teaclave-storage-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    expose:
      - 17778
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    entrypoint: ./teaclave_storage_service
    container_name: teaclave-storage-service
    networks:
      internal:

  teaclave-access-control-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    expose:
      - 17779
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    container_name: teaclave-access-control-service
    entrypoint: ./teaclave_access_control_service
    networks:
      internal:

  teaclave-execution-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    expose:
      - 17770
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
      - /tmp/fusion_data:/tmp/fusion_data
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    entrypoint: ./teaclave_execution_service
    container_name: teaclave-execution-service
    depends_on:
      - teaclave-scheduler-service
    networks:
      internal:
      fs:

  teaclave-scheduler-service:
    build:
      context: ../
      dockerfile: docker/teaclave-rt.ubuntu-2004.Dockerfile
    expose:
      - 17780
    volumes:
      - ./runtime.config.toml:/teaclave/runtime.config.toml
    working_dir: /teaclave
    environment:
      - AS_SPID
      - AS_KEY
      - AS_ALGO
      - AS_URL
      - TEACLAVE_LOG
    entrypoint: ./teaclave_scheduler_service
    container_name: teaclave-scheduler-service
    depends_on:
      - teaclave-storage-service
    networks:
      internal:

  teaclave-file-service:
    image: python:3
    container_name: teaclave-file-service
    volumes:
      - ../release/tests:/teaclave-file-service
      - /tmp/fusion_data:/tmp/fusion_data
    working_dir: /tmp/fusion_data
    ports:
      - 6789:6789
    expose:
      - 6789
    entrypoint: /teaclave-file-service/scripts/simple_http_server.py
    networks:
      fs:

networks:
  internal:
  api:
  fs:
