version: "3"

services:
  slims:
    container_name: slims
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - ENV=${APP_ENV}
      - DB_HOST=db
      - DB_PORT=3306
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - DB_NAME=${DB_NAME}
    volumes:
      - appfiles:/var/www/html/files
      - appimages:/var/www/html/images
      - apprepo:/var/www/html/repository
    ports:
      - "${HTTP_PORT}:80"
    networks:
      - proxy
    depends_on:
      - db

  db:
    image: mariadb:lts
    container_name: db
    ports:
      - "${DB_PORT}:3306"
    volumes:
      - ./install/senayan.sql:/docker-entrypoint-initdb.d/01-senayan.sql
      - ./install/sampledata.sql:/docker-entrypoint-initdb.d/02-sampledata.sql
      - dbdata:/var/lib/mysql
    environment:
      - MARIADB_ROOT_PASSWORD=${DB_PASS}
      - MARIADB_DATABASE=${DB_NAME}
    networks:
      - proxy

networks:
  proxy:
    driver: bridge

volumes:
  dbdata:
  appfiles:
  appimages:
  apprepo:
