version: '3.7'

services:
  frontend:
    container_name: frontend
    build:
      context: frontend
    volumes:
      - './frontend:/app'
      - './backend/database:/database'
      - '/app/node_modules'
      - '/app/.next'
    ports:
      - '127.0.0.1:8800:3000'
    environment:
      - NODE_ENV=development
    depends_on:
      - backend

  backend:
    container_name: backend
    build:
      context: backend
    volumes:
      - './backend:/app'
      - '/app/node_modules'
    ports:
      - '127.0.0.1:8801:4000'
    environment:
      - NODE_ENV=development
      - PRISMA_MANAGEMENT_API_SECRET=PrismaSecret
    depends_on:
      - prisma

  prisma:
    image: prismagraphql/prisma:1.34.10
    restart: always
    ports:
      - '127.0.0.1:8846:4466'
    environment:
      PRISMA_CONFIG: |
        port: 4466
        managementApiSecret: "PrismaSecret"
        databases:
          default:
            connector: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true

  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - '/var/lib/mysql'
      - './dbBackup:/backup'

  proxy:
    image: nginx:alpine
    restart: always
    ports:
      - '8820:8820'
    volumes:
      - './proxy/nginx.conf:/etc/nginx/nginx.conf:ro'
