services:
  web:
    build: ./front
    container_name: nextgoal-web
    ports:
      - "83:80"
    restart: unless-stopped
    depends_on:
      - api

  api:
    build: ./back
    container_name: nextgoal-api
    ports:
      - "5452:5452"
    environment:
      DB_USER: nextgoal
      DB_PASSWORD: nextgoal
      DB_HOST: db
      DB_PORT: 3306
      DB_NAME: nextgoal
    restart: unless-stopped
    depends_on:
      - db

  db:
    image: mysql:8.0
    container_name: nextgoal-db
    ports:
      - "3310:3306"
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: nextgoal
      MYSQL_USER: nextgoal
      MYSQL_PASSWORD: nextgoal
    volumes:
      - db_data:/var/lib/mysql
      - ./db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
    restart: unless-stopped
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

volumes:
  db_data:
