name: inception

volumes:
  wordpress:
    driver: local
    driver_opts:
      device: $DATA_PATH/wordpress
      o: bind
      type: none

services:
  mariadb:
    restart: on-failure
    build:
      context: ./requirements/mariadb
      dockerfile: Dockerfile
    volumes:
      - type: bind
        source: $DATA_PATH/mariadb
        target: /var/lib/mysql
    networks:
      - inception
    env_file: .env
    secrets:
      - db_root_password
      - db_password
  nginx:
    restart: on-failure
    ports:
      - 443:443
    build:
      context: ./requirements/nginx
      dockerfile: Dockerfile
    depends_on:
      wordpress:
        condition: service_healthy
        restart: true
    volumes:
      - wordpress:/var/www/wordpress
    networks:
      inception:
        aliases:
          - $DOMAIN_NAME
    env_file: .env
  redis:
    restart: on-failure
    build:
      context: ./requirements/bonus/redis
      dockerfile: Dockerfile
    networks:
      - inception
    secrets:
      - redis_password
  wordpress:
    restart: on-failure
    depends_on:
      mariadb:
        condition: service_healthy
        restart: true
    build:
      context: ./requirements/wordpress
      dockerfile: Dockerfile
    volumes:
      - wordpress:/var/www/wordpress
    networks:
      - inception
    secrets:
      - db_password
      - admin_password
      - redis_password
    env_file: .env
  vsftpd:
    restart: on-failure
    build:
      context: ./requirements/bonus/vsftpd
      dockerfile: Dockerfile
    volumes:
      - wordpress:/var/www/wordpress
    ports:
      - 21:21
      - 20:20
      - 21100-21110:21100-21110
    secrets:
      - admin_password
    env_file: .env
  adminer:
    restart: on-failure
    depends_on:
      mariadb:
        condition: service_healthy
        restart: true
    build:
      context: ./requirements/bonus/adminer
      dockerfile: Dockerfile
    networks:
      - inception
    secrets:
      - db_password
    env_file: .env
  mailhog:
    restart: on-failure
    build:
      context: ./requirements/bonus/mailhog
      dockerfile: Dockerfile
    networks:
      - inception
  site:
    restart: on-failure
    build:
      context: ./requirements/bonus/site
      dockerfile: Dockerfile
    networks:
      - inception

secrets:
  db_password:
    file: ../secrets/db_password.txt
  db_root_password:
    file: ../secrets/db_root_password.txt
  admin_password:
    file: ../secrets/credentials.txt
  redis_password:
    file: ../secrets/redis_password.txt

networks:
  inception:
