version: "3"

services:
  php-fpm:
    build: ./etc/php/dockerfile/81/
    image: domp-php
    container_name: php-fpm
    environment:
      TZ: Asia/Shanghai
    volumes:
      - ./etc/php/php-fpm.d/php-fpm.conf:/usr/local/etc/php-fpm.conf
      - ./mnt/shm:/dev/shm
      - ./mnt/data:/data
      - ./mnt/tmp:/tmp
      - ./../../:/wwwroot
    depends_on:
      - redis
      - mongodb
      - mysql
    restart: always

  openresty:
    container_name: openresty
    image: openresty/openresty:centos     # 开发环境
    #image: openresty/openresty:latest     # 生产环境
    environment:
      TZ: Asia/Shanghai
    volumes:
      - ./etc/nginx/conf.d:/etc/nginx/conf.d
      - ./etc/nginx/cert:/etc/nginx/cert
      - ./mnt/shm:/dev/shm
      - ./mnt/data:/data
      - ./mnt/tmp:/tmp
      - ./../../:/wwwroot
    ports:
      - 0.0.0.0:80:80
    depends_on:
      - php-fpm
    privileged: true
    restart: always

  redis:
    build: ./etc/redis/
    container_name: redis
    image: domp-redis
    #command: --requirepass wanggang1985    # 覆盖密码
    # volumes:                              # 覆盖路径 
    #   - D:\\docker_mnt\\data\\redis:/data/redis
    #   - ./etc/redis/port6379.conf:/usr/local/etc/redis/redis.conf
    restart: always

  mongodb:
    container_name: mongodb
    image: mongo:latest
    restart: always
    command: --wiredTigerCacheSizeGB 0.25
    # 其实也可以像redis 一样把配置文件搞进去或者是映射成路径, 懒得搞了    
    environment:
      MONGO_INITDB_ROOT_USERNAME: gwang
      MONGO_INITDB_ROOT_PASSWORD: wanggang1985

  mysql:
    build: ./etc/mysql/
    container_name: mysql
    image: domp-mysql
    restart: always
    ports:
      - 3306:3306
    # 这里mysql需要初始化一下数据库和表结构. sql文件是dockerfile提前拷贝过去的, 
    # 也可以通过后期执行脚本docker cp xx container:/data/xx
    command: --init-file=/tmp/ylsj2019_pay_dev.sql
    environment:
      MYSQL_ROOT_PASSWORD: wanggang1985
      MYSQL_DATABASE: ylsj2019_pay_dev
      MYSQL_USER: gwang
      MYSQL_PASSWORD: wanggang1985

  # phpmyadmin:
  #   image: phpmyadmin:fpm-alpine
  #   restart: always
  #   ports:
  #     - 8080:80
  #   environment:
  #     - PMA_ARBITRARY=1