version : '2'

services:
  backend:
    build:
      context: .
      dockerfile: backend.dockerfile
      args:
        - API_URL
        - MYSQL_DATABASE
        - MYSQL_USER
        - MYSQL_PASSWORD
        - WP_ENV
        - WP_AUTH_KEY
        - WP_SECURE_AUTH_KEY
        - WP_LOGGED_IN_KEY
        - WP_NONCE_KEY
        - WP_AUTH_SALT
        - WP_SECURE_AUTH_SALT
        - WP_LOGGED_IN_SALT
        - WP_NONCE_SALT
        - WP_JWT_AUTH_SECRET_KEY
    volumes:
      - ./log/backend/:/var/log/apache2/
    ports:
      - '8081:80'
    depends_on:
      - db
    #use links keywoard to use db as a known host "db" to connect to database
    links:
      - db
  
  frontend:
    build:
      context: .
      dockerfile: frontend.dockerfile
      args:
        - API_URL
    volumes:
      - ./log/frontend/:/var/log/apache2/
    ports:
      - '8080:80'
    

  db:
    build: 
      context: .
      dockerfile: mysql.dockerfile
      args:
        - API_URL
        - MYSQL_ROOT_PASSWORD
        - MYSQL_DATABASE
        - MYSQL_USER
        - MYSQL_PASSWORD
    ports:
      - '23306:3306'
    volumes:
      - ./database/volume/:/var/lib/mysql