version: '3.1'

services:
  photolist:
    env_file:
      - ../configs/common.env
    build:
      context: ../.
      dockerfile: build/Dockerfile.Multistage
    image: photolist:latest
    links:
      - minio:minio
      - dbMysql:dbMysql
    volumes:
      - ../images:/app/images
      - ../configs/photolist.yaml:/etc/photolist.yaml
    depends_on:
      - "dbMysql"
      - "minio"
    command: ["/app/wait-for-it.sh", "dbMysql:3306", "--", "/app/photolist"]

  photoauth:
    env_file:
      - ../configs/common.env
      - ../configs/photoauth.env
    image: photolist:latest
    links:
      - dbMysql:dbMysql
      - auth:auth
    volumes:
      - ../configs/photoauth.yaml:/etc/photoauth.yaml
    depends_on:
      - "dbMysql"
      - "photolist"
      - "auth"
    command: ["/app/wait-for-it.sh", "dbMysql:3306", "--", "/app/photoauth"]

  auth:
    env_file:
      - ../configs/common.env
      - ../configs/auth.env
    image: photolist:latest
    links:
      - dbMysql:dbMysql
    volumes:
      - ../configs/auth.yaml:/etc/auth.yaml
    depends_on:
      - "photolist"
      - "dbMysql"
    command: ["/app/wait-for-it.sh", "dbMysql:3306", "--", "/app/auth"]


  dbMysql:
    image: mariadb:10.7
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    ports:
      - 3306:3306
    volumes:
      # paths relative to docker-compose files
      - './_mysql/:/docker-entrypoint-initdb.d/'
      # - ../tmp/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: "love"
      MYSQL_DATABASE: photolist

  nginx:
    image: nginx:1.17
    links:
      - minio:minio
      - photolist:photolist
      - photoauth:photoauth
    depends_on:
      - "photolist"
      - "photoauth"
    volumes:
      - ../configs/nginx:/etc/nginx/conf.d
    ports:
      - 8080:80

  minio:
    restart: always
    image: minio/minio
    ports:
      - "9000:9000"
    environment:
      MINIO_ACCESS_KEY: access_123
      MINIO_SECRET_KEY: secret_123
    # что запускать и где данные храняться
    command: server /data 
    volumes:
      - ../minio_data:/data

  adminer:
    image: adminer
    restart: always
    ports:
      - 8090:8080