services:
  <<BACKEND_SERVICE>>:
    image: <<BACKEND_IMAGE>>
    pull_policy: if_not_present
    container_name: <<BACKEND_DOCKER>>
    ports:
      - "<<BACKEND_HOST_PORT>>:<<BACKEND_PORT>>"
    environment:
      - HTTP_PROXY
      - HTTPS_PROXY
      - https_proxy
      - http_proxy
      - <<no_proxy_str>>
      - <<NO_PROXY_STR>>
    env_file:
      - ../.envs/env.runtime.<<NAME_SUFFIX>>
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ../examples:<<BACKEND_PATH>>/examples
      - ./config.yaml:<<BACKEND_PATH>>/conf/config.yaml
      - ./config.json:<<BACKEND_PATH>>/conf/config.json
      - ../log-dirs/logs-<<NAME_SUFFIX>>/server:/app/logs
      - <<SQLITE_VOLUME>>:/app/data
      - <<MEMORY_VOLUME>>:<<MEMORY_DATA_PATH>>
      - <<KNOWLEDGE_VOLUME>>:/app/site-packages/data
    networks:
      - <<JIUWEN_NETWORK_NAME>>
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s

  <<FRONTEND_SERVICE>>:
    image: <<FRONTEND_IMAGE>>
    pull_policy: if_not_present
    container_name: <<FRONTEND_DOCKER>>
    ports:
      - "<<FRONTEND_HOST_PORT>>:<<FRONTEND_PORT>>"
    environment:
      - SSL_PASSWORD
    env_file:
      - ../.envs/env.runtime.<<NAME_SUFFIX>>
    volumes:
      - ./.ssl-dirs/ssl-<<NAME_SUFFIX>>:/etc/nginx/ssl
      - /etc/localtime:/etc/localtime:ro
      - ./config.json:/usr/share/nginx/html/config.json
      - ./.nginx-files/nginx.conf.<<NAME_SUFFIX>>:/etc/nginx/nginx.conf
    depends_on:
      <<BACKEND_SERVICE>>:
        condition: service_healthy
    networks:
      - <<JIUWEN_NETWORK_NAME>>
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "-k", "https://localhost:<<FRONTEND_PORT>>/"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

volumes:
  <<SQLITE_VOLUME>>:
  <<MEMORY_VOLUME>>:
  <<KNOWLEDGE_VOLUME>>:

networks:
  <<JIUWEN_NETWORK_NAME>>:
    driver: bridge