version: '3.9'
services:
  # START OF NGINX CONFIG
  #
  #
  nginx:
    image: nginx:1.21.6-alpine
    container_name: 'nginx'
    depends_on:
      - candy
      - mariadb
    links:
      - candy
    restart: unless-stopped
    volumes:
      - ./server:/var/www/html/cbt
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ./docker/nginx/logs:/var/log/nginx
    ports:
      # HOST:CONTAINER
      - 80:80
      # - 443:443

  candy:
    image: adityampc/cbtcandy:php-8.1.4-fpm-alpine
    container_name: cbt
    depends_on:
      - mariadb
    restart: always
    volumes:
      - ./server:/var/www/html/cbt
    working_dir: /var/www/html/cbt
    environment:
      # If you down want to use xDebug, set remote_enable=0
      XDEBUG_CONFIG: "remote_enable=0"
      PHP_IDE_CONFIG: "serverName=Docker"
  #
  #
  # END OF NGINX CONFIG
  #
  # START OF APACHE CONFIG
  #
  #
  # candy:    
  #   image: adityampc/cbtcandy:php-8.1.3-apache
  #   container_name: cbt
  #   depends_on:
  #     - mariadb
  #   restart: always
  #   volumes:
  #     - ./docker/apache/default.conf:/etc/apache2/sites-available/000-default.conf
  #     - ./server:/var/www/html/cbt
  #   working_dir: /var/www/html/cbt
  #   environment:
  #     # If you down want to use xDebug, set remote_enable=0
  #     XDEBUG_CONFIG: "remote_enable=0"
  #     PHP_IDE_CONFIG: "serverName=Docker"
  #   ports:
  #     # HOST:CONTAINER
  #     - 80:80
  #     - 443:443
  #
  #
  # END OF APACHE CONFIG

  mariadb:
    image: mariadb:10.7.3
    container_name: db
    # ganti ke 3306:3306 jika port 3306 tidak digunakan atau hapus 
    # ports:
    # HOST:CONTAINER
    # - 3305:3306
    volumes:
      - ./docker/mariadb/data/:/var/lib/mysql
      - ./docker/mariadb/logs:/var/log/mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rpcbt
      MYSQL_DATABASE: dbcbt
      MYSQL_USER: ucbt
      MYSQL_PASSWORD: pcbt

  phpmyadmin:
    image: phpmyadmin
    container_name: pmyadmin
    depends_on:
      - mariadb
    ports:
      # HOST:CONTAINER
      - 8081:80
    restart: unless-stopped
    environment:
      PMA_HOST: mariadb
      PMA_PORT: 3306
      PMA_USER: ucbt
      PMA_PASSWORD: pcbt
