# author oas Ohotnikov.A@artix.su
# Запускаем 3 сервиса: DB, delivery, gateway
version: '3'
services:
  delivery-db:
    image: postgres:10.6
    restart: "no"
    environment:
      POSTGRES_USER: delivery
      POSTGRES_DB: delivery
    container_name: delivery-db
    volumes:
      - delivery_postgres_data:/var/lib/postgresql/data
      - delivery_postgres_logs:/logs
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"
  delivery-service:
    image: dockerregistry.artix.su:2443/delivery-service:${TAG:-latest}
    restart: "no"
    ports:
      - "8110:8110"
    environment:
      - "JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1"
      - "LOG_LEVEL_ARTIX=INFO"
    deploy:
      resources:
        limits:
          memory: 1024M
        reservations:
          memory: 512M
    depends_on:
      - delivery-db
    volumes:
      - delivery_logs:/delivery
#  Костыль для времени https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes/683651
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"
    container_name: delivery-service
  delivery-gateway:
    image: dockerregistry.artix.su:2443/delivery-gateway:${TAG:-latest}
    restart: "no"
    environment:
      - "JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1"
    deploy:
      resources:
        limits:
          memory: 1024M
        reservations:
          memory: 512M
    depends_on:
      - delivery-db
      - delivery-service
    command: ["./wait-for.sh", "-t", "100", "delivery-service"]
    container_name: delivery-gateway
    volumes:
      - delivery_logs:/delivery
      - "/etc/timezone:/etc/timezone:ro"
      - "/etc/localtime:/etc/localtime:ro"
volumes:
  delivery_postgres_data:
  delivery_postgres_logs:
  delivery_logs:
