#version: '3.8'

services:
  web:
    build: .
    ports:
      - "8081:80"
    volumes:
      - ./nchc_docker:/var/www/html   # 将当前目录挂载到容器的 /var/www/html
    networks:
      - mynetwork  
    depends_on:
      - db
    environment:
      DB_HOST: db
      DB_NAME: nchc_nz
      DB_USERNAME: nchc
      DB_PASSWORD: hanyuVr2498
      MAIL_HOST: my_database
      MAIL_PORT: 789
      MAIL_USERNAME: Support
      MAIL_PASSWORD: 1111

  db:
    image: mysql:8.0
    #image: postgres:10.0-alpine
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: nchc_nz
      MYSQL_USER: nchc
      MYSQL_PASSWORD: hanyuVr2498
    volumes:
      - ./nchc_nz.sql:/docker-entrypoint-initdb.d/nchc_nz.sql
    #  - db_data:/var/lib/mysql
    networks:
      - mynetwork

#volumes:
#  db_data:
networks:
  mynetwork:

#     depends_on:
#       - db
#     environment:
#       - MYSQL_HOST=db
#       - MYSQL_USER=root
#       - MYSQL_PASSWORD=rootpassword
#       - MYSQL_DATABASE=mydatabase

#   db:
#     image: mysql:8.0
#     environment:
#       MYSQL_ROOT_PASSWORD: rootpassword
#       MYSQL_DATABASE: mydatabase
#     volumes:
#       - db_data:/var/lib/mysql

# volumes:
#   db_data: